linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] xfs: test that we can handle spurious zone wp advancements
@ 2025-05-07 10:30 Hans Holmberg
  2025-05-07 13:09 ` hch
  2025-05-07 17:01 ` Darrick J. Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Hans Holmberg @ 2025-05-07 10:30 UTC (permalink / raw)
  To: Zorro Lang
  Cc: djwong@kernel.org, fstests@vger.kernel.org,
	linux-xfs@vger.kernel.org, Hans Holmberg, Hans Holmberg, hch

From: Hans Holmberg <Hans.Holmberg@wdc.com>

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>
---
Changes since v1:
 Added _require_realtime and fixed a white space error based
 on Darrick's review comments.

Changes since v2:
 Make sure we don't fail when the rt section is internal
 Dropped inclusion of common filters and fixed dd parameter ordering

 tests/xfs/4214     | 71 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/4214.out |  2 ++
 2 files changed, 73 insertions(+)
 create mode 100755 tests/xfs/4214
 create mode 100644 tests/xfs/4214.out

diff --git a/tests/xfs/4214 b/tests/xfs/4214
new file mode 100755
index 000000000000..f5262a40b229
--- /dev/null
+++ b/tests/xfs/4214
@@ -0,0 +1,71 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2025 Western Digital Corporation.  All Rights Reserved.
+#
+# FS QA Test 4214
+#
+# 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/4214.out b/tests/xfs/4214.out
new file mode 100644
index 000000000000..a746546bc8f6
--- /dev/null
+++ b/tests/xfs/4214.out
@@ -0,0 +1,2 @@
+QA output created by 4214
+Number of open zones: 0
-- 
2.34.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] xfs: test that we can handle spurious zone wp advancements
  2025-05-07 10:30 [PATCH v3] xfs: test that we can handle spurious zone wp advancements Hans Holmberg
@ 2025-05-07 13:09 ` hch
  2025-05-07 17:01 ` Darrick J. Wong
  1 sibling, 0 replies; 3+ messages in thread
From: hch @ 2025-05-07 13:09 UTC (permalink / raw)
  To: Hans Holmberg
  Cc: Zorro Lang, djwong@kernel.org, fstests@vger.kernel.org,
	linux-xfs@vger.kernel.org, hch

Looks good:

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] xfs: test that we can handle spurious zone wp advancements
  2025-05-07 10:30 [PATCH v3] xfs: test that we can handle spurious zone wp advancements Hans Holmberg
  2025-05-07 13:09 ` hch
@ 2025-05-07 17:01 ` Darrick J. Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2025-05-07 17:01 UTC (permalink / raw)
  To: Hans Holmberg
  Cc: Zorro Lang, fstests@vger.kernel.org, linux-xfs@vger.kernel.org,
	hch

On Wed, May 07, 2025 at 10:30:14AM +0000, Hans Holmberg wrote:
> From: Hans Holmberg <Hans.Holmberg@wdc.com>
> 
> 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>

Looks good now,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
> Changes since v1:
>  Added _require_realtime and fixed a white space error based
>  on Darrick's review comments.
> 
> Changes since v2:
>  Make sure we don't fail when the rt section is internal
>  Dropped inclusion of common filters and fixed dd parameter ordering
> 
>  tests/xfs/4214     | 71 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/xfs/4214.out |  2 ++
>  2 files changed, 73 insertions(+)
>  create mode 100755 tests/xfs/4214
>  create mode 100644 tests/xfs/4214.out
> 
> diff --git a/tests/xfs/4214 b/tests/xfs/4214
> new file mode 100755
> index 000000000000..f5262a40b229
> --- /dev/null
> +++ b/tests/xfs/4214
> @@ -0,0 +1,71 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2025 Western Digital Corporation.  All Rights Reserved.
> +#
> +# FS QA Test 4214
> +#
> +# 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/4214.out b/tests/xfs/4214.out
> new file mode 100644
> index 000000000000..a746546bc8f6
> --- /dev/null
> +++ b/tests/xfs/4214.out
> @@ -0,0 +1,2 @@
> +QA output created by 4214
> +Number of open zones: 0
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-05-07 17:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 10:30 [PATCH v3] xfs: test that we can handle spurious zone wp advancements Hans Holmberg
2025-05-07 13:09 ` hch
2025-05-07 17:01 ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).