Re: [PATCH 4/7] btrfs: lift uuid_mutex to callers of btrfs_open_devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





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@xxxxxxxx>

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

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;
  }

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux