Skip to contentSkip to conversation

btrfs: add a check for sysfs_create_group

PATCH In review Kangjie Lu 4 participants 4 messages Dec 26, 2018 – Jan 8, 2019 Btrfs file system

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH v2 1/1 btrfs: add a check for sysfs_create_group

In case sysfs_create_group fails, let's check its return value and issues an error message.

---
 fs/btrfs/sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
fs/btrfs/sysfs.c +2 -0
index 3717c864ba23..24ef416e700b 100644
@@ -889,6 +889,8 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info,
 	 */
 	sysfs_remove_group(fsid_kobj, &btrfs_feature_attr_group);
 	ret = sysfs_create_group(fsid_kobj, &btrfs_feature_attr_group);
+	if (ret)
+		btrfs_err(fs_info, "failed to create btrfs_feature_attr_group.\n");
 }
 
 static int btrfs_init_debugfs(void)
Signature · 1 line
2.17.2 (Apple Git-113)
#1 lore raw
Quoted 13 lines · Kangjie Lu

In case sysfs_create_group fails, let's check its return value and issues an error message.

---
  fs/btrfs/sysfs.c | 2 ++
  1 file changed, 2 insertions(+)
fs/btrfs/sysfs.c +0 -0
index 3717c864ba23..24ef416e700b 100644

fs/btrfs/sysfs.c void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, · line 893

Quoted 5 lines
fs/btrfs/sysfs.c +2 -0
@@ -889,6 +889,8 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info,
  	 */
  	sysfs_remove_group(fsid_kobj, &btrfs_feature_attr_group);
  	ret = sysfs_create_group(fsid_kobj, &btrfs_feature_attr_group);
+	if (ret)
+		btrfs_err(fs_info, "failed to create btrfs_feature_attr_group.\n");

NIT: ".\n" is unnecessary.

---
Su

Quoted 4 lines
fs/btrfs/sysfs.c +0 -0
  }
 
  static int btrfs_init_debugfs(void)
Reviewed-by on v2 1/1
#2 lore raw
In reply to Kangjie Lu
Quoted 13 lines · Kangjie Lu

In case sysfs_create_group fails, let's check its return value and issues an error message.

---
 fs/btrfs/sysfs.c | 2 ++
 1 file changed, 2 insertions(+)
fs/btrfs/sysfs.c +0 -0
index 3717c864ba23..24ef416e700b 100644

fs/btrfs/sysfs.c void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info, · line 893

Quoted 5 lines
fs/btrfs/sysfs.c +2 -0
@@ -889,6 +889,8 @@ void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info,
 	 */
 	sysfs_remove_group(fsid_kobj, &btrfs_feature_attr_group);
 	ret = sysfs_create_group(fsid_kobj, &btrfs_feature_attr_group);
+	if (ret)
+		btrfs_err(fs_info, "failed to create btrfs_feature_attr_group.\n");

Forgot to mention, for btrfs_* infrastructure, no need for the ending '\n'.

Despite that, looks good.

Thanks,
Qu

Quoted 4 lines
fs/btrfs/sysfs.c +0 -0
 }
 
 static int btrfs_init_debugfs(void)
#3 lore raw
In reply to Kangjie Lu
Quoted 2 lines · Kangjie Lu

In case sysfs_create_group fails, let's check its return value and issues an error message.

It's in a function that's not currently used and the sysfs code needs to be reworked. The return code should be passed to the caller, printing error message in this case may not be desired but I can't say right now.