linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/4] btrfs: add_missing_dev() should return the actual error
@ 2017-10-09  3:07 Anand Jain
  2017-10-09  3:07 ` [PATCH v2 2/4] btrfs: fix EIO misuse to report missing degraded option Anand Jain
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Anand Jain @ 2017-10-09  3:07 UTC (permalink / raw)
  To: linux-btrfs

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 <anand.jain@oracle.com>
---
v2: This patch is a split from
    [PATCH 1/2] btrfs: fix read_one_chunk() return error code

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

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0e8f16c305df..2f500a32089e 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, &devid, dev_uuid);
 	if (IS_ERR(device))
-		return NULL;
+		return device;
 
 	list_add(&device->dev_list, &fs_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,8 @@ 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))
+			return PTR_ERR(device);
 		btrfs_report_missing_device(fs_info, devid, dev_uuid);
 	} else {
 		if (!device->bdev) {
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-10-13 12:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-09  3:07 [PATCH v2 1/4] btrfs: add_missing_dev() should return the actual error Anand Jain
2017-10-09  3:07 ` [PATCH v2 2/4] btrfs: fix EIO misuse to report missing degraded option Anand Jain
2017-10-13 12:16   ` David Sterba
2017-10-09  3:07 ` [PATCH v2 3/4] btrfs: declare btrfs_report_missing_device() static Anand Jain
2017-10-09  3:07 ` [PATCH v2 4/4] btrfs: fix use of error or warning for missing device Anand Jain
2017-10-11  0:52 ` [PATCH v2 1/4] btrfs: add_missing_dev() should return the actual error Liu Bo
2017-10-11  4:34   ` [PATCH v2.1 " Anand Jain
2017-10-11  4:46   ` [PATCH v3 " Anand Jain
2017-10-13 12:14     ` David Sterba
2017-10-13 12:28 ` [PATCH v2 " David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).