linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 10/12] Btrfs-progs: deal with mismatch index between dir index and inode ref
Date: Fri, 10 Oct 2014 16:57:15 -0400	[thread overview]
Message-ID: <1412974637-31334-11-git-send-email-jbacik@fb.com> (raw)
In-Reply-To: <1412974637-31334-1-git-send-email-jbacik@fb.com>

Sometimes we have a dir index and an inode ref that don't agree on the index.
In this case just assume that the inode ref is the ultimate authority on the
subject and delete the dir index.  This means we have to not reset index if we
find a mismatched inode ref to make sure we delete the right dir index.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 cmds-check.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmds-check.c b/cmds-check.c
index ca890cc..80fa244 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -608,9 +608,10 @@ static int add_inode_backref(struct cache_tree *inode_cache,
 			backref->errors |= REF_ERR_DUP_INODE_REF;
 		if (backref->found_dir_index && backref->index != index)
 			backref->errors |= REF_ERR_INDEX_UNMATCH;
+		else
+			backref->index = index;
 
 		backref->ref_type = itemtype;
-		backref->index = index;
 		backref->found_inode_ref = 1;
 	} else {
 		BUG_ON(1);
@@ -1654,8 +1655,10 @@ static int repair_inode_backrefs(struct btrfs_root *root,
 		if (rec->ino == root_dirid && backref->index == 0)
 			continue;
 
-		if (delete && backref->found_dir_index &&
-		    !backref->found_inode_ref) {
+		if (delete &&
+		    ((backref->found_dir_index && !backref->found_inode_ref) ||
+		     (backref->found_dir_index && backref->found_inode_ref &&
+		      backref->errors & REF_ERR_INDEX_UNMATCH))) {
 			ret = delete_dir_index(root, inode_cache, rec, backref);
 			if (ret)
 				break;
-- 
1.8.3.1


  parent reply	other threads:[~2014-10-10 20:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 20:57 Btrfs-progs: fix horrible things Josef Bacik
2014-10-10 20:57 ` [PATCH 01/12] Btrfs-progs: repair missing dir index Josef Bacik
2014-10-10 20:57 ` [PATCH 02/12] Btrfs-progs: pull back backref.c and fix it up Josef Bacik
2014-10-10 20:57 ` [PATCH 03/12] Btrfs-progs: break out rbtree util functions Josef Bacik
2014-10-10 20:57 ` [PATCH 04/12] Btrfs-progs: update rbtree libs Josef Bacik
2014-10-10 20:57 ` [PATCH 05/12] Btrfs-progs: lookup all roots that point to a corrupt block Josef Bacik
2014-10-10 20:57 ` [PATCH 06/12] Btrfs-progs: reset chunk state if we restart check Josef Bacik
2014-10-10 20:57 ` [PATCH 07/12] Btrfs-progs: re-search tree root if it changes Josef Bacik
2014-10-10 20:57 ` [PATCH 08/12] Btrfs-progs: delete bogus dir indexes Josef Bacik
2014-10-10 20:57 ` [PATCH 09/12] Btrfs-progs: add a dummy backref if our location is wrong Josef Bacik
2014-10-10 20:57 ` Josef Bacik [this message]
2014-10-10 20:57 ` [PATCH 11/12] Btrfs-progs: add ability to corrupt dir items Josef Bacik

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=1412974637-31334-11-git-send-email-jbacik@fb.com \
    --to=jbacik@fb.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).