fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] btrfs/255: add test for quota disable in parallel with balance
@ 2022-01-18  5:57 Shin'ichiro Kawasaki
  2022-01-18 14:46 ` Filipe Manana
  0 siblings, 1 reply; 3+ messages in thread
From: Shin'ichiro Kawasaki @ 2022-01-18  5:57 UTC (permalink / raw)
  To: fstests
  Cc: linux-btrfs, Naohiro Aota, Johannes Thumshirn, Damien Le Moal,
	Shin'ichiro Kawasaki

Test quota disable during btrfs balance and confirm it does not cause
kernel hang. This is a regression test for the problem reported to
linux-btrfs list [1]. The hang was recreated using the test case and
memory backed null_blk device with 5GB size as the scratch device.

[1] https://lore.kernel.org/linux-btrfs/20220115053012.941761-1-shinichiro.kawasaki@wdc.com/

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
Changes from v1:
* Put more stress by repeating quota enable/disable and btrfs balance
* Reflected other comments on the list

 tests/btrfs/255     | 45 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/255.out |  2 ++
 2 files changed, 47 insertions(+)
 create mode 100755 tests/btrfs/255
 create mode 100644 tests/btrfs/255.out

diff --git a/tests/btrfs/255 b/tests/btrfs/255
new file mode 100755
index 00000000..32f00f42
--- /dev/null
+++ b/tests/btrfs/255
@@ -0,0 +1,45 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Western Digital Corporation or its affiliates.
+#
+# FS QA Test No. btrfs/255
+#
+# Confirm that disabling quota during balance does not hang
+#
+. ./common/preamble
+_begin_fstest auto qgroup balance
+
+# real QA test starts here
+_supported_fs btrfs
+_require_scratch
+
+_scratch_mkfs >> $seqres.full 2>&1
+_scratch_mount
+
+# Fill 40% of the device or 2GB
+fill_percent=40
+max_fillsize=$((2 * 1024 * 1024 * 1024))
+
+devsize=$(($(_get_device_size $SCRATCH_DEV) * 512))
+fillsize=$((devsize * fill_percent / 100))
+((fillsize > max_fillsize)) && fillsize=$max_fillsize
+
+fs=$((4096 * 1024))
+for ((i = 0; i * fs < fillsize; i++)); do
+	dd if=/dev/zero of=$SCRATCH_MNT/file.$i bs=$fs count=1 \
+	   >> $seqres.full 2>&1
+done
+
+# Run btrfs balance and quota enable/disable in parallel
+_btrfs_stress_balance $SCRATCH_MNT >> $seqres.full &
+balance_pid=$!
+echo $balance_pid >> $seqres.full
+for ((i = 0; i < 20; i++)); do
+	$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
+	$BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
+done
+kill $balance_pid &> /dev/null
+
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/255.out b/tests/btrfs/255.out
new file mode 100644
index 00000000..7eefb828
--- /dev/null
+++ b/tests/btrfs/255.out
@@ -0,0 +1,2 @@
+QA output created by 255
+Silence is golden
-- 
2.33.1


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

* Re: [PATCH v2] btrfs/255: add test for quota disable in parallel with balance
  2022-01-18  5:57 [PATCH v2] btrfs/255: add test for quota disable in parallel with balance Shin'ichiro Kawasaki
@ 2022-01-18 14:46 ` Filipe Manana
  2022-01-19  2:19   ` Shinichiro Kawasaki
  0 siblings, 1 reply; 3+ messages in thread
From: Filipe Manana @ 2022-01-18 14:46 UTC (permalink / raw)
  To: Shin'ichiro Kawasaki
  Cc: fstests, linux-btrfs, Naohiro Aota, Johannes Thumshirn,
	Damien Le Moal

On Tue, Jan 18, 2022 at 02:57:21PM +0900, Shin'ichiro Kawasaki wrote:
> Test quota disable during btrfs balance and confirm it does not cause
> kernel hang. This is a regression test for the problem reported to
> linux-btrfs list [1]. The hang was recreated using the test case and
> memory backed null_blk device with 5GB size as the scratch device.
> 
> [1] https://lore.kernel.org/linux-btrfs/20220115053012.941761-1-shinichiro.kawasaki@wdc.com/
> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
> Changes from v1:
> * Put more stress by repeating quota enable/disable and btrfs balance
> * Reflected other comments on the list
> 
>  tests/btrfs/255     | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/255.out |  2 ++
>  2 files changed, 47 insertions(+)
>  create mode 100755 tests/btrfs/255
>  create mode 100644 tests/btrfs/255.out
> 
> diff --git a/tests/btrfs/255 b/tests/btrfs/255
> new file mode 100755
> index 00000000..32f00f42
> --- /dev/null
> +++ b/tests/btrfs/255
> @@ -0,0 +1,45 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022 Western Digital Corporation or its affiliates.
> +#
> +# FS QA Test No. btrfs/255
> +#
> +# Confirm that disabling quota during balance does not hang
> +#
> +. ./common/preamble
> +_begin_fstest auto qgroup balance
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_require_scratch
> +
> +_scratch_mkfs >> $seqres.full 2>&1
> +_scratch_mount
> +
> +# Fill 40% of the device or 2GB
> +fill_percent=40
> +max_fillsize=$((2 * 1024 * 1024 * 1024))
> +
> +devsize=$(($(_get_device_size $SCRATCH_DEV) * 512))
> +fillsize=$((devsize * fill_percent / 100))
> +((fillsize > max_fillsize)) && fillsize=$max_fillsize
> +
> +fs=$((4096 * 1024))
> +for ((i = 0; i * fs < fillsize; i++)); do
> +	dd if=/dev/zero of=$SCRATCH_MNT/file.$i bs=$fs count=1 \
> +	   >> $seqres.full 2>&1
> +done
> +
> +# Run btrfs balance and quota enable/disable in parallel
> +_btrfs_stress_balance $SCRATCH_MNT >> $seqres.full &
> +balance_pid=$!
> +echo $balance_pid >> $seqres.full
> +for ((i = 0; i < 20; i++)); do
> +	$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
> +	$BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
> +done
> +kill $balance_pid &> /dev/null

You need to wait for the balance pid to exit before terminating the test,
otherwise the test will fail often when the fstests framework is trying
to unmount the scratch device (with an -EBUSY returned from umount).

And please do like in other tests that use _btrfs_stress_balance():

	kill $balance_pid
	wait
	# wait for the balance operation to finish
	while ps aux | grep "balance start" | grep -qv grep; do
		sleep 1
	done

Like in btrfs/060 for example.

Other than that, it looks fine, thanks.

> +
> +echo "Silence is golden"
> +status=0
> +exit
> diff --git a/tests/btrfs/255.out b/tests/btrfs/255.out
> new file mode 100644
> index 00000000..7eefb828
> --- /dev/null
> +++ b/tests/btrfs/255.out
> @@ -0,0 +1,2 @@
> +QA output created by 255
> +Silence is golden
> -- 
> 2.33.1
> 

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

* Re: [PATCH v2] btrfs/255: add test for quota disable in parallel with balance
  2022-01-18 14:46 ` Filipe Manana
