diff options
author | Filipe Manana <fdmanana@suse.com> | 2022-10-11 13:17:04 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-12-05 18:00:39 +0100 |
commit | b629685803bc0cefbbd29240ea28d57d8a17bcbc (patch) | |
tree | e344bf7703df90a54595612e0f9b6b3efcb8413d /fs | |
parent | 84a7949d409753c90dc3477b8cfc18e983b09078 (diff) |
btrfs: remove roots ulist when checking data extent sharedness
Currently btrfs_is_data_extent_shared() is passing a ulist for the roots
argument of find_parent_nodes(), however it does not use that ulist for
anything and for this context that list always ends up with at most one
element.
Since find_parent_nodes() is able to deal with a NULL ulist for its roots
argument, make btrfs_is_data_extent_shared() pass it NULL and avoid the
burden of allocating memory for the unnused roots ulist, initializing it,
releasing it and allocating one struct ulist_node for it during the call
to find_parent_nodes().
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/backref.c | 6 | ||||
-rw-r--r-- | fs/btrfs/backref.h | 1 |
2 files changed, 1 insertions, 6 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 4caff3052da7..4d8573fa75b4 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1664,7 +1664,6 @@ struct btrfs_backref_share_check_ctx *btrfs_alloc_backref_share_check_ctx(void) return NULL; ulist_init(&ctx->refs); - ulist_init(&ctx->roots); return ctx; } @@ -1675,7 +1674,6 @@ void btrfs_free_backref_share_ctx(struct btrfs_backref_share_check_ctx *ctx) return; ulist_release(&ctx->refs); - ulist_release(&ctx->roots); kfree(ctx); } @@ -1718,7 +1716,6 @@ int btrfs_is_data_extent_shared(struct btrfs_inode *inode, u64 bytenr, }; int level; - ulist_init(&ctx->roots); ulist_init(&ctx->refs); trans = btrfs_join_transaction_nostart(root); @@ -1742,7 +1739,7 @@ int btrfs_is_data_extent_shared(struct btrfs_inode *inode, u64 bytenr, bool cached; ret = find_parent_nodes(trans, fs_info, bytenr, elem.seq, &ctx->refs, - &ctx->roots, NULL, &shared, false); + NULL, NULL, &shared, false); if (ret == BACKREF_FOUND_SHARED) { /* this is the only condition under which we return 1 */ ret = 1; @@ -1810,7 +1807,6 @@ int btrfs_is_data_extent_shared(struct btrfs_inode *inode, u64 bytenr, up_read(&fs_info->commit_root_sem); } out: - ulist_release(&ctx->roots); ulist_release(&ctx->refs); return ret; } diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h index 8da0ba6b94a4..5f468f0defda 100644 --- a/fs/btrfs/backref.h +++ b/fs/btrfs/backref.h @@ -26,7 +26,6 @@ struct btrfs_backref_shared_cache_entry { struct btrfs_backref_share_check_ctx { /* Ulists used during backref walking. */ struct ulist refs; - struct ulist roots; /* * A path from a root to a leaf that has a file extent item pointing to * a given data extent should never exceed the maximum b+tree height. |