Skip to content

Commit 04a7090

Browse files
fdmananakdave
authored andcommitted
btrfs: send: index backref cache by node number instead of by sector number
We now have a nodesize_bits member in fs_info so we can index an extent buffer in the backref cache by node number instead of by sector number. While this allows for a denser index space with the possibility of using less maple tree nodes, in practice it's unlikely to hit such benefits since we currently limit the maximum number of keys in the cache to 128, so unless all extent buffers are contiguous we are unlikely to see a memory usage reduction in the backing maple tree due to less nodes. Nevertheless it doesn't cost anything to index by node number and it's more logical. Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent f90f173 commit 04a7090

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/btrfs/send.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ static bool lookup_backref_cache(u64 leaf_bytenr, void *ctx,
13881388
struct backref_ctx *bctx = ctx;
13891389
struct send_ctx *sctx = bctx->sctx;
13901390
struct btrfs_fs_info *fs_info = sctx->send_root->fs_info;
1391-
const u64 key = leaf_bytenr >> fs_info->sectorsize_bits;
1391+
const u64 key = leaf_bytenr >> fs_info->nodesize_bits;
13921392
struct btrfs_lru_cache_entry *raw_entry;
13931393
struct backref_cache_entry *entry;
13941394

@@ -1443,7 +1443,7 @@ static void store_backref_cache(u64 leaf_bytenr, const struct ulist *root_ids,
14431443
if (!new_entry)
14441444
return;
14451445

1446-
new_entry->entry.key = leaf_bytenr >> fs_info->sectorsize_bits;
1446+
new_entry->entry.key = leaf_bytenr >> fs_info->nodesize_bits;
14471447
new_entry->entry.gen = 0;
14481448
new_entry->num_roots = 0;
14491449
ULIST_ITER_INIT(&uiter);

0 commit comments

Comments
 (0)