Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c37f49c7 authored by Zhao Lei's avatar Zhao Lei Committed by David Sterba
Browse files

btrfs: reada: reduce additional fs_info->reada_lock in reada_find_zone



We can avoid additional locking-acquirment and one pair of
kref_get/put by combine two condition.

Signed-off-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 50378530
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -260,18 +260,14 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
	spin_lock(&fs_info->reada_lock);
	ret = radix_tree_gang_lookup(&dev->reada_zones, (void **)&zone,
				     logical >> PAGE_CACHE_SHIFT, 1);
	if (ret == 1)
	if (ret == 1 && logical >= zone->start && logical <= zone->end) {
		kref_get(&zone->refcnt);
		spin_unlock(&fs_info->reada_lock);

	if (ret == 1) {
		if (logical >= zone->start && logical <= zone->end)
		return zone;
		spin_lock(&fs_info->reada_lock);
		kref_put(&zone->refcnt, reada_zone_release);
		spin_unlock(&fs_info->reada_lock);
	}

	spin_unlock(&fs_info->reada_lock);

	cache = btrfs_lookup_block_group(fs_info, logical);
	if (!cache)
		return NULL;