summaryrefslogtreecommitdiff
path: root/fs/btrfs/reada.c
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-12-31 17:57:52 +0300
committerDavid Sterba <dsterba@suse.com>2016-02-18 12:26:10 +0300
commita3f7fde24350a17a589c470265ac2d5a0e6f119f (patch)
tree6409a5427d9a6c9f16b1f65512858e3fae231cf8 /fs/btrfs/reada.c
parent97d5f0e63d78a48cef35349261f90d0d4266dc24 (diff)
downloadlinux-a3f7fde24350a17a589c470265ac2d5a0e6f119f.tar.xz
btrfs: reada: Move is_need_to_readahead contition earlier
Move is_need_to_readahead contition earlier to avoid useless loop to get relative data for readahead. 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.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c
index f0cf5f3b865a..b2f768a3174a 100644
--- a/fs/btrfs/reada.c
+++ b/fs/btrfs/reada.c
@@ -660,7 +660,6 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
u64 logical;
int ret;
int i;
- int need_kick = 0;
spin_lock(&fs_info->reada_lock);
if (dev->reada_curr_zone == NULL) {
@@ -696,6 +695,15 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
spin_unlock(&fs_info->reada_lock);
+ spin_lock(&re->lock);
+ if (re->scheduled_for || list_empty(&re->extctl)) {
+ spin_unlock(&re->lock);
+ reada_extent_put(fs_info, re);
+ return 0;
+ }
+ re->scheduled_for = dev;
+ spin_unlock(&re->lock);
+
/*
* find mirror num
*/
@@ -707,18 +715,8 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
}
logical = re->logical;
- spin_lock(&re->lock);
- if (!re->scheduled_for && !list_empty(&re->extctl)) {
- re->scheduled_for = dev;
- need_kick = 1;
- }
- spin_unlock(&re->lock);
-
reada_extent_put(fs_info, re);
- if (!need_kick)
- return 0;
-
atomic_inc(&dev->reada_in_flight);
ret = reada_tree_block_flagged(fs_info->extent_root, logical,
mirror_num, &eb);