linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH 06/11] btrfs-progs: backref: Allow backref walk to handle direct parent ref
Date: Wed, 22 Nov 2017 17:03:20 +0800	[thread overview]
Message-ID: <20171122090325.29458-7-wqu@suse.com> (raw)
In-Reply-To: <20171122090325.29458-1-wqu@suse.com>

[BUG]
Btrfs lowmem mode fails with the following ASSERT() on certain valid
image.
------
backref.c:466: __add_missing_keys: Assertion `ref->root_id` failed, value 0
------

[REASON]
Lowmem mode uses btrfs_find_all_roots() when walking down fs trees.

However if a tree block with only shared parent backref like below,
backref code from btrfs-progs doesn't handle it correct.
------
        item 72 key (604653731840 METADATA_ITEM 0) itemoff 13379 itemsize 60
                refs 4 gen 7198 flags TREE_BLOCK|FULL_BACKREF
                tree block skinny level 0
                shared block backref parent 604498477056
                shared block backref parent 604498460672
                shared block backref parent 604498444288
                shared block backref parent 604498411520
------

Such shared block ref is *direct* ref, which means we don't need to
solve its key, nor its rootid.

As the objective of backref walk is to find all direct parents until it
reaches tree root.
So for such direct ref, it should be pended to pref_stat->pending, other
than pending it to pref_stat->pending_missing_key.

[FIX]
For direct ref, pending it to pref_state->pending directly to solve the
problem.

Reported-by: Chris Murphy <chris@colorremedies.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 backref.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/backref.c b/backref.c
index 8615f6b8677a..27309e07a1e9 100644
--- a/backref.c
+++ b/backref.c
@@ -206,6 +206,9 @@ static int __add_prelim_ref(struct pref_state *prefstate, u64 root_id,
 	if (key) {
 		ref->key_for_search = *key;
 		head = &prefstate->pending;
+	} else if (parent) {
+		memset(&ref->key_for_search, 0, sizeof(ref->key_for_search));
+		head = &prefstate->pending;
 	} else {
 		memset(&ref->key_for_search, 0, sizeof(ref->key_for_search));
 		head = &prefstate->pending_missing_keys;
-- 
2.15.0


  parent reply	other threads:[~2017-11-22  9:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22  9:03 [PATCH 00/11] Lowmem mode btrfs fixes exposed by complex tree Qu Wenruo
2017-11-22  9:03 ` [PATCH 01/11] btrfs-progs: lowmem check: Fix regression which screws up extent allocator Qu Wenruo
2017-11-22  9:03 ` [PATCH 02/11] btrfs-progs: lowmem check: Fix NULL pointer access caused by large tree reloc tree Qu Wenruo
2017-11-22  9:03 ` [PATCH 03/11] btrfs-progs: lowmem check: Fix inlined data extent ref lookup Qu Wenruo
2017-11-22  9:03 ` [PATCH 04/11] btrfs-progs: lowmem check: Fix false backref lost warning for keyed extent data ref Qu Wenruo
2017-11-22  9:03 ` [PATCH 05/11] btrfs-progs: fsck-test: Introduce test case for false data extent backref lost Qu Wenruo
2017-11-22  9:03 ` Qu Wenruo [this message]
2017-11-22  9:03 ` [PATCH 07/11] btrfs-progs: lowmem check: Fix function call stack overflow caused by wrong tree reloc tree detection Qu Wenruo
2017-11-22  9:03 ` [PATCH 08/11] btrfs-progs: lowmem check: Fix false alerts for image with shared block ref only backref Qu Wenruo
2017-11-22  9:03 ` [PATCH 10/11] btrfs-progs: lowmem check: Fix false alerts of referencer count mismatch for snapshot Qu Wenruo
2017-11-22  9:03 ` [PATCH 11/11] btrfs-progs: fsck-tests: Introduce test case with keyed data backref with shared tree blocks Qu Wenruo
2017-11-24 14:46 ` [PATCH 00/11] Lowmem mode btrfs fixes exposed by complex tree David Sterba

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=20171122090325.29458-7-wqu@suse.com \
    --to=wqu@suse.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 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).