@ 2022-01-19  2:19   ` Shinichiro Kawasaki
  0 siblings, 0 replies; 3+ messages in thread
From: Shinichiro Kawasaki @ 2022-01-19  2:19 UTC (permalink / raw)
  To: Filipe Manana
  Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
	Naohiro Aota, Johannes Thumshirn, Damien Le Moal

On Jan 18, 2022 / 14:46, Filipe Manana wrote:
> On Tue, Jan 18, 2022 at 02:57:21PM +0900, Shin'ichiro Kawasaki wrote:

(snip)

> > +# Run btrfs balance and quota enable/disable in parallel
> > +_btrfs_stress_balance $SCRATCH_MNT >> $seqres.full &
> > +balance_pid=$!
> > +echo $balance_pid >> $seqres.full
> > +for ((i = 0; i < 20; i++)); do
> > +	$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
> > +	$BTRFS_UTIL_PROG quota disable $SCRATCH_MNT
> > +done
> > +kill $balance_pid &> /dev/null
> 
> You need to wait for the balance pid to exit before terminating the test,
> otherwise the test will fail often when the fstests framework is trying
> to unmount the scratch device (with an -EBUSY returned from umount).
> 
> And please do like in other tests that use _btrfs_stress_balance():
> 
> 	kill $balance_pid
> 	wait
> 	# wait for the balance operation to finish
> 	while ps aux | grep "balance start" | grep -qv grep; do
> 		sleep 1
> 	done
> 
> Like in btrfs/060 for example.
> 
> Other than that, it looks fine, thanks.

Thanks. Will update the patch as you commented and send out v3.

-- 
Best Regards,
Shin'ichiro Kawasaki

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

end of thread, other threads:[~2022-01-19  2:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-18  5:57 [PATCH v2] btrfs/255: add test for quota disable in parallel with balance Shin'ichiro Kawasaki
2022-01-18 14:46 ` Filipe Manana
2022-01-19  2:19   ` Shinichiro Kawasaki

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).