Message ID | aa8da9743ec75d4438f5de49051834337133da10.1664808830.git.fdmanana@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: add missing path cache update during fiemap | expand |
On Mon, Oct 03, 2022 at 03:57:30PM +0100, fdmanana@kernel.org wrote: > From: Filipe Manana <fdmanana@suse.com> > > 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(). > > Signed-off-by: Filipe Manana <fdmanana@suse.com> Added to misc-next, thanks.
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index dce3a16996b9..3c0c1f626c75 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1557,6 +1557,19 @@ static bool lookup_backref_shared_cache(struct btrfs_backref_shared_cache *cache return false; *is_shared = entry->is_shared; + /* + * If the node at this level is shared, than all nodes below are also + * shared. Currently some of the nodes below may be marked as not shared + * because we have just switched from one leaf to another, and switched + * also other nodes above the leaf and below the current level, so mark + * them as shared. + */ + if (*is_shared) { + for (int i = 0; i < level; i++) { + cache->entries[i].is_shared = true; + cache->entries[i].gen = entry->gen; + } + } return true; }