aboutsummaryrefslogtreecommitdiff
path: root/weed/mount
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2025-12-09 22:02:17 -0800
committerGitHub <noreply@github.com>2025-12-09 22:02:17 -0800
commit1e1473ef4ac8e0ca70f25a3bcf5ef57f79b03779 (patch)
tree9e6f7d0c777ee64d5e16959a27cd89ac0275657b /weed/mount
parent4bc2b6d62b70cbc322706191e0e98228af4729e3 (diff)
downloadseaweedfs-1e1473ef4ac8e0ca70f25a3bcf5ef57f79b03779.tar.xz
seaweedfs-1e1473ef4ac8e0ca70f25a3bcf5ef57f79b03779.zip
mount: improve NFS directory listing (#7696)
mount: remove unused isEarlyTerminated variable The variable was redundant because when processEachEntryFn returns false, we immediately return fuse.OK, so the check was always false.
Diffstat (limited to 'weed/mount')
-rw-r--r--weed/mount/weedfs_dir_read.go53
1 files changed, 24 insertions, 29 deletions
diff --git a/weed/mount/weedfs_dir_read.go b/weed/mount/weedfs_dir_read.go
index 492b5422d..325512c37 100644
--- a/weed/mount/weedfs_dir_read.go
+++ b/weed/mount/weedfs_dir_read.go
@@ -159,7 +159,6 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl
}
}
- isEarlyTerminated := false
dirPath, code := wfs.inodeToPath.GetPath(input.NodeId)
if code != fuse.OK {
return code
@@ -179,13 +178,11 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl
if !isPlusMode {
if !out.AddDirEntry(dirEntry) {
- isEarlyTerminated = true
return false
}
} else {
entryOut := out.AddDirLookupEntry(dirEntry)
if entryOut == nil {
- isEarlyTerminated = true
return false
}
if fh, found := wfs.fhMap.FindFileHandle(inode); found {
@@ -257,35 +254,33 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl
}
// Cache exhausted, load next batch
- if !isEarlyTerminated {
- if err := meta_cache.EnsureVisited(wfs.metaCache, wfs, dirPath); err != nil {
- glog.Errorf("dir ReadDirAll %s: %v", dirPath, err)
- return fuse.EIO
- }
+ if err := meta_cache.EnsureVisited(wfs.metaCache, wfs, dirPath); err != nil {
+ glog.Errorf("dir ReadDirAll %s: %v", dirPath, err)
+ return fuse.EIO
+ }
- // Batch loading: fetch batchSize entries starting from lastEntryName
- loadedCount := 0
- bufferFull := false
- loadErr := wfs.metaCache.ListDirectoryEntries(context.Background(), dirPath, lastEntryName, false, int64(batchSize), func(entry *filer.Entry) (bool, error) {
- currentIndex := int64(len(dh.entryStream))
- dh.entryStream = append(dh.entryStream, entry)
- loadedCount++
- if !processEachEntryFn(entry, currentIndex) {
- bufferFull = true
- return false, nil
- }
- return true, nil
- })
- if loadErr != nil {
- glog.Errorf("list meta cache: %v", loadErr)
- return fuse.EIO
+ // Batch loading: fetch batchSize entries starting from lastEntryName
+ loadedCount := 0
+ bufferFull := false
+ loadErr := wfs.metaCache.ListDirectoryEntries(context.Background(), dirPath, lastEntryName, false, int64(batchSize), func(entry *filer.Entry) (bool, error) {
+ currentIndex := int64(len(dh.entryStream))
+ dh.entryStream = append(dh.entryStream, entry)
+ loadedCount++
+ if !processEachEntryFn(entry, currentIndex) {
+ bufferFull = true
+ return false, nil
}
+ return true, nil
+ })
+ if loadErr != nil {
+ glog.Errorf("list meta cache: %v", loadErr)
+ return fuse.EIO
+ }
- // Mark finished only when loading completed normally (not buffer full)
- // and we got fewer entries than requested
- if !bufferFull && loadedCount < batchSize {
- dh.isFinished = true
- }
+ // Mark finished only when loading completed normally (not buffer full)
+ // and we got fewer entries than requested
+ if !bufferFull && loadedCount < batchSize {
+ dh.isFinished = true
}
}