]> Git Repo - linux.git/commitdiff
btrfs: mark sanity checks when getting chunk map as unlikely
authorFilipe Manana <[email protected]>
Tue, 21 Nov 2023 13:38:34 +0000 (13:38 +0000)
committerDavid Sterba <[email protected]>
Fri, 15 Dec 2023 19:27:01 +0000 (20:27 +0100)
When getting a chunk map, at btrfs_get_chunk_map(), we do some sanity
checks to verify that we found an extent map and that it includes the
requested logical address. These are never expected to fail, so mark
them as unlikely to make it more clear as well as to allow a compiler
to generate more efficient code.

Reviewed-by: Josef Bacik <[email protected]>
Signed-off-by: Filipe Manana <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
fs/btrfs/volumes.c

index f627674b37db50bfd9f5e1149bb65d237e590f17..c66e1c6c0410f00bcaa0d915801f9a63d3737f2d 100644 (file)
@@ -3005,14 +3005,14 @@ struct extent_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info,
        em = lookup_extent_mapping(em_tree, logical, length);
        read_unlock(&em_tree->lock);
 
-       if (!em) {
+       if (unlikely(!em)) {
                btrfs_crit(fs_info,
                           "unable to find chunk map for logical %llu length %llu",
                           logical, length);
                return ERR_PTR(-EINVAL);
        }
 
-       if (em->start > logical || em->start + em->len <= logical) {
+       if (unlikely(em->start > logical || em->start + em->len <= logical)) {
                btrfs_crit(fs_info,
                           "found a bad chunk map, wanted %llu-%llu, found %llu-%llu",
                           logical, logical + length, em->start, em->start + em->len);
This page took 0.065677 seconds and 4 git commands to generate.