turn-off Nlink readdir() optimization for NFS/CIFS (#19420)

fixes #19418
fixes #19416
This commit is contained in:
Harshavardhana
2024-04-05 08:17:08 -07:00
committed by GitHub
parent 96d226c0b1
commit a207bd6790
5 changed files with 28 additions and 21 deletions

View File

@@ -59,10 +59,22 @@ type WalkDirOptions struct {
DiskID string
}
// supported FS for Nlink optimization in readdir.
const (
xfs = "XFS"
ext4 = "EXT4"
)
// WalkDir will traverse a directory and return all entries found.
// On success a sorted meta cache stream will be returned.
// Metadata has data stripped, if any.
func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writer) (err error) {
legacyFS := !(s.fsType == xfs || s.fsType == ext4)
s.RLock()
legacy := s.formatLegacy
s.RUnlock()
// Verify if volume is valid and it exists.
volumeDir, err := s.getVolDir(opts.Bucket)
if err != nil {
@@ -76,10 +88,6 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ
}
}
s.RLock()
legacy := s.formatLegacy
s.RUnlock()
// Use a small block size to start sending quickly
w := newMetacacheWriter(wr, 16<<10)
w.reuseBlocks = true // We are not sharing results, so reuse buffers.
@@ -353,7 +361,7 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ
// NOT an object, append to stack (with slash)
// If dirObject, but no metadata (which is unexpected) we skip it.
if !isDirObj {
if !isDirEmpty(pathJoinBuf(sb, volumeDir, meta.name)) {
if !isDirEmpty(pathJoinBuf(sb, volumeDir, meta.name), legacyFS) {
dirStack = append(dirStack, meta.name+slashSeparator)
}
}