All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: <calestyo@scientia.net>, <chris@colorremedies.com>, <dsterba@suse.cz>
Subject: [PATCH 5/9] btrfs-progs: lowmem check: Fix extent item size false alert
Date: Mon, 23 Jan 2017 17:13:54 +0800	[thread overview]
Message-ID: <20170123091359.21390-6-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <20170123091359.21390-1-quwenruo@cn.fujitsu.com>

If one extent item has no inline ref, btrfs lowmem mode check can give
false alert without outputting any error message.

The problem is lowmem mode always assume that extent item has inline
refs, and when it encounters such case it flags the extent item has
wrong size, but doesn't output the error message.

Although we already have such image submitted, at the commit time due to
another bug in cmds-check return value, it doesn't detect it until that
bug is fixed.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 cmds-check.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/cmds-check.c b/cmds-check.c
index fd176b76..802d179f 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -10730,13 +10730,20 @@ static int check_extent_item(struct btrfs_fs_info *fs_info,
 	}
 	end = (unsigned long)ei + item_size;
 
-	if (ptr >= end) {
+next:
+	/* Reached extent item end normally */
+	if (ptr == end)
+		goto out;
+
+	/* Beyond extent item end, wrong item size */
+	if (ptr > end) {
 		err |= ITEM_SIZE_MISMATCH;
+		error("extent item at bytenr %llu slot %d has wrong size",
+			eb->start, slot);
 		goto out;
 	}
 
 	/* Now check every backref in this extent item */
-next:
 	iref = (struct btrfs_extent_inline_ref *)ptr;
 	type = btrfs_extent_inline_ref_type(eb, iref);
 	offset = btrfs_extent_inline_ref_offset(eb, iref);
@@ -10773,8 +10780,7 @@ next:
 	}
 
 	ptr += btrfs_extent_inline_ref_size(type);
-	if (ptr < end)
-		goto next;
+	goto next;
 
 out:
 	return err;
-- 
2.11.0




  parent reply	other threads:[~2017-01-23  9:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23  9:13 [PATCH 0/9] Lowmem mode fsck fixes with fsck-tests framework update Qu Wenruo
2017-01-23  9:13 ` [PATCH 1/9] btrfs-progs: lowmem check: Fix wrong block group check when search slot points to slot beyong leaf Qu Wenruo
2017-01-23  9:13 ` [PATCH 2/9] btrfs-progs: fsck-test: Add test image for lowmem mode block group false alert Qu Wenruo
2017-01-23  9:13 ` [PATCH 3/9] btrfs-progs: fsck: Output verbose error when fsck found a bug Qu Wenruo
2017-01-23  9:13 ` [PATCH 4/9] btrfs-progs: lowmem check: Fix false alert in checking data extent pointing to prealloc extent Qu Wenruo
2017-01-23  9:13 ` Qu Wenruo [this message]
2017-01-23  9:13 ` [PATCH 6/9] btrfs-progs: tests: Move fsck-tests/015 to fuzz tests Qu Wenruo
2017-01-23  9:13 ` [PATCH 7/9] btrfs-progs: fsck-tests: Make 013 compatible with lowmem mode Qu Wenruo
2017-01-23  9:13 ` [PATCH 8/8] btrfs-progs: fsck: Fix lowmem mode override to allow it skip repair work Qu Wenruo
2017-01-23  9:13 ` [PATCH 8/9] btrfs-progs: fsck-tests: Add new test case for partly written prealloc extent Qu Wenruo
2017-01-23  9:13 ` [PATCH 9/9] btrfs-progs: fsck: Fix lowmem mode override to allow it skip repair work Qu Wenruo
2017-01-24 16:54 ` [PATCH 0/9] Lowmem mode fsck fixes with fsck-tests framework update Christoph Anton Mitterer
2017-01-25  0:44   ` Qu Wenruo
2017-01-25  0:46     ` Christoph Anton Mitterer
2017-01-25  4:16       ` Qu Wenruo
2017-01-25  4:40         ` Christoph Anton Mitterer
2017-01-26  2:50         ` Christoph Anton Mitterer
2017-01-26  3:10           ` Qu Wenruo
2017-01-26  3:30             ` Christoph Anton Mitterer
2017-01-26 23:31             ` Christoph Anton Mitterer
2017-01-29  4:27               ` Qu Wenruo
2017-01-30  3:07                 ` Christoph Anton Mitterer
2017-02-01  1:06                   ` Qu Wenruo
2017-02-01 22:03                     ` Christoph Anton Mitterer
2017-02-02  0:25                       ` Qu Wenruo
2017-02-02  2:12                         ` Qu Wenruo
     [not found]                           ` <1486098502.7443.3.camel@lmu.de>
2017-02-03  6:20                             ` Qu Wenruo
2017-02-03 23:01                               ` Christoph Anton Mitterer
2017-02-06  1:25                                 ` Qu Wenruo

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=20170123091359.21390-6-quwenruo@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=calestyo@scientia.net \
    --cc=chris@colorremedies.com \
    --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.