The variable @eb is assigned to leaf in fs_tree before insertion of backref. It will causes wrong parent of new inserted backref. Set @parent in the begin solves the problem. Signed-off-by: Su Yue <suy.fnst@xxxxxxxxxxxxxx> --- cmds-check.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index ebede26cef01..1f06f0a0ea61 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -11938,6 +11938,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; @@ -11979,11 +11984,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, -- 2.15.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
