Skip to content

Commit adfb69a

Browse files
asjkdave
authored andcommitted
btrfs: add_missing_dev() should return the actual error
add_missing_dev() can return device pointer so that IS_ERR/PTR_ERR can be used to check for the actual error that occurred in the function. Signed-off-by: Anand Jain <[email protected]> Reviewed-by: Liu Bo <[email protected]> [ minor error message adjustment ] Signed-off-by: David Sterba <[email protected]>
1 parent 9e882d6 commit adfb69a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

fs/btrfs/volumes.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6238,7 +6238,7 @@ static struct btrfs_device *add_missing_dev(struct btrfs_fs_devices *fs_devices,
62386238

62396239
device = btrfs_alloc_device(NULL, &devid, dev_uuid);
62406240
if (IS_ERR(device))
6241-
return NULL;
6241+
return device;
62426242

62436243
list_add(&device->dev_list, &fs_devices->devices);
62446244
device->fs_devices = fs_devices;
@@ -6443,9 +6443,12 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
64436443
map->stripes[i].dev =
64446444
add_missing_dev(fs_info->fs_devices, devid,
64456445
uuid);
6446-
if (!map->stripes[i].dev) {
6446+
if (IS_ERR(map->stripes[i].dev)) {
64476447
free_extent_map(em);
6448-
return -EIO;
6448+
btrfs_err(fs_info,
6449+
"failed to init missing dev %llu: %ld",
6450+
devid, PTR_ERR(map->stripes[i].dev));
6451+
return PTR_ERR(map->stripes[i].dev);
64496452
}
64506453
btrfs_report_missing_device(fs_info, devid, uuid);
64516454
}
@@ -6571,8 +6574,12 @@ static int read_one_dev(struct btrfs_fs_info *fs_info,
65716574
}
65726575

65736576
device = add_missing_dev(fs_devices, devid, dev_uuid);
6574-
if (!device)
6575-
return -ENOMEM;
6577+
if (IS_ERR(device)) {
6578+
btrfs_err(fs_info,
6579+
"failed to add missing dev %llu: %ld",
6580+
devid, PTR_ERR(device));
6581+
return PTR_ERR(device);
6582+
}
65766583
btrfs_report_missing_device(fs_info, devid, dev_uuid);
65776584
} else {
65786585
if (!device->bdev) {

0 commit comments

Comments
 (0)