diff mbox series

[2/4] xfs/271: fix test failure on non-reflink filesystems

Message ID 161472736521.3478298.1405183245326186350.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series fstests: various fixes | expand

Commit Message

Darrick J. Wong March 2, 2021, 11:22 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

This test creates an empty filesystem with rmap btrees enabled, and then
checks that GETFSMAP corresponds (roughly) with what we expect mkfs to
have written to the filesystem.

Unfortunately, the test's calculation for the number of "per-AG
metadata" extents is not quite correct.  For a filesystem with a
refcount btree, the rmapbt and agfl blocks will be reported separately,
but for non-reflink filesystems, GETFSMAP merges the records.

Since this test counts the number of records, fix the calculation.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/271 |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

Comments

Chandan Babu R March 4, 2021, 3:42 p.m. UTC | #1
On 03 Mar 2021 at 04:52, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> This test creates an empty filesystem with rmap btrees enabled, and then
> checks that GETFSMAP corresponds (roughly) with what we expect mkfs to
> have written to the filesystem.
>
> Unfortunately, the test's calculation for the number of "per-AG
> metadata" extents is not quite correct.  For a filesystem with a
> refcount btree, the rmapbt and agfl blocks will be reported separately,
> but for non-reflink filesystems, GETFSMAP merges the records.
>
> Since this test counts the number of records, fix the calculation.
>

Looks good to me.

Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>


> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  tests/xfs/271 |   12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
>
>
> diff --git a/tests/xfs/271 b/tests/xfs/271
> index 48a3eb8f..35c23b84 100755
> --- a/tests/xfs/271
> +++ b/tests/xfs/271
> @@ -38,6 +38,16 @@ _scratch_mount
>  
>  agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
>  
> +# mkfs lays out btree root blocks in the order bnobt, cntbt, inobt, finobt,
> +# rmapbt, refcountbt, and then allocates AGFL blocks.  Since GETFSMAP has the
> +# same owner (per-AG metadata) for rmap btree blocks and blocks on the AGFL and
> +# the reverse mapping index merges records, the number of per-AG extents
> +# reported will vary depending on whether the refcount btree is enabled.
> +$XFS_INFO_PROG $SCRATCH_MNT | grep -q reflink=1
> +has_reflink=$(( 1 - $? ))
> +perag_metadata_exts=2
> +test $has_reflink -gt 0 && perag_metadata_exts=$((perag_metadata_exts + 1))
> +
>  echo "Get fsmap" | tee -a $seqres.full
>  $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT > $TEST_DIR/fsmap
>  cat $TEST_DIR/fsmap >> $seqres.full
> @@ -48,7 +58,7 @@ _within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount 0 -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
> -_within_tolerance "freesp extent count" $(wc -l < $TEST_DIR/testout) $((agcount * 3)) 0 999999 -v
> +_within_tolerance "freesp extent count" $(wc -l < $TEST_DIR/testout) $((agcount * perag_metadata_exts)) 0 999999 -v
>  
>  echo "Check inode btrees" | tee -a $seqres.full
>  grep 'inode btree[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout
Christoph Hellwig March 5, 2021, 8:31 a.m. UTC | #2
On Tue, Mar 02, 2021 at 03:22:45PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> This test creates an empty filesystem with rmap btrees enabled, and then
> checks that GETFSMAP corresponds (roughly) with what we expect mkfs to
> have written to the filesystem.
> 
> Unfortunately, the test's calculation for the number of "per-AG
> metadata" extents is not quite correct.  For a filesystem with a
> refcount btree, the rmapbt and agfl blocks will be reported separately,
> but for non-reflink filesystems, GETFSMAP merges the records.
> 
> Since this test counts the number of records, fix the calculation.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/tests/xfs/271 b/tests/xfs/271
index 48a3eb8f..35c23b84 100755
--- a/tests/xfs/271
+++ b/tests/xfs/271
@@ -38,6 +38,16 @@  _scratch_mount
 
 agcount=$(_xfs_mount_agcount $SCRATCH_MNT)
 
+# mkfs lays out btree root blocks in the order bnobt, cntbt, inobt, finobt,
+# rmapbt, refcountbt, and then allocates AGFL blocks.  Since GETFSMAP has the
+# same owner (per-AG metadata) for rmap btree blocks and blocks on the AGFL and
+# the reverse mapping index merges records, the number of per-AG extents
+# reported will vary depending on whether the refcount btree is enabled.
+$XFS_INFO_PROG $SCRATCH_MNT | grep -q reflink=1
+has_reflink=$(( 1 - $? ))
+perag_metadata_exts=2
+test $has_reflink -gt 0 && perag_metadata_exts=$((perag_metadata_exts + 1))
+
 echo "Get fsmap" | tee -a $seqres.full
 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT > $TEST_DIR/fsmap
 cat $TEST_DIR/fsmap >> $seqres.full
@@ -48,7 +58,7 @@  _within_tolerance "AG header count" $(wc -l < $TEST_DIR/testout) $agcount 0 -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
-_within_tolerance "freesp extent count" $(wc -l < $TEST_DIR/testout) $((agcount * 3)) 0 999999 -v
+_within_tolerance "freesp extent count" $(wc -l < $TEST_DIR/testout) $((agcount * perag_metadata_exts)) 0 999999 -v
 
 echo "Check inode btrees" | tee -a $seqres.full
 grep 'inode btree[[:space:]]*[0-9]*[[:space:]]*([0-9]*\.\.' $TEST_DIR/fsmap | tee -a $seqres.full > $TEST_DIR/testout