Skip to content

Commit 96dbcc0

Browse files
fdmananakdave
authored andcommitted
btrfs: add missing path cache update during fiemap
When looking the stored result for a cached path node, if the stored result is valid and has a value of true, we must update all the nodes for all levels below it with a result of true as well. This is necessary when moving from one leaf in the fs tree to the next one, as well as when moving from a node at any level to the next node at the same level. Currently this logic is missing as it was somehow forgotten by a recent patch with the subject: "btrfs: speedup checking for extent sharedness during fiemap". This adds the missing logic, which is the counter part to what we do when adding a shared node to the cache at store_backref_shared_cache(). Fixes: 12a824d ("btrfs: speedup checking for extent sharedness during fiemap") Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent cbddcc4 commit 96dbcc0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fs/btrfs/backref.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,6 +1557,19 @@ static bool lookup_backref_shared_cache(struct btrfs_backref_shared_cache *cache
15571557
return false;
15581558

15591559
*is_shared = entry->is_shared;
1560+
/*
1561+
* If the node at this level is shared, than all nodes below are also
1562+
* shared. Currently some of the nodes below may be marked as not shared
1563+
* because we have just switched from one leaf to another, and switched
1564+
* also other nodes above the leaf and below the current level, so mark
1565+
* them as shared.
1566+
*/
1567+
if (*is_shared) {
1568+
for (int i = 0; i < level; i++) {
1569+
cache->entries[i].is_shared = true;
1570+
cache->entries[i].gen = entry->gen;
1571+
}
1572+
}
15601573

15611574
return true;
15621575
}

0 commit comments

Comments
 (0)