linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@kernel.org>
To: Naohiro Aota <naohiro.aota@wdc.com>
Cc: linux-btrfs@vger.kernel.org, johannes.thumshirn@wdc.com,
	linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
	david@fromorbit.com
Subject: Re: [PATCH v4 3/3] btrfs: assert that relocation is protected with sb_start_write()
Date: Tue, 29 Mar 2022 11:10:33 +0100	[thread overview]
Message-ID: <YkLbGYSbJg5Gkl2Q@debian9.Home> (raw)
In-Reply-To: <28e3e02ed14fe7c0859707e1a10a447fe4338c16.1648535838.git.naohiro.aota@wdc.com>

On Tue, Mar 29, 2022 at 03:56:00PM +0900, Naohiro Aota wrote:
> Relocation of a data block group creates ordered extents. 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 | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index fdc2c4b411f0..5e52cd8d5f23 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -3977,6 +3977,16 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
>  	if (!bg)
>  		return -ENOENT;
>  
> +	/*
> +	 * Relocation of a data block group creates ordered extents.
> +	 * Without sb_start_write(), we can freeze the FS while unfinished
> +	 * ordered extents are left. Such ordered extents can cause a
> +	 * deadlock e.g, when syncfs() is trying to finish them because

syncfs() is not trying to finish them, it's waiting for them to complete.

> +	 * they never finish as the FS is already frozen.

More specifically they can't finish because they block when joining a transaction,
due to the fact that the freeze locks are being held in write mode.

Anyway, I won't make you send yet another version. Perhaps this is something
David can fixup when he picks the patch.

Reviewed-by: Filipe Manana <fdmanana@suse.com>

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
> 

  reply	other threads:[~2022-03-29 10:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29  6:55 [PATCH v4 0/3] protect relocation with sb_start_write Naohiro Aota
2022-03-29  6:55 ` [PATCH v4 1/3] btrfs: mark resumed async balance as writing Naohiro Aota
2022-03-29  6:55 ` [PATCH v4 2/3] fs: add a check function for sb_start_write() Naohiro Aota
2022-03-29  6:56 ` [PATCH v4 3/3] btrfs: assert that relocation is protected with sb_start_write() Naohiro Aota
2022-03-29 10:10   ` Filipe Manana [this message]
2022-03-30 14:19 ` [PATCH v4 0/3] protect relocation with sb_start_write 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=YkLbGYSbJg5Gkl2Q@debian9.Home \
    --to=fdmanana@kernel.org \
    --cc=david@fromorbit.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=viro@zeniv.linux.org.uk \
    /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).