]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs/509: adjust inumbers accounting for metadata directories
authorDarrick J. Wong <djwong@kernel.org>
Tue, 6 Feb 2024 00:06:39 +0000 (16:06 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 1 Nov 2024 20:41:57 +0000 (13:41 -0700)
The INUMBERS ioctl exports data from the inode btree directly -- the
number of inodes it reports is taken from ir_freemask and includes all
the files in the metadata directory tree.  BULKSTAT, on the other hand,
only reports non-metadata files.  When metadir is enabled, this will
(eventually) cause a discrepancy in the inode counts that is large
enough to exceed the tolerances, thereby causing a test failure.

Correct this by counting the files in the metadata directory and
subtracting that from the INUMBERS totals.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
tests/xfs/509

index 53c6bd9c0772a15e92cf7e80b60b43f9576a377e..9b07fecc5d1a104e4946a5316da04c62ef46a1da 100755 (executable)
@@ -91,13 +91,13 @@ inumbers_count()
        bstat_versions | while read v_tag v_flag; do
                echo -n "inumbers all($v_tag): "
                nr=$(inumbers_fs $SCRATCH_MNT $v_flag)
-               _within_tolerance "inumbers" $nr $expect $tolerance -v
+               _within_tolerance "inumbers" $((nr - METADATA_FILES)) $expect $tolerance -v
 
                local agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
                for batchsize in 71 2 1; do
                        echo -n "inumbers $batchsize($v_tag): "
                        nr=$(inumbers_ag $agcount $batchsize $SCRATCH_MNT $v_flag)
-                       _within_tolerance "inumbers" $nr $expect $tolerance -v
+                       _within_tolerance "inumbers" $((nr - METADATA_FILES)) $expect $tolerance -v
                done
        done
 }
@@ -142,9 +142,28 @@ _require_xfs_io_command inumbers
 DIRCOUNT=8
 INOCOUNT=$((2048 / DIRCOUNT))
 
+# Count everything in the metadata directory tree.
+count_metadir_files() {
+       # Each possible path in the metadata directory tree must be listed
+       # here.
+       local metadirs=('/rtgroups')
+       local db_args=('-f')
+
+       for m in "${metadirs[@]}"; do
+               db_args+=('-c' "ls -m $m")
+       done
+
+       local ret=$(_scratch_xfs_db "${db_args[@]}" 2>/dev/null | grep regular | wc -l)
+       test -z "$ret" && ret=0
+       echo $ret
+}
+
 _scratch_mkfs "-d agcount=$DIRCOUNT" >> $seqres.full 2>&1 || _fail "mkfs failed"
 _scratch_mount
 
+METADATA_FILES=$(count_metadir_files)
+echo "found $METADATA_FILES metadata files" >> $seqres.full
+
 # Figure out if we have v5 bulkstat/inumbers ioctls.
 has_v5=
 bs_root_out="$($XFS_IO_PROG -c 'bulkstat_single root' $SCRATCH_MNT 2>>$seqres.full)"