FSTests Archive on lore.kernel.org
 help / color / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Cc: Filipe Manana <fdmanana@suse.com>
Subject: [PATCH v5 2/2] btrfs: Add a test for dead looping balance after balance cancel
Date: Thu, 21 May 2020 08:52:15 +0800
Message-ID: <20200521005215.13652-1-wqu@suse.com> (raw)

Test if canceling a running balance can cause later balance to dead

The fix is titled "btrfs: relocation: Clear the DEAD_RELOC_TREE bit for
 orphan roots to prevent runaway balance".

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
- Remove lsof debug output
- Remove ps debug output
- Use $XFS_IO_PROG directly to avoid wrapped dd command
  This allows us to kill the writer and wait it correctly, other than
  killing the bash process running the wrapper function.
- Fix typos
- Use _run_btrfs_balance_start() wrapper
- Add the xfs_io kill in cleanup()
 tests/btrfs/213     | 66 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/213.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 69 insertions(+)
 create mode 100755 tests/btrfs/213
 create mode 100644 tests/btrfs/213.out

diff --git a/tests/btrfs/213 b/tests/btrfs/213
new file mode 100755
index 00000000..a125eb62
--- /dev/null
+++ b/tests/btrfs/213
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
+# FS QA Test 213
+# Test if canceling a running balance can lead to dead looping balance
+seq=`basename $0`
+echo "QA output created by $seq"
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+	cd /
+	kill $write_pid &> /dev/null
+	rm -f $tmp.*
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+# remove previous $seqres.full before test
+rm -f $seqres.full
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_xfs_io_command pwrite -D
+_scratch_mkfs >> $seqres.full
+# Create enough IO so that we need around $runtime seconds to relocate it.
+# Here we don't want any wrapper, as we want full control of the process.
+$XFS_IO_PROG -f -c "pwrite -D -b 1M 0 1024T" "$SCRATCH_MNT/file" &> /dev/null &
+sleep $runtime
+kill $write_pid
+wait $write_pid
+# Now balance should take at least $runtime seconds, we can cancel it at
+# $runtime/2 to ensure a success cancel.
+_run_btrfs_balance_start -d --bg "$SCRATCH_MNT"
+sleep $(($runtime / 2))
+$BTRFS_UTIL_PROG balance cancel "$SCRATCH_MNT"
+# Now check if we can finish relocating metadata, which should finish very
+# quickly.
+$BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" >> $seqres.full
+echo "Silence is golden"
+# success, all done
diff --git a/tests/btrfs/213.out b/tests/btrfs/213.out
new file mode 100644
index 00000000..bd8f2430
--- /dev/null
+++ b/tests/btrfs/213.out
@@ -0,0 +1,2 @@
+QA output created by 213
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index 8d65bddd..59e8ecce 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -215,3 +215,4 @@
 210 auto quick qgroup snapshot
 211 auto quick log prealloc
 212 auto balance dangerous
+213 auto quick balance dangerous

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200521005215.13652-1-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=fdmanana@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git