Commit 94ad29d2 authored by Zhao Lei's avatar Zhao Lei Committed by Greg Kroah-Hartman

btrfs: reada: Fix in-segment calculation for reada

commit 50378530 upstream.

reada_zone->end is end pos of segment:
 end = start + cache->key.offset - 1;

So we need to use "<=" in condition to judge is a pos in the
segment.

The problem happened rearly, because logical pos rarely pointed
to last 4k of a blockgroup, but we need to fix it to make code
right in logic.
Signed-off-by: default avatarZhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e23744bf
...@@ -265,7 +265,7 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info, ...@@ -265,7 +265,7 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
spin_unlock(&fs_info->reada_lock); spin_unlock(&fs_info->reada_lock);
if (ret == 1) { if (ret == 1) {
if (logical >= zone->start && logical < zone->end) if (logical >= zone->start && logical <= zone->end)
return zone; return zone;
spin_lock(&fs_info->reada_lock); spin_lock(&fs_info->reada_lock);
kref_put(&zone->refcnt, reada_zone_release); kref_put(&zone->refcnt, reada_zone_release);
...@@ -679,7 +679,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, ...@@ -679,7 +679,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info,
*/ */
ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re, ret = radix_tree_gang_lookup(&dev->reada_extents, (void **)&re,
dev->reada_next >> PAGE_CACHE_SHIFT, 1); dev->reada_next >> PAGE_CACHE_SHIFT, 1);
if (ret == 0 || re->logical >= dev->reada_curr_zone->end) { if (ret == 0 || re->logical > dev->reada_curr_zone->end) {
ret = reada_pick_zone(dev); ret = reada_pick_zone(dev);
if (!ret) { if (!ret) {
spin_unlock(&fs_info->reada_lock); spin_unlock(&fs_info->reada_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment