Skip to content

Commit

Permalink
btrfs: backref, only search backref entries from leaves of the same root
Browse files Browse the repository at this point in the history
We could have some nodes/leaves in subvolume whose owner are not the
that subvolume. In this way, when we resolve normal backrefs of that
subvolume, we should avoid collecting those references from these blocks.

Reviewed-by: Josef Bacik <[email protected]>
Reviewed-by: Johannes Thumshirn <[email protected]>
Signed-off-by: ethanwu <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
ethanwu-syno authored and kdave committed Mar 23, 2020
1 parent ed58f2e commit cfc0eed
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions fs/btrfs/backref.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,14 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,
* slot == nritems.
* 2. We are searching for normal backref but bytenr of this leaf
* matches shared data backref
* 3. The leaf owner is not equal to the root we are searching
*
* For these cases, go to the next leaf before we continue.
*/
eb = path->nodes[0];
if (path->slots[0] >= btrfs_header_nritems(eb) ||
is_shared_data_backref(preftrees, eb->start)) {
is_shared_data_backref(preftrees, eb->start) ||
ref->root_id != btrfs_header_owner(eb)) {
if (time_seq == SEQ_LAST)
ret = btrfs_next_leaf(root, path);
else
Expand All @@ -466,9 +469,12 @@ static int add_all_parents(struct btrfs_root *root, struct btrfs_path *path,

/*
* We are searching for normal backref but bytenr of this leaf
* matches shared data backref.
* matches shared data backref, OR
* the leaf owner is not equal to the root we are searching for
*/
if (slot == 0 && is_shared_data_backref(preftrees, eb->start)) {
if (slot == 0 &&
(is_shared_data_backref(preftrees, eb->start) ||
ref->root_id != btrfs_header_owner(eb))) {
if (time_seq == SEQ_LAST)
ret = btrfs_next_leaf(root, path);
else
Expand Down

0 comments on commit cfc0eed

Please sign in to comment.