All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
To: Linux Btrfs <linux-btrfs@vger.kernel.org>
Cc: wangshilong1991@gmail.com
Subject: [PATCH] Btrfs-progs: make btrfs-map-logical handle error gracefully
Date: Fri, 19 Jul 2013 14:31:34 +0800	[thread overview]
Message-ID: <51E8DD46.7070601@cn.fujitsu.com> (raw)

If an overflow logical address is passed(for example),the original
code will cause segmentation, this is unfriendly to users,fix it.

Signed-off-by: Wang Shilong<wangsl.fnst@cn.fujitsu.com>
---
  btrfs-map-logical.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index b9635f7..fce6504 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -57,7 +57,14 @@ struct extent_buffer *debug_read_block(struct btrfs_root *root, u64 bytenr,
  		ret = btrfs_map_block(&root->fs_info->mapping_tree, READ,
  				      eb->start, &length, &multi,
  				      mirror_num, NULL);
-		BUG_ON(ret);
+		if (ret) {
+			fprintf(info_file,
+				"Error: fails to map mirror%d logical %llu: %s\n",
+				mirror_num, (unsigned long long)eb->start,
+				strerror(-ret));
+			free_extent_buffer(eb);
+			return NULL;
+		}
  		device = multi->stripes[0].dev;
  		eb->fd = device->fd;
  		device->total_ios++;
-- 1.8.0.1


                 reply	other threads:[~2013-07-19  6:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=51E8DD46.7070601@cn.fujitsu.com \
    --to=wangsl.fnst@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wangshilong1991@gmail.com \
    /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.