]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: avoid redundant call to get inline ref type at check_committed_ref()
authorFilipe Manana <fdmanana@suse.com>
Mon, 9 Dec 2024 16:07:12 +0000 (16:07 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 13 Jan 2025 13:53:16 +0000 (14:53 +0100)
At check_committed_ref() we are calling btrfs_get_extent_inline_ref_type()
twice, once before we check if have an inline extent owner ref (for simple
qgroups) and then once again sometime after that check. This second call
is redundant when we have simple quotas disabled or we found an inline ref
that is not of the owner ref type. So avoid this second call unless we
have simple quotas enabled and found an owner ref, saving a function call
that does inline ref validation again.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index e81f4615ccdfe66d2831adace84c318f1528785e..00e137c48a9bc13f393f7d49422454e45ef9b0bc 100644 (file)
@@ -2352,6 +2352,7 @@ static noinline int check_committed_ref(struct btrfs_root *root,
        if (btrfs_fs_incompat(fs_info, SIMPLE_QUOTA) && type == BTRFS_EXTENT_OWNER_REF_KEY) {
                expected_size += btrfs_extent_inline_ref_size(BTRFS_EXTENT_OWNER_REF_KEY);
                iref = (struct btrfs_extent_inline_ref *)(iref + 1);
+               type = btrfs_get_extent_inline_ref_type(leaf, iref, BTRFS_REF_TYPE_DATA);
        }
 
        /* If extent item has more than 1 inline ref then it's shared */
@@ -2359,7 +2360,6 @@ static noinline int check_committed_ref(struct btrfs_root *root,
                goto out;
 
        /* If this extent has SHARED_DATA_REF then it's shared */
-       type = btrfs_get_extent_inline_ref_type(leaf, iref, BTRFS_REF_TYPE_DATA);
        if (type != BTRFS_EXTENT_DATA_REF_KEY)
                goto out;