aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>2022-01-19 11:25:31 +0900
committerEryu Guan <guaneryu@gmail.com>2022-01-23 22:25:12 +0800
commitcf686862d840bd8e2906db5abc38d78be96d0249 (patch)
tree346bde28cbedae3ebbabedcf19fbf9f7316c71f0
parentbe9fdf6287a0b9437901ea206ed5c62dad7abcc2 (diff)
downloadxfstests-dev-cf686862d840bd8e2906db5abc38d78be96d0249.tar.gz
btrfs: add test for quota disable in parallel with balance
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, and fixed by kernel patch titled btrfs: fix deadlock between quota disable and qgroup rescan worker [1] https://lore.kernel.org/linux-btrfs/20220115053012.941761-1-shinichiro.kawasaki@wdc.com/ Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
-rwxr-xr-xtests/btrfs/25553
-rw-r--r--tests/btrfs/255.out2
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/btrfs/255 b/tests/btrfs/255
new file mode 100755
index 0000000000..7e70944afa
--- /dev/null
+++ b/tests/btrfs/255
@@ -0,0 +1,53 @@
+#! /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.
+#
+# The deadlock is fixed by kernel patch titled:
+# btrfs: fix deadlock between quota disable and qgroup rescan worker
+#
+. ./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
+wait
+# wait for the balance operation to finish
+while ps aux | grep "balance start" | grep -qv grep; do
+ sleep 1
+done
+
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/255.out b/tests/btrfs/255.out
new file mode 100644
index 0000000000..7eefb828f6
--- /dev/null
+++ b/tests/btrfs/255.out
@@ -0,0 +1,2 @@
+QA output created by 255
+Silence is golden