diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-01-25 01:15:54 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-01-25 01:15:54 -0800 |
| commit | 8cccccce9f0ae4d145b8da07ee7b615cb01ce23e (patch) | |
| tree | a20d9f9083d8683414a6d6c81fec7af853ad8f03 | |
| parent | 90e30c01704219b86ebb8132b66b6c4adcf24d09 (diff) | |
| download | seaweedfs-8cccccce9f0ae4d145b8da07ee7b615cb01ce23e.tar.xz seaweedfs-8cccccce9f0ae4d145b8da07ee7b615cb01ce23e.zip | |
mount: reuse the entry object for the new directory
avoid mkdir and then query for the same directory
reduces these "context canceled" issues
attr read directory:"/seaweedfs/other/java/s3copier/src/main/java/com" name:"seaweedfs" : rpc error: code = Canceled desc = context canceled
| -rw-r--r-- | weed/filesys/dir.go | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go index b783cbcbe..7af5544ff 100644 --- a/weed/filesys/dir.go +++ b/weed/filesys/dir.go @@ -154,21 +154,23 @@ func (dir *Dir) Create(ctx context.Context, req *fuse.CreateRequest, func (dir *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, error) { + newEntry := &filer_pb.Entry{ + Name: req.Name, + IsDirectory: true, + Attributes: &filer_pb.FuseAttributes{ + Mtime: time.Now().Unix(), + Crtime: time.Now().Unix(), + FileMode: uint32(req.Mode &^ dir.wfs.option.Umask), + Uid: req.Uid, + Gid: req.Gid, + }, + } + err := dir.wfs.WithFilerClient(ctx, func(client filer_pb.SeaweedFilerClient) error { request := &filer_pb.CreateEntryRequest{ Directory: dir.Path, - Entry: &filer_pb.Entry{ - Name: req.Name, - IsDirectory: true, - Attributes: &filer_pb.FuseAttributes{ - Mtime: time.Now().Unix(), - Crtime: time.Now().Unix(), - FileMode: uint32(req.Mode &^ dir.wfs.option.Umask), - Uid: req.Uid, - Gid: req.Gid, - }, - }, + Entry: newEntry, } glog.V(1).Infof("mkdir: %v", request) @@ -181,7 +183,7 @@ func (dir *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, err }) if err == nil { - node := dir.newDirectory(filer2.NewFullPath(dir.Path, req.Name), nil) + node := dir.newDirectory(filer2.NewFullPath(dir.Path, req.Name), newEntry) return node, nil } |
