[PATCH 04/10] btrfs-progs: return -EIO properly in restore_metadump()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Error number -EIO is assigned to ret but later ret is overwritten by
wait_for_worker().

Signed-off-by: Eryu Guan <guaneryu@xxxxxxxxx>
---
 btrfs-image.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/btrfs-image.c b/btrfs-image.c
index 82eed05..7d3a2f8 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -2465,6 +2465,7 @@ static int restore_metadump(const char *input, FILE *out, int old_restore,
 	u64 bytenr = 0;
 	FILE *in = NULL;
 	int ret = 0;
+	int err = 0;
 
 	if (!strcmp(input, "-")) {
 		in = stdin;
@@ -2526,7 +2527,7 @@ static int restore_metadump(const char *input, FILE *out, int old_restore,
 		if (le64_to_cpu(header->magic) != HEADER_MAGIC ||
 		    le64_to_cpu(header->bytenr) != bytenr) {
 			fprintf(stderr, "bad header in metadump image\n");
-			ret = -EIO;
+			err = -EIO;
 			break;
 		}
 		ret = add_cluster(cluster, &mdrestore, &bytenr);
@@ -2536,6 +2537,8 @@ static int restore_metadump(const char *input, FILE *out, int old_restore,
 		}
 	}
 	ret = wait_for_worker(&mdrestore);
+	if (!ret)
+		ret = err;
 
 	if (!ret && !multi_devices && !old_restore) {
 		struct btrfs_root *root;
-- 
2.4.3

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




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux