All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: nborisov@suse.com, Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Subject: [PATCH v2 1/3] btrfs-progs: lowmem fsck: Remove corupted link before re-add correct link
Date: Fri, 19 Jan 2018 15:25:34 +0800	[thread overview]
Message-ID: <20180119072536.22286-2-wqu@suse.com> (raw)
In-Reply-To: <20180119072536.22286-1-wqu@suse.com>

For repair_ternary_lowmem() used in lowmem mode, if it found 1 of
DIR_INDEX/DIR_ITEM/INODE_REF missing, it will try to insert correct
link.

However for case like invalid type in DIR_INDEX, we should delete the
corrupted DIR_INDEX first before inserting the correct link.

This patch will remove the corrupted link before re-insert.
This should solve the duplicated DIR_INDEX problem in old lowmem mode
repair.

Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 cmds-check.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cmds-check.c b/cmds-check.c
index 7fc30da83ea1..f302724dd840 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -4997,6 +4997,10 @@ int repair_ternary_lowmem(struct btrfs_root *root, u64 dir_ino, u64 ino,
 		goto out;
 	}
 	if (stage == 1) {
+		ret = btrfs_unlink(trans, root, ino, dir_ino, index, name,
+				   name_len, 0);
+		if (ret)
+			goto out;
 		ret = btrfs_add_link(trans, root, ino, dir_ino, name, name_len,
 			       filetype, &index, 1, 1);
 		goto out;
-- 
2.15.1


  reply	other threads:[~2018-01-19  7:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19  7:25 [PATCH v2 0/3] Lowmem fsck repair to fix filetype mismatch Qu Wenruo
2018-01-19  7:25 ` Qu Wenruo [this message]
2018-01-19  7:40   ` [PATCH v2 1/3] btrfs-progs: lowmem fsck: Remove corupted link before re-add correct link Su Yue
2018-01-19  7:25 ` [PATCH v2 2/3] btrfs-progs: dir-item: Don't do extra filetype validaction check for btrfs_match_dir_item_name Qu Wenruo
2018-01-19  7:39   ` Su Yue
2018-01-19  7:38     ` Qu Wenruo
2018-01-19  8:07       ` Su Yue
2018-01-19  9:40   ` Nikolay Borisov
2018-01-19 10:03     ` Qu Wenruo
2018-01-19 10:21       ` Nikolay Borisov
2018-01-19 10:39         ` Qu Wenruo
2018-01-19 12:34           ` Nikolay Borisov
2018-01-22  5:45   ` [PATCH v2.1 " Qu Wenruo
2018-01-22  8:09     ` Nikolay Borisov
2018-01-19  7:25 ` [PATCH v2 3/3] btrfs-progs: dir-item: Make btrfs_delete_one_dir_name more robust to handle corrupted name len Qu Wenruo
2018-01-19  7:40   ` Su Yue
2018-01-19  9:43   ` Nikolay Borisov

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=20180119072536.22286-2-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    --cc=sebastian@breakpoint.cc \
    /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.