diff mbox series

[3/8] btrfs: mark sanity checks when getting chunk map as unlikely

Message ID 38d4c787bace59d3956c26089f21227db4d32bbd.1700573314.git.fdmanana@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: add a btrfs_chunk_map structure and preparatory cleanups | expand

Commit Message

Filipe Manana Nov. 21, 2023, 1:38 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

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.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/volumes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3b61c47306c0..9c4b52d29d6b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3002,14 +3002,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);