btrfs: fix unbalanced unlock of mapping_tree_lock
authorNaohiro Aota <naohiro.aota@wdc.com>
Thu, 21 Dec 2023 16:46:16 +0000 (01:46 +0900)
committerDavid Sterba <dsterba@suse.com>
Fri, 12 Jan 2024 00:59:59 +0000 (01:59 +0100)
The error path of btrfs_get_chunk_map() releases
fs_info->mapping_tree_lock. But, it is taken and released in
btrfs_find_chunk_map(). So, there is no need to do so.

Fixes: 7dc66abb5a47 ("btrfs: use a dedicated data structure for chunk maps")
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/volumes.c

index 4c32497311d2ff6ba28fc9ac5ba8dd5b8f835a66..d67785be2c778c6611d639dcbdcffffec4c513c2 100644 (file)
@@ -3087,7 +3087,6 @@ struct btrfs_chunk_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info,
        map = btrfs_find_chunk_map(fs_info, logical, length);
 
        if (unlikely(!map)) {
-               read_unlock(&fs_info->mapping_tree_lock);
                btrfs_crit(fs_info,
                           "unable to find chunk map for logical %llu length %llu",
                           logical, length);
@@ -3095,7 +3094,6 @@ struct btrfs_chunk_map *btrfs_get_chunk_map(struct btrfs_fs_info *fs_info,
        }
 
        if (unlikely(map->start > logical || map->start + map->chunk_len <= logical)) {
-               read_unlock(&fs_info->mapping_tree_lock);
                btrfs_crit(fs_info,
                           "found a bad chunk map, wanted %llu-%llu, found %llu-%llu",
                           logical, logical + length, map->start,