From: Miao Xie <miaox@cn.fujitsu.com>
To: Linux Btrfs <linux-btrfs@vger.kernel.org>
Subject: [PATCH V2 3/3] Btrfs-progs: fix unresolved ref root message
Date: Fri, 10 Aug 2012 16:54:11 +0800 [thread overview]
Message-ID: <5024CC33.2040901@cn.fujitsu.com> (raw)
btrfsck misinformed "unresolved ref root" message when there were several
snapshots in the file system. The patch(commit cfdd42686c70) tried to fix
this bug, but didn't fix it completely. If the metadata was stored in a
shared leaf of the tree, the problem would happen again. This patch fixes
it by another way, we don't check the relationship of the trees when we
traverse the fs/file tree, we just do the check when we merge the snapshot
records to the root cache.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
Changelog v1 -> v2:
- new patch.
---
btrfsck.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/btrfsck.c b/btrfsck.c
index bb1aa76..4e91769 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -857,13 +857,10 @@ static int process_dir_item(struct btrfs_root *root,
key->objectid, key->offset, namebuf,
len, filetype, key->type, error);
} else if (location.type == BTRFS_ROOT_ITEM_KEY) {
- u64 parent = root->objectid;
-
- if (is_child_root(root, parent, location.objectid))
- add_inode_backref(root_cache, location.objectid,
- key->objectid, key->offset,
- namebuf, len, filetype,
- key->type, error);
+ add_inode_backref(root_cache, location.objectid,
+ key->objectid, key->offset,
+ namebuf, len, filetype,
+ key->type, error);
} else {
fprintf(stderr, "warning line %d\n", __LINE__);
}
@@ -1489,6 +1486,9 @@ static int merge_root_recs(struct btrfs_root *root,
remove_cache_extent(src_cache, &node->cache);
free(node);
+ if (!is_child_root(root, root->objectid, rec->ino))
+ goto skip;
+
list_for_each_entry(backref, &rec->backrefs, list) {
BUG_ON(backref->found_inode_ref);
if (backref->found_dir_item)
@@ -1504,6 +1504,7 @@ static int merge_root_recs(struct btrfs_root *root,
backref->namelen, BTRFS_DIR_INDEX_KEY,
backref->errors);
}
+skip:
free_inode_rec(rec);
}
return 0;
--
1.7.6.5
reply other threads:[~2012-08-10 8:54 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=5024CC33.2040901@cn.fujitsu.com \
--to=miaox@cn.fujitsu.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).