diff mbox

[1/7] btrfs: restore uuid_mutex in btrfs_open_devices

Message ID 953899caf13686e1f128748ef3220281a1b9a47e.1529516228.git.dsterba@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

David Sterba June 20, 2018, 5:51 p.m. UTC
Commit 542c5908abfe84f7b4c1 ("btrfs: replace uuid_mutex by
device_list_mutex in btrfs_open_devices") switched to device_list_mutex
as we need that for the device list traversal, but we also need
uuid_mutex to protect access to fs_devices::opened to be consistent with
other users of that item.

CC: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/volumes.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Anand Jain July 4, 2018, 8:09 a.m. UTC | #1
On 06/21/2018 01:51 AM, David Sterba wrote:
> Commit 542c5908abfe84f7b4c1 ("btrfs: replace uuid_mutex by
> device_list_mutex in btrfs_open_devices") switched to device_list_mutex
> as we need that for the device list traversal, but we also need
> uuid_mutex to protect access to fs_devices::opened to be consistent with
> other users of that item.
> 
> CC: Anand Jain <anand.jain@oracle.com>
> Signed-off-by: David Sterba <dsterba@suse.com>

  I am optimize the uuid_mutex for fsids concurrency on top these set of 
patches, so.

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

Thanks, Anand

> ---
>   fs/btrfs/volumes.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index e034ad9e23b4..1da162928d1a 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1146,6 +1146,7 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
>   {
>   	int ret;
>   
> +	mutex_lock(&uuid_mutex);
>   	mutex_lock(&fs_devices->device_list_mutex);
>   	if (fs_devices->opened) {
>   		fs_devices->opened++;
> @@ -1155,6 +1156,7 @@ 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;
>   }
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba July 13, 2018, 12:49 p.m. UTC | #2
On Wed, Jul 04, 2018 at 04:09:50PM +0800, Anand Jain wrote:
> On 06/21/2018 01:51 AM, David Sterba wrote:
> > Commit 542c5908abfe84f7b4c1 ("btrfs: replace uuid_mutex by
> > device_list_mutex in btrfs_open_devices") switched to device_list_mutex
> > as we need that for the device list traversal, but we also need
> > uuid_mutex to protect access to fs_devices::opened to be consistent with
> > other users of that item.
> > 
> > CC: Anand Jain <anand.jain@oracle.com>
> > Signed-off-by: David Sterba <dsterba@suse.com>
> 
>   I am optimize the uuid_mutex for fsids concurrency on top these set of 
> patches, so.
> 
>   Reviewed-by: Anand Jain <anand.jain@oracle.com>

So this should go to 4.18, instead of reverting 542c5908abfe8.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index e034ad9e23b4..1da162928d1a 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1146,6 +1146,7 @@  int btrfs_open_devices(struct btrfs_fs_devices *fs_devices,
 {
 	int ret;
 
+	mutex_lock(&uuid_mutex);
 	mutex_lock(&fs_devices->device_list_mutex);
 	if (fs_devices->opened) {
 		fs_devices->opened++;
@@ -1155,6 +1156,7 @@  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;
 }