From: Filipe Manana <fdmanana@gmail.com>
To: Liu Bo <bo.li.liu@oracle.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
David Sterba <dsterba@suse.cz>, Filipe Manana <fdmanana@suse.com>,
Jeff Mahoney <jeffm@suse.com>
Subject: Re: [PATCH v2] Btrfs: fix BUG_ON in btrfs_mark_buffer_dirty
Date: Thu, 24 Nov 2016 09:56:19 +0000 [thread overview]
Message-ID: <CAL3q7H7ideJggLC_q1ODGYRQx8A3k5DHW+b0cQBHPkAGaaApfA@mail.gmail.com> (raw)
In-Reply-To: <1479938294-3282-1-git-send-email-bo.li.liu@oracle.com>
On Wed, Nov 23, 2016 at 9:58 PM, Liu Bo <bo.li.liu@oracle.com> wrote:
> This can only happen with CONFIG_BTRFS_FS_CHECK_INTEGRITY=y.
>
> Commit 1ba98d0 ("Btrfs: detect corruption when non-root leaf has zero item")
> assumes that a leaf is its root when leaf->bytenr == btrfs_root_bytenr(root),
> however, we should not use btrfs_root_bytenr(root) since it's mainly got
> updated during committing transaction. So the check can fail when doing
> COW on this leaf while it is a root.
>
> This changes to use "if (leaf == btrfs_root_node(root))" instead, just like
> how we check whether leaf is a root in __btrfs_cow_block().
>
> Fixes: 1ba98d086fe3 (Btrfs: detect corruption when non-root leaf has zero item)
> Cc: stable@vger.kernel.org # 4.8+
> Reported-by: Jeff Mahoney <jeffm@suse.com>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Thanks Bo!
> ---
> v2: Tag itself for stable.
>
> fs/btrfs/disk-io.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 9367c31..b401e6d 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -572,13 +572,17 @@ static noinline int check_leaf(struct btrfs_root *root,
> * open_ctree() some roots has not yet been set up.
> */
> if (!IS_ERR_OR_NULL(check_root)) {
> + struct extent_buffer *eb;
> +
> + eb = btrfs_root_node(check_root);
> /* if leaf is the root, then it's fine */
> - if (leaf->start !=
> - btrfs_root_bytenr(&check_root->root_item)) {
> + if (leaf != eb) {
> CORRUPT("non-root leaf's nritems is 0",
> - leaf, root, 0);
> + leaf, check_root, 0);
> + free_extent_buffer(eb);
> return -EIO;
> }
> + free_extent_buffer(eb);
> }
> return 0;
> }
> --
> 2.5.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Filipe David Manana,
"People will forget what you said,
people will forget what you did,
but people will never forget how you made them feel."
prev parent reply other threads:[~2016-11-24 9:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-23 21:58 [PATCH v2] Btrfs: fix BUG_ON in btrfs_mark_buffer_dirty Liu Bo
2016-11-24 9:56 ` Filipe Manana [this message]
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=CAL3q7H7ideJggLC_q1ODGYRQx8A3k5DHW+b0cQBHPkAGaaApfA@mail.gmail.com \
--to=fdmanana@gmail.com \
--cc=bo.li.liu@oracle.com \
--cc=dsterba@suse.cz \
--cc=fdmanana@suse.com \
--cc=jeffm@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).