diff --git a/depends/bazil.org/fuse/fs/serve.go b/depends/bazil.org/fuse/fs/serve.go index 61bb43dd9..f9ab9525d 100644 --- a/depends/bazil.org/fuse/fs/serve.go +++ b/depends/bazil.org/fuse/fs/serve.go @@ -926,6 +926,40 @@ func (s *Server) Serve(fs FS, opt *proto.MountOptions) error { return fmt.Errorf("restore fail: %v", err) } + if opt != nil && opt.FuseServeThreads <= 0 { + for { + if s.TrySuspend(fs) { + break + } + + req, err := s.conn.ReadRequest() + if err != nil { + if err == io.EOF { + break + } + return err + } + + switch req.(type) { + case *fuse.ForgetRequest: + ctx := context.Background() + ForgetServeLimit.Wait(ctx) + default: + } + + s.wg.Add(1) + go func() { + defer s.wg.Done() + if opt != nil && opt.RequestTimeout > 0 { + s.serveWithTimeOut(req, opt.RequestTimeout) + } else { + s.serve(req) + } + }() + } + return nil + } + fn := func() error { defer s.wg.Done() @@ -949,16 +983,6 @@ func (s *Server) Serve(fs FS, opt *proto.MountOptions) error { default: } - // s.wg.Add(1) - // go func() { - // defer s.wg.Done() - // if opt != nil && opt.RequestTimeout > 0 { - // s.serveWithTimeOut(req, opt.RequestTimeout) - // } else { - // s.serve(req) - // } - // }() - if opt != nil && opt.RequestTimeout > 0 { s.serveWithTimeOut(req, opt.RequestTimeout) } else { diff --git a/proto/mount_options.go b/proto/mount_options.go index b909deffd..40fcfd932 100644 --- a/proto/mount_options.go +++ b/proto/mount_options.go @@ -205,7 +205,7 @@ func InitMountOptions(opts []MountOption) { opts[MetaCacheAcceleration] = MountOption{"metaCacheAcceleration", "keep meta cache and get inode/extents in one go", "", false} opts[MinimumNlinkReadDir] = MountOption{"minimumNlinkReadDir", "the minimum Nlink value of the directory that actively triggers the ReadDir operation", "", int64(10000)} opts[InodeLruLimit] = MountOption{"inodeLruLimit", "capacity for inode lru", "", int64(10000000)} - opts[FuseServeThreads] = MountOption{"fuseServeThreads", "Fuse Serve Threads", "", int64(64)} + opts[FuseServeThreads] = MountOption{"fuseServeThreads", "Fuse Serve Threads", "", int64(0)} for i := 0; i < MaxMountOption; i++ { flag.StringVar(&opts[i].cmdlineValue, opts[i].keyword, "", opts[i].description) }