]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs/271,xfs/556: fix tests to deal with rtgroups output in bmap/fsmap commands
authorDarrick J. Wong <djwong@kernel.org>
Tue, 6 Feb 2024 00:06:43 +0000 (16:06 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 1 Nov 2024 20:41:58 +0000 (13:41 -0700)
Fix these tests to deal with the xfs_io bmap and fsmap commands printing
out realtime group numbers if the feature is enabled.

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

index 81b894f4e8a9a98a2b83f8950d6a5e63e70407f5..9cd186ad64d0bef7cddb890aad575851c9f370a2 100644 (file)
@@ -419,6 +419,13 @@ _xfs_has_feature()
                feat="rtextents"
                feat_regex="[1-9][0-9]*"
                ;;
+       "rtgroups")
+               # any fs with rtgroups enabled will have a nonzero rt group
+               # size, even if there is no rt device (and hence zero actual
+               # groups)
+               feat="rgsize"
+               feat_regex="[1-9][0-9]*"
+               ;;
        esac
 
        local answer="$($XFS_INFO_PROG "$fs" 2>&1 | grep -E -w -c "$feat=$feat_regex")"
index 420f4e7479220a86164f7f4ea56567ba8fd1b4bf..8a71746d6eaede9a1d5ee225fe536538438b8498 100755 (executable)
@@ -29,6 +29,8 @@ _scratch_mkfs > "$seqres.full" 2>&1
 _scratch_mount
 
 agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
+agcount_wiggle=0
+_xfs_has_feature $SCRATCH_MNT rtgroups && agcount_wiggle=1
 
 # mkfs lays out btree root blocks in the order bnobt, cntbt, inobt, finobt,
 # rmapbt, refcountbt, and then allocates AGFL blocks.  Since GETFSMAP has the
@@ -46,7 +48,7 @@ cat $TEST_DIR/fsmap >> $seqres.full
 
 echo "Check AG header" | tee -a $seqres.full
 grep 'static fs metadata[[:space:]]*[0-9]*[[:space:]]*(0\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
-_within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount 0 -v
+_within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount $agcount_wiggle -v
 
 echo "Check freesp/rmap btrees" | tee -a $seqres.full
 grep 'per-AG metadata[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
index 79e03caf40a0a585787ca3e3ec141066ab72b925..83d5022e700c8bec58f86aed6194d345090a1ef0 100755 (executable)
@@ -45,16 +45,20 @@ victim=$SCRATCH_MNT/a
 file_blksz=$(_get_file_block_size $SCRATCH_MNT)
 $XFS_IO_PROG -f -c "pwrite -S 0x58 0 $((4 * file_blksz))" -c "fsync" $victim >> $seqres.full
 unset errordev
-_xfs_is_realtime_file $victim && errordev="RT"
+
+awk_len_prog='{print $6}'
+if _xfs_is_realtime_file $victim; then
+       if ! _xfs_has_feature $SCRATCH_MNT rtgroups; then
+               awk_len_prog='{print $4}'
+       fi
+       errordev="RT"
+fi
 bmap_str="$($XFS_IO_PROG -c "bmap -elpv" $victim | grep "^[[:space:]]*0:")"
 echo "$errordev:$bmap_str" >> $seqres.full
 
 phys="$(echo "$bmap_str" | $AWK_PROG '{print $3}')"
-if [ "$errordev" = "RT" ]; then
-       len="$(echo "$bmap_str" | $AWK_PROG '{print $4}')"
-else
-       len="$(echo "$bmap_str" | $AWK_PROG '{print $6}')"
-fi
+len="$(echo "$bmap_str" | $AWK_PROG "$awk_len_prog")"
+
 fs_blksz=$(_get_block_size $SCRATCH_MNT)
 echo "file_blksz:$file_blksz:fs_blksz:$fs_blksz" >> $seqres.full
 kernel_sectors_per_fs_block=$((fs_blksz / 512))