Skip to content

Commit

Permalink
btrfs: set the total_devices in device_list_add()
Browse files Browse the repository at this point in the history
There is no other parent for device_list_add() except for
btrfs_scan_one_device(), which would set btrfs_fs_devices::total_devices
if device_list_add is successful and this can be done with in
device_list_add() itself.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Anand Jain authored and David Sterba committed Jan 22, 2018
1 parent 327f18c commit f2788d2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,8 @@ static noinline int device_list_add(const char *path,
if (!fs_devices->opened)
device->generation = found_transid;

fs_devices->total_devices = btrfs_super_num_devices(disk_super);

*fs_devices_ret = fs_devices;

return 0;
Expand Down Expand Up @@ -1182,7 +1184,6 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
struct page *page;
int ret;
u64 devid;
u64 total_devices;
u64 bytenr;

/*
Expand All @@ -1207,11 +1208,8 @@ int btrfs_scan_one_device(const char *path, fmode_t flags, void *holder,
}

devid = btrfs_stack_device_id(&disk_super->dev_item);
total_devices = btrfs_super_num_devices(disk_super);

ret = device_list_add(path, disk_super, devid, fs_devices_ret);
if (!ret && fs_devices_ret)
(*fs_devices_ret)->total_devices = total_devices;

btrfs_release_disk_super(page);

Expand Down

0 comments on commit f2788d2

Please sign in to comment.