1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-07 09:37:49 +02:00

mount: fix renaming a deep directory with unvisited directories

This commit is contained in:
Chris Lu 2021-10-16 23:33:45 -07:00
parent b9a2efd69b
commit 0ccdb937bb
3 changed files with 8 additions and 5 deletions

View file

@ -352,7 +352,7 @@ func (dir *Dir) ReadDirAll(ctx context.Context) (ret []fuse.Dirent, err error) {
glog.Errorf("dir ReadDirAll %s: %v", dirPath, err) glog.Errorf("dir ReadDirAll %s: %v", dirPath, err)
return nil, fuse.EIO return nil, fuse.EIO
} }
listErr := dir.wfs.metaCache.ListDirectoryEntries(context.Background(), dirPath, "", false, int64(math.MaxInt32), func(entry *filer.Entry) bool { listErr := dir.wfs.metaCache.ListDirectoryEntries(context.Background(), dir.wfs, dirPath, "", false, int64(math.MaxInt32), func(entry *filer.Entry) bool {
processEachEntryFn(entry, false) processEachEntryFn(entry, false)
return true return true
}) })

View file

@ -131,7 +131,7 @@ func (dir *Dir) moveFolderSubEntries(ctx context.Context, oldParent util.FullPat
glog.V(1).Infof("moving folder %s => %s", currentDirPath, newDirPath) glog.V(1).Infof("moving folder %s => %s", currentDirPath, newDirPath)
var moveErr error var moveErr error
listErr := dir.wfs.metaCache.ListDirectoryEntries(ctx, currentDirPath, "", false, int64(math.MaxInt32), func(item *filer.Entry) bool { listErr := dir.wfs.metaCache.ListDirectoryEntries(ctx, dir.wfs, currentDirPath, "", false, int64(math.MaxInt32), func(item *filer.Entry) bool {
moveErr = dir.moveEntry(ctx, currentDirPath, item, newDirPath, item.Name()) moveErr = dir.moveEntry(ctx, currentDirPath, item, newDirPath, item.Name())
if moveErr != nil { if moveErr != nil {
return false return false

View file

@ -2,10 +2,10 @@ package meta_cache
import ( import (
"context" "context"
"fmt"
"github.com/chrislusf/seaweedfs/weed/filer" "github.com/chrislusf/seaweedfs/weed/filer"
"github.com/chrislusf/seaweedfs/weed/filer/leveldb" "github.com/chrislusf/seaweedfs/weed/filer/leveldb"
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/util/bounded_tree" "github.com/chrislusf/seaweedfs/weed/util/bounded_tree"
"os" "os"
@ -117,12 +117,15 @@ func (mc *MetaCache) DeleteEntry(ctx context.Context, fp util.FullPath) (err err
return mc.localStore.DeleteEntry(ctx, fp) return mc.localStore.DeleteEntry(ctx, fp)
} }
func (mc *MetaCache) ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int64, eachEntryFunc filer.ListEachEntryFunc) error { func (mc *MetaCache) ListDirectoryEntries(ctx context.Context, client filer_pb.FilerClient, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int64, eachEntryFunc filer.ListEachEntryFunc) error {
//mc.RLock() //mc.RLock()
//defer mc.RUnlock() //defer mc.RUnlock()
if !mc.visitedBoundary.HasVisited(dirPath) { if !mc.visitedBoundary.HasVisited(dirPath) {
return fmt.Errorf("unsynchronized dir: %v", dirPath) glog.V(2).Infof("visit unsynchronized dir: %v", dirPath)
// this should not happen often
// unless, e.g., moving a deep directory
EnsureVisited(mc, client, dirPath)
} }
_, err := mc.localStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit, func(entry *filer.Entry) bool { _, err := mc.localStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit, func(entry *filer.Entry) bool {