From: "Darrick J. Wong" <djwong@kernel.org>
To: Zizhi Wo <wozizhi@huawei.com>
Cc: linux-xfs@vger.kernel.org, Carlos Maiolino <cem@kernel.org>,
fstests <fstests@vger.kernel.org>
Subject: [PATCH] xfs/273: check thoroughness of the fsmappings
Date: Fri, 8 Nov 2024 09:41:46 -0800 [thread overview]
Message-ID: <20241108174146.GA168062@frogsfrogsfrogs> (raw)
In-Reply-To: <20241108173907.GB168069@frogsfrogsfrogs>
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(+)
diff --git a/tests/xfs/273 b/tests/xfs/273
index d7fb80c4033429..ecfe5e7760a092 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_git_commit kernel XXXXXXXXXXXXXX "xfs: fix off-by-one error in fsmap's end_daddr usage"
+
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);
+ next = $5 + 1;
+ if (next > next_daddr[devno])
+ next_daddr[devno] = next;
+}
+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
next prev parent reply other threads:[~2024-11-08 17:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 17:39 [PATCH] xfs: fix off-by-one error in fsmap's end_daddr usage Darrick J. Wong
2024-11-08 17:41 ` Darrick J. Wong [this message]
2024-11-09 14:45 ` [PATCH] xfs/273: check thoroughness of the fsmappings Zorro Lang
2024-11-09 16:19 ` Darrick J. Wong
2024-11-18 6:59 ` [PATCH] xfs: fix off-by-one error in fsmap's end_daddr usage Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241108174146.GA168062@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=wozizhi@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox