Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3467978imu; Sun, 11 Nov 2018 15:47:39 -0800 (PST) X-Google-Smtp-Source: AJdET5eR7kvQbItgrHrYN0gUp8IXL9D8qecYDTPVLFbeE8uXkc/9wwxlnuuQrwXeZm42MbP+5JDw X-Received: by 2002:a63:1d62:: with SMTP id d34-v6mr15839815pgm.180.1541980059569; Sun, 11 Nov 2018 15:47:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541980059; cv=none; d=google.com; s=arc-20160816; b=Y2v8SDNEjSxnHuCpwLrgwz8RKIjYiEgPhjH5HUBjLWZjWhFlitdsxy8eC+YneBlD5I 5OpkY98f8W20USlePufOth7kj1aDpYcyEj2VkBafBiG6B9lRWqijqXc9LeyKbomDK7mZ QW9kq7rKAWgmI4Z/vLByQgGhiMW6j6JM6iLBqkuA4WbUTiVZ4AkodZ/s6MF5HU6fb1s9 xtZqhjc0nVQPC2vnC/nP7hoDB61Hw3rXAtmIZyWHYqqLJqCX0/Qb2Lbwa3KcJ6jdf60L FveYe+ypJUCfhXF9bdCaCX5l6tqwrq9214qiireyDKfy9dzH2Ft6oxLtzgaiwDar3uec qy8Q== 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=ZhfGEzxgR+rYT7hTPEDr2YV6d5EuMH70sC6vhYqFbE4=; b=g7uU8azMDteDES4IBQAx5DLJvBcd0dvK3klLBsFDcrBx4roHrUfPFBF3tLyFxFQSVo Lk5w3NPzMmJvmmVySrGqNPs59d3d8dJqG/DqLs7krfxMDvkBYMXnUcZY1lkPnuILoVBd N6HS2n4vyVOEgDlYSIhB6zrDf3rvNGgTHcIOxKg491poVVz9qGUHt0n1dJD0b660cp+u E1mhp09q2LbKTbAxjs+P1+ZnlorwbPWB5KjRbEOYvLlYSyVLSCNuOdRFx8lNE0HVrqDD HCFZ56wM0K69j8OvDHG9Gp25NPZiBE6sjdkugv0mL+9FWa7on0Ig17B3fwNOCkzj9Xmk w0cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="xjRihrE/"; 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 r14si4805855pgh.39.2018.11.11.15.47.24; Sun, 11 Nov 2018 15:47:39 -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="xjRihrE/"; 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 S1733201AbeKLISu (ORCPT + 99 others); Mon, 12 Nov 2018 03:18:50 -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 S1730142AbeKLISs (ORCPT ); Mon, 12 Nov 2018 03:18:48 -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 E4979223D1; Sun, 11 Nov 2018 22:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975333; bh=w4rKHWGXup3Oh9b5ePfbBWudPuVEeSJoOQJLlywvDqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xjRihrE/XQ1G5OAE0b+BOOs8Eudhyg/5PX6YwrSvbA2csmZzFs6z48b4KWIctWaPs axmfBLiHBBIX2nMVj30Gi5pCYnJamBFh9FyIJB6lMd6y0hKODndLUqFXsH1IkLr1EU /IpBed4zzoFVvi0jBqpANSVPa7bFeOZkh5YBYw2g= 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 348/361] btrfs: reset max_extent_size properly Date: Sun, 11 Nov 2018 14:21:35 -0800 Message-Id: <20181111221701.304788779@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 21a94f7acf0f748599ea552af5d9ee7d7e41c72f upstream. If we use up our block group before allocating a new one we'll easily get a max_extent_size that's set really really low, which will result in a lot of fragmentation. We need to make sure we're resetting the max_extent_size when we add a new chunk or add new space. CC: stable@vger.kernel.org # 4.4+ 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 | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4530,6 +4530,7 @@ static int do_chunk_alloc(struct btrfs_t goto out; } else { ret = 1; + space_info->max_extent_size = 0; } space_info->force_alloc = CHUNK_ALLOC_NO_FORCE; @@ -6431,6 +6432,7 @@ static int btrfs_free_reserved_bytes(str space_info->bytes_readonly += num_bytes; cache->reserved -= num_bytes; space_info->bytes_reserved -= num_bytes; + space_info->max_extent_size = 0; if (delalloc) cache->delalloc_bytes -= num_bytes;