]> Savannah Git Hosting - gnulib.git/commitdiff
fts: enable leaf optimization for XFS
authorPádraig Brady <P@draigBrady.com>
Sun, 20 Dec 2015 23:46:05 +0000 (23:46 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 20 Dec 2015 23:55:38 +0000 (23:55 +0000)
XFS provides usable dirent.d_type only for DT_DIR,
but the noleaf optimization still applies, as confirmed with:

  test $(($(find . -maxdepth 1 -type d | wc -l) + 1)) = $(stat -c %h .)

Enabling this gives significant traversal speedup.
Testing with find(1) gives:

  $ time find/find-before /usr/share >/dev/null
  real    0m0.410s
  user    0m0.145s
  sys     0m0.266s

  $ time find/find-after /usr/share >/dev/null
  real    0m0.278s
  user    0m0.147s
  sys     0m0.131s

* lib/fts.c (leaf_optimization_applies): Add XFS to the white list.

ChangeLog
lib/fts.c

index 3945c58d20f38113035b938ef2eea37ff0329cb1..464dc7484b081d9862bd451d14d06a71e1e4a0a4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-12-20  Pádraig Brady  <P@draigBrady.com>
+
+       fts: enable leaf optimization for XFS
+       XFS provides usable dirent.d_type only for DT_DIR,
+       but the noleaf optimization still applies.
+       * lib/fts.c (leaf_optimization_applies): Add XFS to the white list.
+
 2015-12-17  Paul Eggert  <eggert@cs.ucla.edu>
 
        intprops: comment fix
index ea736751636365c971207049a9e63d2f63970c73..99679c7a96181be2c022f06cbed2aac638cb368a 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -665,6 +665,7 @@ fts_close (FTS *sp)
 # define S_MAGIC_TMPFS 0x1021994
 # define S_MAGIC_NFS 0x6969
 # define S_MAGIC_REISERFS 0x52654973
+# define S_MAGIC_XFS 0x58465342
 # define S_MAGIC_PROC 0x9FA0
 
 /* Return false if it is easy to determine the file system type of
@@ -720,6 +721,7 @@ leaf_optimization_applies (int dir_fd)
       /* List here the file system types that lack usable dirent.d_type
          info, yet for which the optimization does apply.  */
     case S_MAGIC_REISERFS:
+    case S_MAGIC_XFS:
       return true;
 
     case S_MAGIC_PROC: