Skip to content

Commit d95a830

Browse files
asjkdave
authored andcommitted
btrfs: merge btrfs_find_device_missing_or_by_path() into parent
btrfs_find_device_missing_or_by_path() is relatively small function, and its only parent btrfs_find_device_by_devspec() is small as well. Besides there are a number of find_device functions. Merge btrfs_find_device_missing_or_by_path() into its parent. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 02a033d commit d95a830

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

fs/btrfs/volumes.c

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2398,32 +2398,6 @@ static struct btrfs_device *btrfs_find_device_by_path(
23982398
return device;
23992399
}
24002400

2401-
static struct btrfs_device *btrfs_find_device_missing_or_by_path(
2402-
struct btrfs_fs_info *fs_info, const char *device_path)
2403-
{
2404-
struct btrfs_device *device = NULL;
2405-
if (strcmp(device_path, "missing") == 0) {
2406-
struct list_head *devices;
2407-
struct btrfs_device *tmp;
2408-
2409-
devices = &fs_info->fs_devices->devices;
2410-
list_for_each_entry(tmp, devices, dev_list) {
2411-
if (test_bit(BTRFS_DEV_STATE_IN_FS_METADATA,
2412-
&tmp->dev_state) && !tmp->bdev) {
2413-
device = tmp;
2414-
break;
2415-
}
2416-
}
2417-
2418-
if (!device)
2419-
return ERR_PTR(-ENOENT);
2420-
} else {
2421-
device = btrfs_find_device_by_path(fs_info, device_path);
2422-
}
2423-
2424-
return device;
2425-
}
2426-
24272401
/*
24282402
* Lookup a device given by device id, or the path if the id is 0.
24292403
*/
@@ -2439,7 +2413,19 @@ struct btrfs_device *btrfs_find_device_by_devspec(
24392413
} else {
24402414
if (!devpath || !devpath[0])
24412415
return ERR_PTR(-EINVAL);
2442-
device = btrfs_find_device_missing_or_by_path(fs_info, devpath);
2416+
2417+
if (strcmp(devpath, "missing") == 0) {
2418+
list_for_each_entry(device, &fs_info->fs_devices->devices,
2419+
dev_list) {
2420+
if (test_bit(BTRFS_DEV_STATE_IN_FS_METADATA,
2421+
&device->dev_state) &&
2422+
!device->bdev)
2423+
return device;
2424+
}
2425+
return ERR_PTR(-ENOENT);
2426+
} else {
2427+
device = btrfs_find_device_by_path(fs_info, devpath);
2428+
}
24432429
}
24442430
return device;
24452431
}

0 commit comments

Comments
 (0)