diff options
author | Anand Jain <anand.jain@oracle.com> | 2019-01-17 18:32:29 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2019-02-25 16:13:23 +0300 |
commit | 6e927cebe250f206ecb51020fa7caa012cf1fba9 (patch) | |
tree | fb2fc0e9e377aea0e966e637e28da59c3af79506 /fs/btrfs/volumes.c | |
parent | d95a830c78adb53058b86e0cb7df98dc0b874d43 (diff) | |
download | linux-6e927cebe250f206ecb51020fa7caa012cf1fba9.tar.xz |
btrfs: cleanup btrfs_find_device_by_devspec()
btrfs_find_device_by_devspec() finds the device by @devid or by
@device_path. This patch makes code flow easy to read by open coding the
else part and renames devpath to device_path.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 61432eefb1dc..e4be0f679460 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2402,7 +2402,8 @@ static struct btrfs_device *btrfs_find_device_by_path( * Lookup a device given by device id, or the path if the id is 0. */ struct btrfs_device *btrfs_find_device_by_devspec( - struct btrfs_fs_info *fs_info, u64 devid, const char *devpath) + struct btrfs_fs_info *fs_info, u64 devid, + const char *device_path) { struct btrfs_device *device; @@ -2410,24 +2411,24 @@ struct btrfs_device *btrfs_find_device_by_devspec( device = btrfs_find_device(fs_info, devid, NULL, NULL); if (!device) return ERR_PTR(-ENOENT); - } else { - if (!devpath || !devpath[0]) - return ERR_PTR(-EINVAL); - - if (strcmp(devpath, "missing") == 0) { - list_for_each_entry(device, &fs_info->fs_devices->devices, - dev_list) { - if (test_bit(BTRFS_DEV_STATE_IN_FS_METADATA, - &device->dev_state) && - !device->bdev) - return device; - } - return ERR_PTR(-ENOENT); - } else { - device = btrfs_find_device_by_path(fs_info, devpath); + return device; + } + + if (!device_path || !device_path[0]) + return ERR_PTR(-EINVAL); + + if (strcmp(device_path, "missing") == 0) { + /* Find first missing device */ + list_for_each_entry(device, &fs_info->fs_devices->devices, + dev_list) { + if (test_bit(BTRFS_DEV_STATE_IN_FS_METADATA, + &device->dev_state) && !device->bdev) + return device; } + return ERR_PTR(-ENOENT); } - return device; + + return btrfs_find_device_by_path(fs_info, device_path); } /* |