From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 0/4] btrfs: Make balance cancelling response faster
Date: Tue, 11 Feb 2020 13:37:25 +0800 [thread overview]
Message-ID: <20200211053729.20807-1-wqu@suse.com> (raw)
[PROBLEM]
There are quite some users reporting that 'btrfs balance cancel' slow to
cancel current running balance, or even doesn't work for certain dead
balance loop.
With the following script showing how long it takes to fully stop a
balance:
#!/bin/bash
dev=/dev/test/test
mnt=/mnt/btrfs
umount $mnt &> /dev/null
umount $dev &> /dev/null
mkfs.btrfs -f $dev
mount $dev -o nospace_cache $mnt
dd if=/dev/zero bs=1M of=$mnt/large &
dd_pid=$!
sleep 3
kill -KILL $dd_pid
sync
btrfs balance start --bg --full $mnt &
sleep 1
echo "cancel request" >> /dev/kmsg
time btrfs balance cancel $mnt
umount $mnt
It takes around 7~10s to cancel the running balance in my test
environment.
[CAUSE]
Btrfs uses btrfs_fs_info::balance_cancel_req to record how many cancel
request are queued.
However that cancelling request is only checked after relocating a block
group.
That behavior is far from optimal to provide a faster cancelling.
[FIX]
This patchset will add more cancelling check points, to make cancelling
faster.
And also, introduce a new error injection points to cover these newly
introduced and future check points.
For the canceled balance during relocate_block_group(), we are re-using
the existing error handling path.
It will mark all existing reloc_roots as orphan in prepare_to_merge(),
then queue all of them for cleanup in merge_reloc_roots().
Thus it shouldn't cause any problem.
Changelog:
v2:
- Rebased to v5.6-rc1
There is a small conflicts caused by extra finished stage output.
Other than that, everything is pretty straightforward
- Add explanation for the error handling path in cover letter.
Qu Wenruo (4):
btrfs: relocation: Introduce error injection points for cancelling
balance
btrfs: relocation: Check cancel request after each data page read
btrfs: relocation: Check cancel request after each extent found
btrfs: relocation: Work around dead relocation stage loop
fs/btrfs/ctree.h | 1 +
fs/btrfs/relocation.c | 24 ++++++++++++++++++++++++
fs/btrfs/volumes.c | 2 +-
3 files changed, 26 insertions(+), 1 deletion(-)
--
2.25.0
next reply other threads:[~2020-02-11 5:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 5:37 Qu Wenruo [this message]
2020-02-11 5:37 ` [PATCH v2 1/4] btrfs: relocation: Introduce error injection points for cancelling balance Qu Wenruo
2020-02-13 20:00 ` Josef Bacik
2020-02-11 5:37 ` [PATCH v2 2/4] btrfs: relocation: Check cancel request after each data page read Qu Wenruo
2020-02-13 20:03 ` Josef Bacik
2020-02-14 17:10 ` David Sterba
2020-02-11 5:37 ` [PATCH v2 3/4] btrfs: relocation: Check cancel request after each extent found Qu Wenruo
2020-02-13 20:05 ` Josef Bacik
2020-02-11 5:37 ` [PATCH v2 4/4] btrfs: relocation: Work around dead relocation stage loop Qu Wenruo
2020-02-13 20:08 ` Josef Bacik
2020-02-14 0:33 ` Qu Wenruo
2020-02-14 17:12 ` [PATCH v2 0/4] btrfs: Make balance cancelling response faster David Sterba
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200211053729.20807-1-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).