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 4/4] btrfs: assert that relocation is protected with sb_start_write()
Date: Fri, 11 Mar 2022 14:33:34 +0000	[thread overview]
Message-ID: <YitdvtFdsFSLHRYd@debian9.Home> (raw)
In-Reply-To: <697674ea626a3d04218b02dbb12e07bdd851d3f0.1646983176.git.naohiro.aota@wdc.com>

On Fri, Mar 11, 2022 at 04:38:05PM +0900, Naohiro Aota wrote:
> btrfs_relocate_chunk() initiates new 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>

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

> ---
>  fs/btrfs/volumes.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 0d27d8d35c7a..b558fd293ffa 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -3239,6 +3239,9 @@ int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
>  	u64 length;
>  	int ret;
>  
> +	/* Assert we called sb_start_write(), not to race with FS freezing */
> +	ASSERT(sb_write_started(fs_info->sb));

Does this pass the scenario of patch 1/4 (resuming balance on mount)?

Because as commented in that patch, we have the sb_start_write() done
in the mount task, and not by the task that actually runs balance - the
balance kthread.

Anyway, this change looks good, my concerns are only about patch 1/4.

Thanks.

> +
>  	if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2)) {
>  		btrfs_err(fs_info,
>  			  "relocate: not supported on extent tree v2 yet");
> -- 
> 2.35.1
> 

      reply	other threads:[~2022-03-11 14:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11  7:38 [PATCH 0/4] protect relocation with sb_start_write Naohiro Aota
2022-03-11  7:38 ` [PATCH 1/4] btrfs: mark resumed async balance as writing Naohiro Aota
2022-03-11 14:08   ` Filipe Manana
2022-03-14  2:29     ` Naohiro Aota
2022-03-14 11:25       ` Filipe Manana
2022-03-11  7:38 ` [PATCH 2/4] btrfs: mark device addition as sb_writing Naohiro Aota
2022-03-11 14:21   ` Filipe Manana
2022-03-14  2:31     ` Naohiro Aota
2022-03-11  7:38 ` [PATCH 3/4] fs: add check functions for sb_start_{write,pagefault,intwrite} Naohiro Aota
2022-03-11 14:28   ` Filipe Manana
2022-03-11  7:38 ` [PATCH 4/4] btrfs: assert that relocation is protected with sb_start_write() Naohiro Aota
2022-03-11 14:33   ` 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=YitdvtFdsFSLHRYd@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).