diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-12-16 23:20:08 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-12-16 23:20:08 -0800 |
| commit | 3ac54792e14f73ce8922ebfdbc88c0b03741fd07 (patch) | |
| tree | 0a790e73d0f48a9550e81eac94891dcd1fa45dd1 /weed/filesys | |
| parent | 39bf274a83bb24609589b89ffe5551ca21d967b2 (diff) | |
| download | seaweedfs-3ac54792e14f73ce8922ebfdbc88c0b03741fd07.tar.xz seaweedfs-3ac54792e14f73ce8922ebfdbc88c0b03741fd07.zip | |
paginate when filer deleting and FUSE mount renaming
Diffstat (limited to 'weed/filesys')
| -rw-r--r-- | weed/filesys/dir_rename.go | 43 | ||||
| -rw-r--r-- | weed/filesys/filehandle.go | 4 |
2 files changed, 34 insertions, 13 deletions
diff --git a/weed/filesys/dir_rename.go b/weed/filesys/dir_rename.go index 8b891752b..61e620148 100644 --- a/weed/filesys/dir_rename.go +++ b/weed/filesys/dir_rename.go @@ -7,6 +7,7 @@ import ( "github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "path/filepath" + "math" ) func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirectory fs.Node) error { @@ -40,21 +41,37 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector func moveEntry(ctx context.Context, client filer_pb.SeaweedFilerClient, oldParent string, entry *filer_pb.Entry, newParent, newName string) error { if entry.IsDirectory { currentDirPath := filepath.Join(oldParent, entry.Name) - request := &filer_pb.ListEntriesRequest{ - Directory: currentDirPath, - } - - glog.V(4).Infof("read directory: %v", request) - resp, err := client.ListEntries(ctx, request) - if err != nil { - glog.V(0).Infof("list %s: %v", oldParent, err) - return fuse.EIO - } - for _, item := range resp.Entries { - err := moveEntry(ctx, client, currentDirPath, item, filepath.Join(newParent, newName), item.Name) + lastFileName := "" + includeLastFile := false + limit := math.MaxInt32 + for limit > 0 { + request := &filer_pb.ListEntriesRequest{ + Directory: currentDirPath, + StartFromFileName: lastFileName, + InclusiveStartFrom: includeLastFile, + Limit: 1024, + } + glog.V(4).Infof("read directory: %v", request) + resp, err := client.ListEntries(ctx, request) if err != nil { - return err + glog.V(0).Infof("list %s: %v", oldParent, err) + return fuse.EIO + } + if len(resp.Entries) == 0 { + break + } + + for _, item := range resp.Entries { + lastFileName = item.Name + err := moveEntry(ctx, client, currentDirPath, item, filepath.Join(newParent, newName), item.Name) + if err != nil { + return err + } + limit-- + } + if len(resp.Entries) < 1024 { + break } } diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index e74228f3c..bbaa39f05 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -12,6 +12,7 @@ import ( "net/http" "strings" "sync" + "time" ) type FileHandle struct { @@ -207,6 +208,9 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error { fh.f.entry.Attributes.Mime = fh.contentType fh.f.entry.Attributes.Uid = req.Uid fh.f.entry.Attributes.Gid = req.Gid + fh.f.entry.Attributes.Mtime = time.Now().Unix() + fh.f.entry.Attributes.Crtime = time.Now().Unix() + fh.f.entry.Attributes.FileMode = uint32(0770) } request := &filer_pb.CreateEntryRequest{ |
