summaryrefslogtreecommitdiff
path: root/check/mode-lowmem.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2018-01-17 13:17:08 +0800
committerDavid Sterba <dsterba@suse.com>2018-05-07 20:14:11 +0200
commita5f0e46ac37f0d8de88a7af8fbb541129d94c27c (patch)
tree28fc243b251e8ddd616893b9e77c2682a0625cc4 /check/mode-lowmem.c
parentf7fc27cb20924cc340a2a522655969253dd97ae9 (diff)
btrfs-progs: check: lowmem: Remove corupted link before readding correct link
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-inserting. This should solve the duplicated DIR_INDEX problem in old lowmem mode repair. Reported-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'check/mode-lowmem.c')
-rw-r--r--check/mode-lowmem.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index bfe45aba..5e1d6b2a 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -635,6 +635,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;