From patchwork Tue Sep 11 17:57:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10596091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E31914E5 for ; Tue, 11 Sep 2018 17:58:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A1DA29B9F for ; Tue, 11 Sep 2018 17:58:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EAE329BA1; Tue, 11 Sep 2018 17:58:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB7E829B9F for ; Tue, 11 Sep 2018 17:58:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728318AbeIKW7O (ORCPT ); Tue, 11 Sep 2018 18:59:14 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:37223 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728113AbeIKW7N (ORCPT ); Tue, 11 Sep 2018 18:59:13 -0400 Received: by mail-qt0-f196.google.com with SMTP id n6-v6so29179346qtl.4 for ; Tue, 11 Sep 2018 10:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sO92wt83JKp84WtpUJNNUQ+YWsKaOa8qungmNmikPJ0=; b=ey/SAXP7xAcwuWgIkiGROdjUtxYW+uVHdwSp13V9na+osuDUownDL92F3Offgpdqye bDompbfoTo+rLEcq8/80mVUmUVvIWOPWZyiSqYS+YdgUxT+0RLoSQHbFtE/A+Sq2bzfD 4MkFKvDFaPyqptyeUz21RRWfq1mdRwG5a1gjJAb6Ntk4s2ySOKyCUk0uTh7pYnWP+kW3 dMyjtCcRnyXaE2ri9L/6JV5Jyx/io2/QmfY6szkEd1YposnV/pNlOBA4K4GdsUoL3aGP Ix/CV+6ZvzIn2L+XjIRLsKfrTcBKxUVRu8e3AwHmQXFkYvM0j+Nh9EwhHjZYIfoG9Ij+ /iEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sO92wt83JKp84WtpUJNNUQ+YWsKaOa8qungmNmikPJ0=; b=TQyk/AfdBcHCC65ZQEdgY1Iwe1gjr58p1vqsplw/I+WXfLKhk+RQ/8dqf+esuroSCI 6f6U/zD3J46RFwQgZUlrR6tjaX5VGfakSKJATmmCgsAiRYP/VKE2KB36bjNpQjYUu3Ip pzPIV5FyJMKJptwDPhjKpih2BniPdr+b3f443ZG6rWKOm0Mkn6vLM6ZsV2P9NAv2lI94 BR1o5z7f4Qvgs9+YZT1smm5Z3QrjEWDyi1rGded6Wabz9+VeYmWUwAa1jpAynr1c0gV7 r/l37S5WV27jE/SHL9IWctupoxkxEvV0uieA+PSUBFkz4dFXfMGB4mFIxN+p/JR+qeF/ g+8w== X-Gm-Message-State: APzg51APxsSveqC1yE2OEUZ0Y21DMYmjQgTWAYjyAsTAkJ+WhN36aQt8 wDHUtCjhut9H1urK7kPuh21skA2o8mBGuw== X-Google-Smtp-Source: ANB0VdZpqeLNWfTWLhD/QBso+H9lplwH4djczdVvocnJb2GFOyPlxndDUgqXgW6rTnPUFRfXMCKoiw== X-Received: by 2002:a0c:c252:: with SMTP id w18-v6mr19742798qvh.183.1536688727336; Tue, 11 Sep 2018 10:58:47 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id f6-v6sm11745522qke.77.2018.09.11.10.58.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Sep 2018 10:58:46 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 20/36] btrfs: don't use ctl->free_space for max_extent_size Date: Tue, 11 Sep 2018 13:57:51 -0400 Message-Id: <20180911175807.26181-21-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180911175807.26181-1-josef@toxicpanda.com> References: <20180911175807.26181-1-josef@toxicpanda.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Josef Bacik 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. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e43834380ce6..ac7b740be4ff 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7484,6 +7484,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, 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; @@ -7779,8 +7780,8 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, 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; } @@ -7947,6 +7948,8 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, } 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);