From: Filipe Manana <fdmanana@kernel.org>
To: Naohiro Aota <naohiro.aota@wdc.com>
Cc: linux-btrfs@vger.kernel.org, johannes.thumshirn@wdc.com
Subject: Re: [PATCH v3 3/3] btrfs: assert that relocation is protected with sb_start_write()
Date: Mon, 28 Mar 2022 11:49:26 +0100 [thread overview]
Message-ID: <YkGStsP38F7AdDSW@debian9.Home> (raw)
In-Reply-To: <3c5403c65f3aacbba5f4e441b336233f2112f141.1648448228.git.naohiro.aota@wdc.com>
On Mon, Mar 28, 2022 at 03:29:22PM +0900, Naohiro Aota wrote:
> btrfs_relocate_chunk() initiates new ordered extents.
Just say the relocation of data block groups creates ordered extents.
Saying btrfs_relocate_chunk() is a bit misleading, since the ordered
extents are created way deeper in the call chain.
> They can cause a
> hang when a process is trying to thaw the filesystem.
>
> We should have called sb_start_write(), so the filesystem is not being
> frozen. Add an ASSERT to check it is protected.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---
> fs/btrfs/relocation.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index fdc2c4b411f0..705799b2b207 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -3977,6 +3977,10 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
> if (!bg)
> return -ENOENT;
>
> + /* Assert we called sb_start_write(), not to race with FS freezing */
Sentences should end with punctuation.
The comment is also a bit vague.
Just say that relocation of data block groups creates ordered extents, and
without sb_start_write() protection, we can deadlock if a fs freeze is started
before the relocation completes, because finishing an ordered extent requires
joining a transaction.
Otherwise it looks good, thanks.
> + if (bg->flags & BTRFS_BLOCK_GROUP_DATA)
> + ASSERT(sb_write_started(fs_info->sb));
> +
> if (btrfs_pinned_by_swapfile(fs_info, bg)) {
> btrfs_put_block_group(bg);
> return -ETXTBSY;
> --
> 2.35.1
>
prev parent reply other threads:[~2022-03-28 10:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 6:29 [PATCH v3 0/3] protect relocation with sb_start_write Naohiro Aota
2022-03-28 6:29 ` [PATCH v3 1/3] btrfs: mark resumed async balance as writing Naohiro Aota
2022-03-28 6:29 ` [PATCH v3 2/3] fs: add check functions for sb_start_{write,pagefault,intwrite} Naohiro Aota
2022-03-28 10:40 ` Filipe Manana
2022-03-28 6:29 ` [PATCH v3 3/3] btrfs: assert that relocation is protected with sb_start_write() Naohiro Aota
2022-03-28 10:49 ` Filipe Manana [this message]
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=YkGStsP38F7AdDSW@debian9.Home \
--to=fdmanana@kernel.org \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.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