public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: avoid possible signal interruption for btrfs_drop_snapshot() on relocation tree
Date: Wed, 8 Jul 2020 10:13:12 -0400	[thread overview]
Message-ID: <0b168157-3dad-ddba-e616-ae82eb2d6501@toxicpanda.com> (raw)
In-Reply-To: <20200708100022.90085-1-wqu@suse.com>

On 7/8/20 6:00 AM, Qu Wenruo wrote:
> [BUG]
> There is a bug report about bad signal timing could lead to read-only
> fs during balance:
> 
>    BTRFS info (device xvdb): balance: start -d -m -s
>    BTRFS info (device xvdb): relocating block group 73001861120 flags metadata
>    BTRFS info (device xvdb): found 12236 extents, stage: move data extents
>    BTRFS info (device xvdb): relocating block group 71928119296 flags data
>    BTRFS info (device xvdb): found 3 extents, stage: move data extents
>    BTRFS info (device xvdb): found 3 extents, stage: update data pointers
>    BTRFS info (device xvdb): relocating block group 60922265600 flags metadata
>    BTRFS: error (device xvdb) in btrfs_drop_snapshot:5505: errno=-4 unknown
>    BTRFS info (device xvdb): forced readonly
>    BTRFS info (device xvdb): balance: ended with status: -4
> 
> [CAUSE]
> The direct cause is the -EINTR from the following call chain when a
> fatal signal is pending:
> 
>   relocate_block_group()
>   |- clean_dirty_subvols()
>      |- btrfs_drop_snapshot()
>         |- btrfs_start_transaction()
>            |- btrfs_delayed_refs_rsv_refill()
>               |- btrfs_reserve_metadata_bytes()
>                  |- __reserve_metadata_bytes()
>                     |- wait_reserve_ticket()
>                        |- prepare_to_wait_event();
>                        |- ticket->error = -EINTR;
> 
> Normally this behavior is fine for most btrfs_start_transaction()
> callers, as they need to catch the fatal signal and exit asap.
> 
> However to balance, especially for the clean_dirty_subvols() case, we're
> already doing cleanup works, such -EINTR from btrfs_drop_snapshot()
> could cause a lot of unexpected problems.
> 
>  From the mentioned forced read-only, to later balance error due to half
> dropped reloc trees.
> 
> [FIX]
> Fix this problem by using btrfs_join_transaction() if
> btrfs_drop_snapshot() is called from relocation context.
> 
> As btrfs_join_transaction() won't wait full tickets, it won't get
> interrupted from signal.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

  parent reply	other threads:[~2020-07-08 14:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 10:00 [PATCH 1/2] btrfs: avoid possible signal interruption for btrfs_drop_snapshot() on relocation tree Qu Wenruo
2020-07-08 10:00 ` [PATCH 2/2] btrfs: relocation: review the call sites which can be interruped by signal Qu Wenruo
2020-07-08 10:07   ` Nikolay Borisov
2020-07-08 14:13 ` Josef Bacik [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-07-08  7:50 [PATCH 1/2] btrfs: avoid possible signal interruption for btrfs_drop_snapshot() on relocation tree 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=0b168157-3dad-ddba-e616-ae82eb2d6501@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --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