]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfs: test that we can handle spurious zone wp advancements
authorHans Holmberg <Hans.Holmberg@wdc.com>
Thu, 8 May 2025 05:34:45 +0000 (07:34 +0200)
committerZorro Lang <zlang@kernel.org>
Thu, 8 May 2025 19:18:13 +0000 (03:18 +0800)
Test that we can gracefully handle spurious zone write pointer
advancements while unmounted.

Any space covered by the wp unexpectedly moving forward should just
be treated as unused space, so check that we can still mount the file
system and that the zone will be reset when all used blocks have been
freed.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/xfs/647 [new file with mode: 0755]
tests/xfs/647.out [new file with mode: 0644]

diff --git a/tests/xfs/647 b/tests/xfs/647
new file mode 100755 (executable)
index 0000000..76959b2
--- /dev/null
@@ -0,0 +1,71 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Western Digital Corporation.  All Rights Reserved.
+#
+# FS QA Test No. 647
+#
+# Test that we can gracefully handle spurious zone write pointer
+# advancements while unmounted.
+#
+
+. ./common/preamble
+_begin_fstest auto quick zone
+
+# Import common functions.
+. ./common/zoned
+
+_require_scratch
+_require_realtime
+
+#
+# Figure out if the rt section is internal or not
+#
+if [ -z "$SCRATCH_RTDEV" ]; then
+       zdev=$SCRATCH_DEV
+else
+       zdev=$SCRATCH_RTDEV
+fi
+
+_require_zoned_device $zdev
+_require_command "$BLKZONE_PROG" blkzone
+
+_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+blksz=$(_get_file_block_size $SCRATCH_MNT)
+
+test_file=$SCRATCH_MNT/test.dat
+dd if=/dev/zero of=$test_file bs=1M count=16 oflag=direct >> $seqres.full 2>&1 \
+       || _fail "file creation failed"
+
+_scratch_unmount
+
+#
+# Figure out which zone was opened to store the test file and where
+# the write pointer is in that zone
+#
+open_zone=$($BLKZONE_PROG report $zdev | \
+       $AWK_PROG '/oi/ { print $2 }' | sed 's/,//')
+open_zone_wp=$($BLKZONE_PROG report $zdev | \
+       grep "start: $open_zone" | $AWK_PROG '{ print $8 }')
+wp=$(( $open_zone + $open_zone_wp ))
+
+# Advance the write pointer manually by one block
+dd if=/dev/zero of=$zdev bs=$blksz count=1 seek=$(($wp * 512 / $blksz)) \
+       oflag=direct >> $seqres.full 2>&1 || _fail "wp advancement failed"
+
+_scratch_mount
+_scratch_unmount
+
+# Finish the open zone
+$BLKZONE_PROG finish -c 1 -o $open_zone $zdev
+
+_scratch_mount
+rm $test_file
+_scratch_unmount
+
+# The previously open zone, now finished and unused, should have been reset
+nr_open=$($BLKZONE_PROG report $zdev | grep -wc "oi")
+echo "Number of open zones: $nr_open"
+
+status=0
+exit
diff --git a/tests/xfs/647.out b/tests/xfs/647.out
new file mode 100644 (file)
index 0000000..d635ef3
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 647
+Number of open zones: 0