1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-02 15:16:51 +02:00

mount2: fix directory pagination

This commit is contained in:
chrislu 2022-02-15 22:42:10 -08:00
parent df51e0c042
commit 3cbce878f2

View file

@ -16,7 +16,6 @@ type DirectoryHandleId uint64
type DirectoryHandle struct { type DirectoryHandle struct {
isFinished bool isFinished bool
counter uint32
lastEntryName string lastEntryName string
} }
@ -139,17 +138,16 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl
return fuse.OK return fuse.OK
} }
isEarlyTerminated := false
dirPath := wfs.inodeToPath.GetPath(input.NodeId) dirPath := wfs.inodeToPath.GetPath(input.NodeId)
var dirEntry fuse.DirEntry var dirEntry fuse.DirEntry
if input.Offset == 0 && !isPlusMode { if input.Offset == 0 && !isPlusMode {
dh.counter++
dirEntry.Ino = input.NodeId dirEntry.Ino = input.NodeId
dirEntry.Name = "." dirEntry.Name = "."
dirEntry.Mode = toSystemMode(os.ModeDir) dirEntry.Mode = toSystemMode(os.ModeDir)
out.AddDirEntry(dirEntry) out.AddDirEntry(dirEntry)
dh.counter++
parentDir, _ := dirPath.DirAndName() parentDir, _ := dirPath.DirAndName()
parentInode := wfs.inodeToPath.GetInode(util.FullPath(parentDir)) parentInode := wfs.inodeToPath.GetInode(util.FullPath(parentDir))
dirEntry.Ino = parentInode dirEntry.Ino = parentInode
@ -160,18 +158,19 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl
} }
processEachEntryFn := func(entry *filer.Entry, isLast bool) bool { processEachEntryFn := func(entry *filer.Entry, isLast bool) bool {
dh.counter++
dirEntry.Name = entry.Name() dirEntry.Name = entry.Name()
inode := wfs.inodeToPath.GetInode(dirPath.Child(dirEntry.Name)) inode := wfs.inodeToPath.GetInode(dirPath.Child(dirEntry.Name))
dirEntry.Ino = inode dirEntry.Ino = inode
dirEntry.Mode = toSystemMode(entry.Mode) dirEntry.Mode = toSystemMode(entry.Mode)
if !isPlusMode { if !isPlusMode {
if !out.AddDirEntry(dirEntry) { if !out.AddDirEntry(dirEntry) {
isEarlyTerminated = true
return false return false
} }
} else { } else {
entryOut := out.AddDirLookupEntry(dirEntry) entryOut := out.AddDirLookupEntry(dirEntry)
if entryOut == nil { if entryOut == nil {
isEarlyTerminated = true
return false return false
} }
wfs.outputFilerEntry(entryOut, inode, entry) wfs.outputFilerEntry(entryOut, inode, entry)
@ -191,7 +190,7 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl
glog.Errorf("list meta cache: %v", listErr) glog.Errorf("list meta cache: %v", listErr)
return fuse.EIO return fuse.EIO
} }
if dh.counter < input.Length { if !isEarlyTerminated {
dh.isFinished = true dh.isFinished = true
} }