linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: David Sterba <dsterba@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 4/7] btrfs: lift uuid_mutex to callers of btrfs_open_devices
Date: Wed, 4 Jul 2018 16:19:39 +0800	[thread overview]
Message-ID: <da05f3ae-3437-8f4e-d30e-8ae5e302d592@oracle.com> (raw)
In-Reply-To: <10602be89b1e8b940353fa64dfda47b6c27b14fa.1529516228.git.dsterba@suse.com>



On 06/21/2018 01:51 AM, David Sterba wrote:
> Prepartory work to fix race between mount and device scan.
> 
> The callers will have to manage the critical section, eg.  mount wants
> to scan and then call btrfs_open_devices without the ioctl scan walking
> in and modifying the fs devices in the meantime.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>

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

Thanks, Anand

> ---
>   fs/btrfs/super.c   | 2 ++
>   fs/btrfs/volumes.c | 4 ++--
>   2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index 735402ed3154..ee82d02f5453 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -1569,7 +1569,9 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
>   		goto error_fs_info;
>   	}
>   
> +	mutex_lock(&uuid_mutex);
>   	error = btrfs_open_devices(fs_devices, mode, fs_type);
> +	mutex_unlock(&uuid_mutex);
>   	if (error)
>   		goto error_fs_info;
>   
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 958bfe1a725c..5336d9832ba4 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1145,7 +1145,8 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
>   {
>   	int ret;
>   
> -	mutex_lock(&uuid_mutex);
> +	lockdep_assert_held(&uuid_mutex);
> +
>   	mutex_lock(&fs_devices->device_list_mutex);
>   	if (fs_devices->opened) {
>   		fs_devices->opened++;
> @@ -1155,7 +1156,6 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
>   		ret = open_fs_devices(fs_devices, flags, holder);
>   	}
>   	mutex_unlock(&fs_devices->device_list_mutex);
> -	mutex_unlock(&uuid_mutex);
>   
>   	return ret;
>   }
> 

  reply	other threads:[~2018-07-04  8:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20 17:51 [PATCH 0/7] Fix locking when scanning devices David Sterba
2018-06-20 17:51 ` [PATCH 1/7] btrfs: restore uuid_mutex in btrfs_open_devices David Sterba
2018-07-04  8:09   ` Anand Jain
2018-07-13 12:49     ` David Sterba
2018-06-20 17:51 ` [PATCH 2/7] btrfs: extend critical section when scanning a new device David Sterba
2018-06-26  7:34   ` Anand Jain
2018-07-04  8:18   ` Anand Jain
2018-07-13 12:55     ` David Sterba
2018-06-20 17:51 ` [PATCH 3/7] btrfs: lift uuid_mutex to callers of btrfs_scan_one_device David Sterba
2018-07-04  8:19   ` Anand Jain
2018-06-20 17:51 ` [PATCH 4/7] btrfs: lift uuid_mutex to callers of btrfs_open_devices David Sterba
2018-07-04  8:19   ` Anand Jain [this message]
2018-06-20 17:51 ` [PATCH 5/7] btrfs: lift uuid_mutex to callers of btrfs_parse_early_options David Sterba
2018-07-04  8:20   ` Anand Jain
2018-06-20 17:51 ` [PATCH 6/7] btrfs: reorder initialization before the mount locks uuid_mutex David Sterba
2018-07-04  8:21   ` Anand Jain
2018-06-20 17:51 ` [PATCH 7/7] btrfs: fix mount and ioctl device scan ioctl race David Sterba
2018-06-26  9:33   ` Anand Jain
2018-07-04  8:22   ` Anand Jain
2018-06-21  7:48 ` [PATCH 0/7] Fix locking when scanning devices Nikolay Borisov
2018-06-22 11:39   ` 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=da05f3ae-3437-8f4e-d30e-8ae5e302d592@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.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 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).