Skip to contentSkip to conversation

btrfs: remove fsid argument from btrfs_sysfs_update_sprout_fsid

PATCH In review Nikolay Borisov 5 participants 5 messages Aug 12, 2020 – Aug 29, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: remove fsid argument from btrfs_sysfs_update_sprout_fsid

It can be accessed from 'fs_devices' as it's identical to fs_info->fs_devices. Also add a comment about why we are calling the function. No semantic changes.

---
 fs/btrfs/sysfs.c   | 6 +++---
 fs/btrfs/sysfs.h   | 3 +--
 fs/btrfs/volumes.c | 8 ++++++--
 3 files changed, 10 insertions(+), 7 deletions(-)
fs/btrfs/sysfs.c +3 -3
index 784a0f8a4cab..2d987b770a20 100644
@@ -1322,8 +1322,8 @@ void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action)
 			&disk_to_dev(bdev->bd_disk)->kobj);
 }
 
-void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
-				    const u8 *fsid)
+void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices)
+
 {
 	char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
 
@@ -1331,7 +1331,7 @@ void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
 	 * Sprouting changes fsid of the mounted filesystem, rename the fsid
 	 * directory
 	 */
-	snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU", fsid);
+	snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU", fs_devices->fsid);
 	if (kobject_rename(&fs_devices->fsid_kobj, fsid_buf))
 		btrfs_warn(fs_devices->fs_info,
 				"sysfs: failed to create fsid for sprout");
fs/btrfs/sysfs.h +1 -2
index cf839c46a131..c9efa15f96e0 100644
@@ -20,8 +20,7 @@ int btrfs_sysfs_remove_devices_dir(struct btrfs_fs_devices *fs_devices,
                 struct btrfs_device *one_device);
 int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs);
 void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
-void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
-				    const u8 *fsid);
+void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices);
 void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info,
 		u64 bit, enum btrfs_feature_set set);
 void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action);
fs/btrfs/volumes.c +6 -2
index 4bae30b9c944..631cb03b3513 100644
@@ -2630,8 +2630,12 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
 			goto error_sysfs;
 		}
 
-		btrfs_sysfs_update_sprout_fsid(fs_devices,
-				fs_info->fs_devices->fsid);
+		/*
+		 * fs_devices now represents the newly sprouted filesystem and
+		 * its fsid has been changed by btrfs_prepare_sprout
+		 */
+		btrfs_sysfs_update_sprout_fsid(fs_devices);
+
 	}
 
 	ret = btrfs_commit_transaction(trans);
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#4 lore raw
In reply to Nikolay Borisov
Quoted 59 lines · Nikolay Borisov

It can be accessed from 'fs_devices' as it's identical to fs_info->fs_devices. Also add a comment about why we are calling the function. No semantic changes.

---
  fs/btrfs/sysfs.c   | 6 +++---
  fs/btrfs/sysfs.h   | 3 +--
  fs/btrfs/volumes.c | 8 ++++++--
  3 files changed, 10 insertions(+), 7 deletions(-)
fs/btrfs/sysfs.c +3 -3
index 784a0f8a4cab..2d987b770a20 100644
@@ -1322,8 +1322,8 @@ void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action)
  			&disk_to_dev(bdev->bd_disk)->kobj);
  }
 
-void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
-				    const u8 *fsid)
+void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices)
+
  {
  	char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
 
@@ -1331,7 +1331,7 @@ void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
  	 * Sprouting changes fsid of the mounted filesystem, rename the fsid
  	 * directory
  	 */
-	snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU", fsid);
+	snprintf(fsid_buf, BTRFS_UUID_UNPARSED_SIZE, "%pU", fs_devices->fsid);
  	if (kobject_rename(&fs_devices->fsid_kobj, fsid_buf))
  		btrfs_warn(fs_devices->fs_info,
  				"sysfs: failed to create fsid for sprout");
fs/btrfs/sysfs.h +1 -2
index cf839c46a131..c9efa15f96e0 100644
@@ -20,8 +20,7 @@ int btrfs_sysfs_remove_devices_dir(struct btrfs_fs_devices *fs_devices,
                  struct btrfs_device *one_device);
  int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs);
  void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
-void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices,
-				    const u8 *fsid);
+void btrfs_sysfs_update_sprout_fsid(struct btrfs_fs_devices *fs_devices);
  void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info,
  		u64 bit, enum btrfs_feature_set set);
  void btrfs_kobject_uevent(struct block_device *bdev, enum kobject_action action);
fs/btrfs/volumes.c +0 -1
index 4bae30b9c944..631cb03b3513 100644
@@ -2630,8 +2630,12 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
  			goto error_sysfs;
  		}
 
-		btrfs_sysfs_update_sprout_fsid(fs_devices,

fs/btrfs/volumes.c int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path · line 2641

Quoted 10 lines
fs/btrfs/volumes.c +6 -1
-				fs_info->fs_devices->fsid);
+		/*
+		 * fs_devices now represents the newly sprouted filesystem and
+		 * its fsid has been changed by btrfs_prepare_sprout
+		 */
+		btrfs_sysfs_update_sprout_fsid(fs_devices);
+
  	}
 
  	ret = btrfs_commit_transaction(trans);