linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz, Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 0/4] btrfs: Make balance cancelling response faster
Date: Tue, 11 Feb 2020 13:35:46 +0800	[thread overview]
Message-ID: <380022b6-38f3-268d-850e-c9529c183930@gmx.com> (raw)
In-Reply-To: <fb81b112-3be5-f86a-3da8-621c1dae6bc1@gmx.com>


[-- Attachment #1.1: Type: text/plain, Size: 2510 bytes --]



On 2020/2/11 下午1:21, Qu Wenruo wrote:
> 
> 
> On 2019/12/5 上午12:39, David Sterba wrote:
>> On Tue, Dec 03, 2019 at 02:42:50PM +0800, Qu Wenruo wrote:
>>> [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.
>>
>> Yes that's the reason why it takes so long to cancel. Adding more
>> cancellation points is fine, but I don't know what exactly happens when
>> the block group relocation is not finished. There's code to merge the
>> reloc inode and commit that, but that's only a high-level view of the
>> thing.
> 
> When cancelled, we still merge the reloc roots with its source (if
> possible, as we still do the check for last_snapshot generation).
> 
> That means, if balance is canceled halfway, we still merge what is
> relocated. Then do the regular cleanup (cleanup the reloc tree).

My bad, that's not the case. But it doesn't matter anyway.

Since we error out by setting @err to -ECANCELD, we won't go through the
merge part.

We just mark all related reloc roots as orphan, then go through the
cleanup path without doing the merge.

That's the existing error handling code, and we should have experienced
quite some of them for the random data reloc tree csum mismatch bug.

At least the error handling part looks pretty solid.

I'll add this explanation into the cover letter of next version.

Thanks,
Qu

> 
> I see no problem doing faster canceling here.
> 
> Or do you have any extra concern?
> 
> Thanks,
> Qu
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-02-11  5:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03  6:42 [PATCH 0/4] btrfs: Make balance cancelling response faster Qu Wenruo
2019-12-03  6:42 ` [PATCH 1/4] btrfs: relocation: Introduce error injection points for cancelling balance Qu Wenruo
2019-12-03 13:29   ` Johannes Thumshirn
2019-12-03  6:42 ` [PATCH 2/4] btrfs: relocation: Check cancel request after each data page read Qu Wenruo
2019-12-03  6:42 ` [PATCH 3/4] btrfs: relocation: Check cancel request after each extent found Qu Wenruo
2019-12-03  6:42 ` [PATCH 4/4] btrfs: relocation: Work around dead relocation stage loop Qu Wenruo
2019-12-04 16:39 ` [PATCH 0/4] btrfs: Make balance cancelling response faster David Sterba
2020-02-11  5:21   ` Qu Wenruo
2020-02-11  5:35     ` Qu Wenruo [this message]
2019-12-05  2:58 ` Zygo Blaxell
2019-12-05  3:26   ` Qu Wenruo
  -- strict thread matches above, loose matches on Subject: below --
2019-12-03  6:24 Qu Wenruo

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=380022b6-38f3-268d-850e-c9529c183930@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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).