From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:38899 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756283AbcEEJn5 (ORCPT ); Thu, 5 May 2016 05:43:57 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C2805AC98 for ; Thu, 5 May 2016 09:43:55 +0000 (UTC) From: David Sterba To: stable@vger.kernel.org Subject: [PATCH 01/17] btrfs: reada: Fix in-segment calculation for reada Date: Thu, 5 May 2016 11:43:38 +0200 Message-Id: <1462441418-2409-1-git-send-email-dsterba@suse.com> In-Reply-To: <20160505094018.GA29353@twin.jikos.cz> References: <20160505094018.GA29353@twin.jikos.cz> Sender: stable-owner@vger.kernel.org List-ID: From: Zhao Lei 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: Zhao Lei Signed-off-by: David Sterba --- fs/btrfs/reada.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c index 619f92963e27..49b3fb73ffbf 100644 --- a/fs/btrfs/reada.c +++ b/fs/btrfs/reada.c @@ -265,7 +265,7 @@ static struct reada_zone *reada_find_zone(struct btrfs_fs_info *fs_info, spin_unlock(&fs_info->reada_lock); if (ret == 1) { - if (logical >= zone->start && logical < zone->end) + if (logical >= zone->start && logical <= zone->end) return zone; spin_lock(&fs_info->reada_lock); kref_put(&zone->refcnt, reada_zone_release); @@ -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, 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); if (!ret) { spin_unlock(&fs_info->reada_lock); -- 2.7.1