From patchwork Thu Aug 30 17:42:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582461 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 AD99017DE for ; Thu, 30 Aug 2018 17:43:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BCDF284DA for ; Thu, 30 Aug 2018 17:43:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9052928676; Thu, 30 Aug 2018 17:43:06 +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 EF1F7284DA for ; Thu, 30 Aug 2018 17:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727666AbeH3VqT (ORCPT ); Thu, 30 Aug 2018 17:46:19 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:38135 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727582AbeH3VqS (ORCPT ); Thu, 30 Aug 2018 17:46:18 -0400 Received: by mail-qt0-f193.google.com with SMTP id x7-v6so11304685qtk.5 for ; Thu, 30 Aug 2018 10:43:03 -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=R3qLQcqq+Qmk/oksZhxGWgtaSGsjsawR33dkWkJ6Sxg=; b=MeQqvyvNPVZS2/OGqJffhFWZ5nMEdMAxtxErVwrchDFi95zDM/wE9S5yuxXagoeM0h 0mKz/jdeTTidYsZkDAQbknK/Ou4Q0kMo3vQGDv6POYc49iMtAIxkOAXSmZySCpf7Jg+l kXPuwObPTq/pvuEp5IJa0RSnb3qc3U6P0HTWPAtqN72Rghk0ZV/5EK+O7iOxL1RQ+ddZ Rt8gjaaz0JUggY/g8xLDslrmywpIVpD3bB9lzXb6+8j7WS6G3T4GLzeeKfXpdUHCuiJk 0D09A2nBYyPbErs/0rTH2qIkgHlVgxXrP2mlvgAEyZefF3JMfU7Mi3gkK+W9DKSx8F12 RoxQ== 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=R3qLQcqq+Qmk/oksZhxGWgtaSGsjsawR33dkWkJ6Sxg=; b=t8cqILItoKBCijTI6dbLYMwtL2aqWqSGWV+G/iM5Dujr05FmBTqmpDgNfY28D1YGIE hhUkPpFbYBtM0VTg1fhyLrXbs2aETwCs1Y6Ran/W79SCbOEsEttU4/6dZrWs+raXlzYw 0ltXoulkM4Do5rWIG+HZPgCf3rxvsgufsk0QcwSikLF0hHFaZZMzMNguVcOlz9WqzxMg L9F1u4QukGSck/bgpEDpyyAHK1f9Zj2+We03k/PsYfrIlRMGmux7MKouMu2EbL2OHgWF B8ICRfj/lArFhLIuG3irzwg9lsf97ys4I8avQTxGTsRLcQQyx/sALxIeQnRcAtcpxDQC UY0A== X-Gm-Message-State: APzg51BmQ7eUJI35kuUUESbBv4D40ZpC2V5YKEBLYwjtT4ZZa1Kdl3iP WcceaXKsE2/Bt8X8EUVW5OPR/+Zrm4/0Qg== X-Google-Smtp-Source: ANB0VdZtHbgddeXBhKCkaUmpmIqWKGqYCH8z0xa5jXT4dDiwYgtIShczc9U5xMPgzE5DV+NPKPqMzQ== X-Received: by 2002:a37:642:: with SMTP id 63-v6mr12119831qkg.11.1535650982462; Thu, 30 Aug 2018 10:43:02 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id g10-v6sm4778682qtk.86.2018.08.30.10.43.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:01 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 19/35] btrfs: don't use ctl->free_space for max_extent_size Date: Thu, 30 Aug 2018 13:42:09 -0400 Message-Id: <20180830174225.2200-20-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180830174225.2200-1-josef@toxicpanda.com> References: <20180830174225.2200-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 664b867ae499..ca98c39308f6 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7460,6 +7460,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; @@ -7755,8 +7756,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; } @@ -7923,6 +7924,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);