Skip to content

Commit

Permalink
btrfs: reada: Move is_need_to_readahead contition earlier
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Zhao Lei authored and David Sterba committed Feb 18, 2016
1 parent 97d5f0e commit a3f7fde
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions fs/btrfs/reada.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
*/
Expand All @@ -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);
Expand Down

0 comments on commit a3f7fde

Please sign in to comment.