All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Josef Bacik <josef@toxicpanda.com>, David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v3 3/6] btrfs: do not call close_fs_devices in btrfs_rm_device
Date: Tue, 5 Oct 2021 11:18:10 +0800	[thread overview]
Message-ID: <f1f5ea81-1914-16d7-4d1b-5e4d83a9265f@oracle.com> (raw)
In-Reply-To: <326bb4ecde587f0f3f4884b65d17951661a0ca77.1633367810.git.josef@toxicpanda.com>


On 05/10/2021 01:19, Josef Bacik wrote:
> There's a subtle case where if we're removing the seed device from a
> file system we need to free its private copy of the fs_devices.  However
> we do not need to call close_fs_devices(), because at this point there
> are no devices left to close as we've closed the last one.  The only
> thing that close_fs_devices() does is decrement ->opened, which should
> be 1.  We want to avoid calling close_fs_devices() here because it has a
> lockdep_assert_held(&uuid_mutex), and we are going to stop holding the
> uuid_mutex in this path.
> 
> So simply decrement the  ->opened counter like we should, and then clean
> up like normal.  Also add a comment explaining what we're doing here as
> I initially removed this code erroneously.
> 

David,

  You might want to add this patch before commit e197aab25da2 (btrfs: do 
not take the uuid_mutex in btrfs_rm_device) in the misc-next. As this 
patch is preparatory of it.

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

  Reviewed-by: Anand Jain <anand.jain@oralce.com>

Thx, Anand

> ---
>   fs/btrfs/volumes.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 0941f61d8071..5f19d0863094 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -2211,9 +2211,16 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path,
>   	synchronize_rcu();
>   	btrfs_free_device(device);
>   
> +	/*
> +	 * This can happen if cur_devices is the private seed devices list.  We
> +	 * cannot call close_fs_devices() here because it expects the uuid_mutex
> +	 * to be held, but in fact we don't need that for the private
> +	 * seed_devices, we can simply decrement cur_devices->opened and then
> +	 * remove it from our list and free the fs_devices.
> +	 */
>   	if (cur_devices->num_devices == 0) {
>   		list_del_init(&cur_devices->seed_list);
> -		close_fs_devices(cur_devices);
> +		cur_devices->opened--;
>   		free_fs_devices(cur_devices);
>   	}
>   
> 


  reply	other threads:[~2021-10-05  3:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04 17:19 [PATCH v3 0/6] Fix lockdep issues around device removal Josef Bacik
2021-10-04 17:19 ` [PATCH v3 1/6] btrfs: use num_device to check for the last surviving seed device Josef Bacik
2021-10-04 17:19 ` [PATCH v3 2/6] btrfs: add comments for device counts in struct btrfs_fs_devices Josef Bacik
2021-10-04 17:19 ` [PATCH v3 3/6] btrfs: do not call close_fs_devices in btrfs_rm_device Josef Bacik
2021-10-05  3:18   ` Anand Jain [this message]
2021-10-04 17:19 ` [PATCH v3 4/6] btrfs: handle device lookup with btrfs_dev_lookup_args Josef Bacik
2021-10-05  4:48   ` Anand Jain
2021-10-05  5:25     ` Anand Jain
2021-10-04 17:19 ` [PATCH v3 5/6] btrfs: add a btrfs_get_dev_args_from_path helper Josef Bacik
2021-10-05  5:27   ` Anand Jain
2021-10-04 17:19 ` [PATCH v3 6/6] btrfs: use btrfs_get_dev_args_from_path in dev removal ioctls Josef Bacik

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=f1f5ea81-1914-16d7-4d1b-5e4d83a9265f@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.