Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3468816imu; Sun, 11 Nov 2018 15:48:56 -0800 (PST) X-Google-Smtp-Source: AJdET5c+zKjDR4JF422IFpWP4EtC97THJio7I/0Wtohu7K622gNvjQxApfBiQR5XhfRSJaNEolaM X-Received: by 2002:a17:902:20eb:: with SMTP id v40-v6mr8284961plg.234.1541980136046; Sun, 11 Nov 2018 15:48:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980136; cv=none; d=google.com; s=arc-20160816; b=0OozZbKaAJk2Ecfu9GF2FbG1D8anXewa+OcAUsPOR3fBqma+dlaipln/yTDaVDaKhy PuDIbfqXCOWLSZ3RnfjgeXFWl59zStLhW4n5FhxKjEt5xq9Jny5BYBZ6HDFCV5V62+t3 PD9JvPKjT2aV6jyWiKgVJF3GQ2bf/DPq1WKslkS4DYeP/Hyq9ASzekfuZAqIN9mtOzd5 yXn2lr8vEMMn34v2HV5rTUlkplK8hQ3hjw9I6CJssQo5AcCGFfK5ko0W0Z15L1qYc5WO gd+/HN6UXAkxesFfM+wcehy/dJCr1tKkT7i9mYoos+2RclXFKwz9PwzmAUwHwIR1sQor lUMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1r+TygAP/r0VQsNHYpc6It6x4P76D7ap6kchg0j2UlU=; b=PugA9XM5m2WP+k6E/1LkiW3/5YZni9Rcw/IWls5cD/FALU10UYaiSaGqJD7cWvPEx8 KY6Q79+YVk7JqPz8nvdeO2Iw8HGuQhg6UazcTUyCChOmJAUnycZqcR0xwOV6xJfSf1rB fVxVfrq4OkCEtKsXT6tfX2pUR3SndqzYlZ7z8+Kw5EaNEPpdzM/3yuT4irxbABx967FZ jOJo46a2kCYPUWOMkSgtgzVEKxECK74ixQBUJgO2V9xcPPW9n1cpv67CPHrrixHiBy1t k/4kSWBnp7LQRr4pHFgJAX2CENdAC+BspWzdDYIv1bBwkBZHXrF62LScBXVk3dnCUBZn tddA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dqz0zJ3O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b65-v6si16289836plb.152.2018.11.11.15.48.41; Sun, 11 Nov 2018 15:48:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dqz0zJ3O; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387522AbeKLJh3 (ORCPT + 99 others); Mon, 12 Nov 2018 04:37:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:39292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733176AbeKLISt (ORCPT ); Mon, 12 Nov 2018 03:18:49 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9AE0D21582; Sun, 11 Nov 2018 22:28:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975333; bh=l+4G7udtpBLJaaPhSe2a2226TUYcXdtPjyVzy44caCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dqz0zJ3OiYHPID+hIKM6KliPUWM5voOQ1/yhXS2dSBIpPaCMMP07ksXdoM+i4wj2J zr31DZErhoLDpOIOpBrHZJEcmkgwRoSa5tdMhXHc/TQznTNMbuWXhtdZkWmIt6hn51 toWWnqEFaasFLJNW3wNqnUxJzN8cgLSE1CM7yp6U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Filipe Manana , Josef Bacik , David Sterba Subject: [PATCH 4.19 350/361] btrfs: dont use ctl->free_space for max_extent_size Date: Sun, 11 Nov 2018 14:21:37 -0800 Message-Id: <20181111221701.463651122@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik commit fb5c39d7a887108087de6ff93d3f326b01b4ef41 upstream. max_extent_size is supposed to be the largest contiguous range for the space info, and ctl->free_space is the total free space in the block group. We need to keep track of these separately and _only_ use the max_free_space if we don't have a max_extent_size, as that means our original request was too large to search any of the block groups for and therefore wouldn't have a max_extent_size set. CC: stable@vger.kernel.org # 4.14+ Reviewed-by: Filipe Manana Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/extent-tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7230,6 +7230,7 @@ static noinline int find_free_extent(str struct btrfs_block_group_cache *block_group = NULL; u64 search_start = 0; u64 max_extent_size = 0; + u64 max_free_space = 0; u64 empty_cluster = 0; struct btrfs_space_info *space_info; int loop = 0; @@ -7525,8 +7526,8 @@ unclustered_alloc: spin_lock(&ctl->tree_lock); if (ctl->free_space < num_bytes + empty_cluster + empty_size) { - if (ctl->free_space > max_extent_size) - max_extent_size = ctl->free_space; + max_free_space = max(max_free_space, + ctl->free_space); spin_unlock(&ctl->tree_lock); goto loop; } @@ -7693,6 +7694,8 @@ loop: } out: if (ret == -ENOSPC) { + if (!max_extent_size) + max_extent_size = max_free_space; spin_lock(&space_info->lock); space_info->max_extent_size = max_extent_size; spin_unlock(&space_info->lock);