summaryrefslogtreecommitdiff
path: root/check/mode-lowmem.c
diff options
context:
space:
mode:
authorSu Yue <suy.fnst@cn.fujitsu.com>2018-02-08 11:27:22 +0800
committerDavid Sterba <dsterba@suse.com>2018-06-07 16:32:03 +0200
commitcb1fbe71ae88fc307b99f9595fc9e7d65974f75f (patch)
treefdc3d05cde7154d350844021fef562f41ecae8df /check/mode-lowmem.c
parentbbf1e8a400d73b5ff2047a584b79db9d3392dc5c (diff)
btrfs-progs: check: lowmem: assign parent early in repair_extent_data_item
The variable @eb is assigned to leaf in fs_tree before insertion of backref. It will cause wrong parent of new inserted backref. Set @parent at beginning to fix the problem. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-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.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 894c42d1..12a88974 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -2535,6 +2535,11 @@ static int repair_extent_data_item(struct btrfs_trans_handle *trans,
extent_offset = btrfs_file_extent_offset(eb, fi);
offset = file_offset - extent_offset;
+ if (nrefs->full_backref[0])
+ parent = btrfs_header_bytenr(eb);
+ else
+ parent = 0;
+
/* now repair only adds backref */
if ((err & BACKREF_MISSING) == 0)
return err;
@@ -2576,11 +2581,6 @@ static int repair_extent_data_item(struct btrfs_trans_handle *trans,
btrfs_release_path(&path);
}
- if (nrefs->full_backref[0])
- parent = btrfs_header_bytenr(eb);
- else
- parent = 0;
-
ret = btrfs_inc_extent_ref(trans, root, disk_bytenr, num_bytes, parent,
root->objectid,
parent ? BTRFS_FIRST_FREE_OBJECTID : fi_key.objectid,