Re: [PATCH v3 1/4] btrfs: add_missing_dev() should return the actual error

2017-10-13 Thread David Sterba
On Wed, Oct 11, 2017 at 12:46:18PM +0800, Anand Jain wrote:
> add_missing_dev() can return device pointer so that IS_ERR/
> PTR_ERR can be used to check for the actual error occurred
> in the function.
> 
> Signed-off-by: Anand Jain 
> Reviewed-by: Liu Bo 

Reviewed-by: David Sterba 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/4] btrfs: add_missing_dev() should return the actual error

2017-10-10 Thread Anand Jain
add_missing_dev() can return device pointer so that IS_ERR/
PTR_ERR can be used to check for the actual error occurred
in the function.

Signed-off-by: Anand Jain 
Reviewed-by: Liu Bo 
---
v2: add btrfs_err in read_one_dev too
v3: fix wrong commit id used for git send and
add missing change log

 fs/btrfs/volumes.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0e8f16c305df..1fb98c2ab9c0 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6249,7 +6249,7 @@ static struct btrfs_device *add_missing_dev(struct 
btrfs_fs_devices *fs_devices,
 
device = btrfs_alloc_device(NULL, , dev_uuid);
if (IS_ERR(device))
-   return NULL;
+   return device;
 
list_add(>dev_list, _devices->devices);
device->fs_devices = fs_devices;
@@ -6454,9 +6454,12 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, 
struct btrfs_key *key,
map->stripes[i].dev =
add_missing_dev(fs_info->fs_devices, devid,
uuid);
-   if (!map->stripes[i].dev) {
+   if (IS_ERR(map->stripes[i].dev)) {
free_extent_map(em);
-   return -EIO;
+   btrfs_err(fs_info,
+   "failed to init missing dev %llu %ld",
+   devid, PTR_ERR(map->stripes[i].dev));
+   return PTR_ERR(map->stripes[i].dev);
}
btrfs_report_missing_device(fs_info, devid, uuid);
}
@@ -6582,8 +6585,12 @@ static int read_one_dev(struct btrfs_fs_info *fs_info,
}
 
device = add_missing_dev(fs_devices, devid, dev_uuid);
-   if (!device)
-   return -ENOMEM;
+   if (IS_ERR(device)) {
+   btrfs_err(fs_info,
+   "failed to add missing dev %llu %ld",
+   devid, PTR_ERR(device));
+   return PTR_ERR(device);
+   }
btrfs_report_missing_device(fs_info, devid, dev_uuid);
} else {
if (!device->bdev) {
-- 
2.13.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html