Reported by Tim Day <[email protected]> in
<https://bugs.gnu.org/80106>.

* lib/fts.c (S_MAGIC_LUSTRE): New macro.
(dirent_inode_sort_may_be_useful): Return false on Lustre file systems
so inode sorting is not performed.
---
 ChangeLog | 9 +++++++++
 lib/fts.c | 6 ++++++
 2 files changed, 15 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 53f19b337a..5ffd08aba2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-01-01  Collin Funk  <[email protected]>
+
+       fts: Improve performance on the Lustre file system.
+       Reported by Tim Day <[email protected]> in
+       <https://bugs.gnu.org/80106>.
+       * lib/fts.c (S_MAGIC_LUSTRE): New macro.
+       (dirent_inode_sort_may_be_useful): Return false on Lustre file systems
+       so inode sorting is not performed.
+
 2026-01-01  Bruno Haible  <[email protected]>
 
        doc: Update regarding stable branches.
diff --git a/lib/fts.c b/lib/fts.c
index a38804ce78..4be7c77fe8 100644
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -652,6 +652,7 @@ enum leaf_optimization
 /* Linux-specific constants from coreutils' src/fs.h */
 # define S_MAGIC_AFS 0x5346414F
 # define S_MAGIC_CIFS 0xFF534D42
+# define S_MAGIC_LUSTRE 0x0BD00BD0
 # define S_MAGIC_NFS 0x6969
 # define S_MAGIC_PROC 0x9FA0
 # define S_MAGIC_TMPFS 0x1021994
@@ -758,6 +759,11 @@ dirent_inode_sort_may_be_useful (FTSENT const *p, int 
dir_fd)
 
   switch (filesystem_type (p, dir_fd))
     {
+    case S_MAGIC_LUSTRE:
+      /* On Lustre, sorting directory entries interferes with its ability to
+         prefetch file metadata (via statahead).  This would make a make a
+         command like 'du' around 9 times slower.  See
+         <https://bugs.gnu.org/80106>.  */
     case S_MAGIC_CIFS:
     case S_MAGIC_NFS:
     case S_MAGIC_TMPFS:
-- 
2.52.0


Reply via email to