Skip to content

Commit cd36da2

Browse files
asjkdave
authored andcommitted
btrfs: simplify parameters of btrfs_sysfs_add_devices_dir
When we add a device we need to add it to sysfs, so instead of using the btrfs_sysfs_add_devices_dir() fs_devices argument to specify whether to add a device or all of fs_devices, call the helper function directly btrfs_sysfs_add_device() and thus make it non-static. Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 6a416a0 commit cd36da2

4 files changed

Lines changed: 7 additions & 11 deletions

File tree

‎fs/btrfs/dev-replace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
512512
atomic64_set(&dev_replace->num_uncorrectable_read_errors, 0);
513513
up_write(&dev_replace->rwsem);
514514

515-
ret = btrfs_sysfs_add_devices_dir(tgt_device->fs_devices, tgt_device);
515+
ret = btrfs_sysfs_add_device(tgt_device);
516516
if (ret)
517517
btrfs_err(fs_info, "kobj add dev failed %d", ret);
518518

‎fs/btrfs/sysfs.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ static struct kobj_type devid_ktype = {
13031303
.release = btrfs_release_devid_kobj,
13041304
};
13051305

1306-
static int btrfs_sysfs_add_device(struct btrfs_device *device)
1306+
int btrfs_sysfs_add_device(struct btrfs_device *device)
13071307
{
13081308
int ret;
13091309
unsigned int nofs_flag;
@@ -1352,13 +1352,10 @@ static int btrfs_sysfs_add_device(struct btrfs_device *device)
13521352
return ret;
13531353
}
13541354

1355-
int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devices,
1356-
struct btrfs_device *device)
1355+
static int btrfs_sysfs_add_fs_devices(struct btrfs_fs_devices *fs_devices)
13571356
{
13581357
int ret;
1359-
1360-
if (device)
1361-
return btrfs_sysfs_add_device(device);
1358+
struct btrfs_device *device;
13621359

13631360
list_for_each_entry(device, &fs_devices->devices, dev_list) {
13641361
ret = btrfs_sysfs_add_device(device);
@@ -1456,7 +1453,7 @@ int btrfs_sysfs_add_mounted(struct btrfs_fs_info *fs_info)
14561453
struct btrfs_fs_devices *fs_devs = fs_info->fs_devices;
14571454
struct kobject *fsid_kobj = &fs_devs->fsid_kobj;
14581455

1459-
error = btrfs_sysfs_add_devices_dir(fs_devs, NULL);
1456+
error = btrfs_sysfs_add_fs_devices(fs_devs);
14601457
if (error)
14611458
return error;
14621459

‎fs/btrfs/sysfs.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ enum btrfs_feature_set {
1414

1515
char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
1616
const char *btrfs_feature_set_name(enum btrfs_feature_set set);
17-
int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devices,
18-
struct btrfs_device *one_device);
17+
int btrfs_sysfs_add_device(struct btrfs_device *device);
1918
void btrfs_sysfs_remove_devices_dir(struct btrfs_fs_devices *fs_devices,
2019
struct btrfs_device *device);
2120
int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs);

‎fs/btrfs/volumes.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2608,7 +2608,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
26082608
mutex_unlock(&fs_info->chunk_mutex);
26092609

26102610
/* Add sysfs device entry */
2611-
btrfs_sysfs_add_devices_dir(fs_devices, device);
2611+
btrfs_sysfs_add_device(device);
26122612

26132613
mutex_unlock(&fs_devices->device_list_mutex);
26142614

0 commit comments

Comments
 (0)