btrfs: reada: Add missed segment checking in reada_find_zone
authorZhao Lei <zhaolei@cn.fujitsu.com>
Fri, 18 Dec 2015 13:56:08 +0000 (21:56 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 16 Feb 2016 12:21:45 +0000 (13:21 +0100)
In rechecking zone-in-tree, we still need to check zone include
our logical address.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/reada.c

index 74480809be7681f7159a8228b8b9c3f6094316d4..7e5d4ac800d9461cdd75baea54dd90c48d82a41e 100644 (file)
@@ -303,8 +303,10 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info,
                kfree(zone);
                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);
+               else
+                       zone = NULL;
        }
        spin_unlock(&fs_info->reada_lock);