xfs: speed up xfs_iwalk_adjust_start a little bit
authorDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:30:44 +0000 (12:30 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:30:44 +0000 (12:30 -0800)
Replace the open-coded loop that recomputes freecount with a single call
to a bit weight function.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_iwalk.c

index 6d2eb63648675e019b85b9c03d38f19bc4c8d054..c1e9c7bcb6a92602fa07db03bfab7430d647125c 100644 (file)
@@ -22,6 +22,7 @@
 #include "xfs_trans.h"
 #include "xfs_pwork.h"
 #include "xfs_ag.h"
+#include "xfs_bit.h"
 
 /*
  * Walking Inodes in the Filesystem
@@ -131,21 +132,11 @@ xfs_iwalk_adjust_start(
        struct xfs_inobt_rec_incore     *irec)  /* btree record */
 {
        int                             idx;    /* index into inode chunk */
-       int                             i;
 
        idx = agino - irec->ir_startino;
 
-       /*
-        * We got a right chunk with some left inodes allocated at it.  Grab
-        * the chunk record.  Mark all the uninteresting inodes free because
-        * they're before our start point.
-        */
-       for (i = 0; i < idx; i++) {
-               if (XFS_INOBT_MASK(i) & ~irec->ir_free)
-                       irec->ir_freecount++;
-       }
-
        irec->ir_free |= xfs_inobt_maskn(0, idx);
+       irec->ir_freecount = hweight64(irec->ir_free);
 }
 
 /* Allocate memory for a walk. */