summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/reada.c
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-12-18 21:48:48 +0800
committerDavid Sterba <dsterba@suse.com>2016-02-16 13:21:45 +0100
commitc37f49c7ef317fb8043fd28594d1e5d728a1ef89 (patch)
tree1a665e48696503f004fbeae82c2cb7de48e2b977 /fs/btrfs/reada.c
parent503785306d182ab624a2232856ef8ab503ee85f9 (diff)
downloadlinux-c37f49c7ef317fb8043fd28594d1e5d728a1ef89.tar.bz2
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: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/reada.c')
-rw-r--r--fs/btrfs/reada.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index 49b3fb73ffbf..74480809be76 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -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);
+ return zone;
}
+ spin_unlock(&fs_info->reada_lock);
+
cache = btrfs_lookup_block_group(fs_info, logical);
if (!cache)
return NULL;