diff mbox series

[1/3] xfs/273: check thoroughness of the mappings

Message ID 173146178829.156441.9898313568693484387.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [1/3] xfs/273: check thoroughness of the mappings | expand

Commit Message

Darrick J. Wong Nov. 13, 2024, 1:36 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Enhance this test to make sure that there are no gaps in the fsmap
records, and (especially) that they we report all the way to the end of
the device.

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

Comments

Christoph Hellwig Nov. 13, 2024, 8:46 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Zorro Lang Nov. 15, 2024, 10:13 a.m. UTC | #2
On Tue, Nov 12, 2024 at 05:36:58PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Enhance this test to make sure that there are no gaps in the fsmap
> records, and (especially) that they we report all the way to the end of
> the device.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---

This version is good to me now,

Reviewed-by: Zorro Lang <zlang@redhat.com>

>  tests/xfs/273 |   47 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 47 insertions(+)
> 
> 
> diff --git a/tests/xfs/273 b/tests/xfs/273
> index d7fb80c4033429..9f11540a77603d 100755
> --- a/tests/xfs/273
> +++ b/tests/xfs/273
> @@ -24,6 +24,8 @@ _require_scratch
>  _require_populate_commands
>  _require_xfs_io_command "fsmap"
>  
> +_fixed_by_kernel_commit XXXXXXXXXXXXXX "xfs: fix off-by-one error in fsmap"
> +
>  rm -f "$seqres.full"
>  
>  echo "Format and mount"
> @@ -37,6 +39,51 @@ cat $TEST_DIR/a $TEST_DIR/b >> $seqres.full
>  
>  diff -uw $TEST_DIR/a $TEST_DIR/b
>  
> +# Do we have mappings for every sector on the device?
> +ddev_fsblocks=$(_xfs_statfs_field "$SCRATCH_MNT" geom.datablocks)
> +rtdev_fsblocks=$(_xfs_statfs_field "$SCRATCH_MNT" geom.rtblocks)
> +fsblock_bytes=$(_xfs_statfs_field "$SCRATCH_MNT" geom.bsize)
> +
> +ddev_daddrs=$((ddev_fsblocks * fsblock_bytes / 512))
> +rtdev_daddrs=$((rtdev_fsblocks * fsblock_bytes / 512))
> +
> +ddev_devno=$(stat -c '%t:%T' $SCRATCH_DEV)
> +if [ "$USE_EXTERNAL" = "yes" ] && [ -n "$SCRATCH_RTDEV" ]; then
> +	rtdev_devno=$(stat -c '%t:%T' $SCRATCH_RTDEV)
> +fi
> +
> +$XFS_IO_PROG -c 'fsmap -m -n 65536' $SCRATCH_MNT | awk -F ',' \
> +	-v data_devno=$ddev_devno \
> +	-v rt_devno=$rtdev_devno \
> +	-v data_daddrs=$ddev_daddrs \
> +	-v rt_daddrs=$rtdev_daddrs \
> +'BEGIN {
> +	next_daddr[data_devno] = 0;
> +	next_daddr[rt_devno] = 0;
> +}
> +{
> +	if ($1 == "EXT")
> +		next
> +	devno = sprintf("%x:%x", $2, $3);
> +	if (devno != data_devno && devno != rt_devno)
> +		next
> +
> +	if (next_daddr[devno] < $4)
> +		printf("%sh: expected daddr %d, saw \"%s\"\n", devno,
> +				next_daddr[devno], $0);
> +		n = $5 + 1;
> +		if (n > next_daddr[devno])
> +		       next_daddr[devno] = n;
> +}
> +END {
> +	if (data_daddrs != next_daddr[data_devno])
> +		printf("%sh: fsmap stops at %d, expected %d\n",
> +				data_devno, next_daddr[data_devno], data_daddrs);
> +	if (rt_devno != "" && rt_daddrs != next_daddr[rt_devno])
> +		printf("%sh: fsmap stops at %d, expected %d\n",
> +				rt_devno, next_daddr[rt_devno], rt_daddrs);
> +}'
> +
>  # success, all done
>  status=0
>  exit
>
diff mbox series

Patch

diff --git a/tests/xfs/273 b/tests/xfs/273
index d7fb80c4033429..9f11540a77603d 100755
--- a/tests/xfs/273
+++ b/tests/xfs/273
@@ -24,6 +24,8 @@  _require_scratch
 _require_populate_commands
 _require_xfs_io_command "fsmap"
 
+_fixed_by_kernel_commit XXXXXXXXXXXXXX "xfs: fix off-by-one error in fsmap"
+
 rm -f "$seqres.full"
 
 echo "Format and mount"
@@ -37,6 +39,51 @@  cat $TEST_DIR/a $TEST_DIR/b >> $seqres.full
 
 diff -uw $TEST_DIR/a $TEST_DIR/b
 
+# Do we have mappings for every sector on the device?
+ddev_fsblocks=$(_xfs_statfs_field "$SCRATCH_MNT" geom.datablocks)
+rtdev_fsblocks=$(_xfs_statfs_field "$SCRATCH_MNT" geom.rtblocks)
+fsblock_bytes=$(_xfs_statfs_field "$SCRATCH_MNT" geom.bsize)
+
+ddev_daddrs=$((ddev_fsblocks * fsblock_bytes / 512))
+rtdev_daddrs=$((rtdev_fsblocks * fsblock_bytes / 512))
+
+ddev_devno=$(stat -c '%t:%T' $SCRATCH_DEV)
+if [ "$USE_EXTERNAL" = "yes" ] && [ -n "$SCRATCH_RTDEV" ]; then
+	rtdev_devno=$(stat -c '%t:%T' $SCRATCH_RTDEV)
+fi
+
+$XFS_IO_PROG -c 'fsmap -m -n 65536' $SCRATCH_MNT | awk -F ',' \
+	-v data_devno=$ddev_devno \
+	-v rt_devno=$rtdev_devno \
+	-v data_daddrs=$ddev_daddrs \
+	-v rt_daddrs=$rtdev_daddrs \
+'BEGIN {
+	next_daddr[data_devno] = 0;
+	next_daddr[rt_devno] = 0;
+}
+{
+	if ($1 == "EXT")
+		next
+	devno = sprintf("%x:%x", $2, $3);
+	if (devno != data_devno && devno != rt_devno)
+		next
+
+	if (next_daddr[devno] < $4)
+		printf("%sh: expected daddr %d, saw \"%s\"\n", devno,
+				next_daddr[devno], $0);
+		n = $5 + 1;
+		if (n > next_daddr[devno])
+		       next_daddr[devno] = n;
+}
+END {
+	if (data_daddrs != next_daddr[data_devno])
+		printf("%sh: fsmap stops at %d, expected %d\n",
+				data_devno, next_daddr[data_devno], data_daddrs);
+	if (rt_devno != "" && rt_daddrs != next_daddr[rt_devno])
+		printf("%sh: fsmap stops at %d, expected %d\n",
+				rt_devno, next_daddr[rt_devno], rt_daddrs);
+}'
+
 # success, all done
 status=0
 exit