From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH] bytrfs-progs: Print error on invalid extent item format during check
Date: Fri, 29 Dec 2017 11:01:44 +0200 [thread overview]
Message-ID: <1514538104-20005-1-git-send-email-nborisov@suse.com> (raw)
While performing normal mode check if the code comes across an invalid
extent format it will just BUG() and exit without printing any useful
information for debugging. Improve the situation by outputting the
key/leaf bytenr/slot which will enable to quickly inspect the tree and
see what the corruption is.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
cmds-check.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/cmds-check.c b/cmds-check.c
index a93ac2c88a38..371516709ed8 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -8362,7 +8362,12 @@ static int process_extent_item(struct btrfs_root *root,
if (item_size < sizeof(*ei)) {
#ifdef BTRFS_COMPAT_EXTENT_TREE_V0
struct btrfs_extent_item_v0 *ei0;
- BUG_ON(item_size != sizeof(*ei0));
+ if (item_size != sizeof(*ei0)) {
+ error("invalid extent item format: ITEM[%llu %u %llu] leaf: %llu slot: %d",
+ key.objectid, key.type, key.offset,
+ btrfs_header_bytenr(eb), slot);
+ BUG();
+ }
ei0 = btrfs_item_ptr(eb, slot, struct btrfs_extent_item_v0);
refs = btrfs_extent_refs_v0(eb, ei0);
#else
--
2.7.4
next reply other threads:[~2017-12-29 9:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-29 9:01 Nikolay Borisov [this message]
2018-01-08 19:29 ` [PATCH] bytrfs-progs: Print error on invalid extent item format during check David Sterba
2018-01-25 5:56 ` Anand Jain
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=1514538104-20005-1-git-send-email-nborisov@suse.com \
--to=nborisov@suse.com \
--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 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).