All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zach Brown <zab@zabbo.net>
To: linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.cz>
Subject: [PATCH 2/4] btrfs-progs: check read extent errors when mapping
Date: Wed, 15 Oct 2014 16:14:19 -0700	[thread overview]
Message-ID: <1413414861-28097-3-git-send-email-zab@zabbo.net> (raw)
In-Reply-To: <1413414861-28097-1-git-send-email-zab@zabbo.net>

coverity barked out a warning that btrfs-map-logical was storing but
ignoring errors from read_extent_from_disk().   So don't ignore 'em.  I
made extent reading errors fatal to match the fatal errors from mapping
mirrors above.

And while we're at it have read_extent_from_disk() return -errno pread
errors instead of -EIO or -1 (-EPERM).  The only other caller who tests
errors clobbers them with -EIO.

Signed-off-by: Zach Brown <zab@zabbo.net>
---
 btrfs-map-logical.c | 12 +++++++++++-
 extent_io.c         |  4 +++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index 6b475fc..47d1104 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -76,8 +76,18 @@ static struct extent_buffer * debug_read_block(struct btrfs_root *root,
 			(unsigned long long)eb->dev_bytenr, device->name);
 		kfree(multi);
 
-		if (!copy || mirror_num == copy)
+		if (!copy || mirror_num == copy) {
 			ret = read_extent_from_disk(eb, 0, eb->len);
+			if (ret) {
+				fprintf(info_file,
+					"Error: failed to read extent: mirror %d logical %llu: %s\n",
+					mirror_num, (unsigned long long)eb->start,
+					strerror(-ret));
+				free_extent_buffer(eb);
+				eb = NULL;
+				break;
+			}
+		}
 
 		num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
 					      eb->start, eb->len);
diff --git a/extent_io.c b/extent_io.c
index 425af8a..5186e89 100644
--- a/extent_io.c
+++ b/extent_io.c
@@ -647,8 +647,10 @@ int read_extent_from_disk(struct extent_buffer *eb,
 {
 	int ret;
 	ret = pread(eb->fd, eb->data + offset, len, eb->dev_bytenr);
-	if (ret < 0)
+	if (ret < 0) {
+		ret = -errno;
 		goto out;
+	}
 	if (ret != len) {
 		ret = -EIO;
 		goto out;
-- 
1.9.3


  parent reply	other threads:[~2014-10-15 23:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15 23:14 [PATCH 0/4] some btrfs-progs coverity fixes Zach Brown
2014-10-15 23:14 ` [PATCH 1/4] btrfs-progs: check sscanf return code Zach Brown
2014-10-15 23:14 ` Zach Brown [this message]
2014-10-15 23:14 ` [PATCH 3/4] btrfs-progs: fix show super unknown flag output Zach Brown
2014-10-15 23:14 ` [PATCH 4/4] btrfs-progs: fix csum root copy-n-paste error Zach Brown
2014-10-16 10:55   ` David Sterba
2014-10-16 11:46 ` [PATCH 0/4] some btrfs-progs coverity fixes David Sterba
2014-10-16 13:33   ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413414861-28097-3-git-send-email-zab@zabbo.net \
    --to=zab@zabbo.net \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.