From patchwork Thu Jul 19 14:50:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10534697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D571F601D2 for ; Thu, 19 Jul 2018 14:50:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBFCE29CB7 for ; Thu, 19 Jul 2018 14:50:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0BB029CC6; Thu, 19 Jul 2018 14:50:34 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 6BF8229CB7 for ; Thu, 19 Jul 2018 14:50:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732034AbeGSPeE (ORCPT ); Thu, 19 Jul 2018 11:34:04 -0400 Received: from mail-qt0-f170.google.com ([209.85.216.170]:37249 "EHLO mail-qt0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731985AbeGSPeD (ORCPT ); Thu, 19 Jul 2018 11:34:03 -0400 Received: by mail-qt0-f170.google.com with SMTP id n6-v6so2859582qtl.4 for ; Thu, 19 Jul 2018 07:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=blKkA10qF6aguWNHKfOI+4aQYTp26AN9H+WJsQ8EiDA=; b=exLMGXkufJCcfvfMiJjUburctxQWn6geuzlzhxybIvfVIa3dITRooNXPCZQHN4c8PG +jDUm8Ewos7PAVGopFWSKqkk8Ph3AQcC/g+6BNGOQwAEGfsuTx5Al/8XMM1Pt/lZpevX ffOo48GkhCqFzJPWFFMP2ByTWizBCDrCkqoBPeYRIPw70v41axU7JcfwHQ56Gj8olW86 /qBiaLQKA2BuDxXlotJHxNSDiIDRkKm9heKnVqo7uC1mZEHT/BPYOsUbJF/LYfo0+p4Z yomBHn4/f75ko4MN1OWWdlcFkRTxYrlnjHJy+mh8hrswNZDH//IqxBGe1g8rQmqQUVRC f8xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=blKkA10qF6aguWNHKfOI+4aQYTp26AN9H+WJsQ8EiDA=; b=XAwjEhYFRK05OrZxzI8OVscyQ8xV9b3a1JYfxx1VCFP8HHL3j+cAcMNytd5Wxwt/kt 4yA5RzKlWVJCDRpptFzapbra7sX81JA2157Rljunz42t2/z/UMHHiAZVPksC+EmfPWUO 0xB9VikT+yZ1P6jAuO7FVig9oPW3nTYwrs6A1ZcjqjfFbJt8f4ySRdCpjjQd+G7gQJ1Z sFpgttHAvnGN94hpihtyfTPQFMvI+a0zAExeePQHkjMt8HODMD+0gA8c8GGxnVd51pJP dyoZSrCGG307AWzQMEyCJWcOIcAow4Y0Dk6w2Z7twmBzf4bR3GyO7V3KrZoqN3Y0fnsg Gwfg== X-Gm-Message-State: AOUpUlHHsfhPeYWyVB5K8gOoz5v9H3V2Gt98mUoTVCitsuLeHHq/bqvS hVCXsbkN3Byur6UduSdVdXTNeam97es= X-Google-Smtp-Source: AAOMgpf5DdpiDERWzQsUme/AikM84eiLDG4OrYyVeWsc10rZ4KV+CfSaljzDafqWE5Rbj7CYZwXAng== X-Received: by 2002:aed:3b26:: with SMTP id p35-v6mr10328986qte.368.1532011832178; Thu, 19 Jul 2018 07:50:32 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id q22-v6sm6834394qtc.33.2018.07.19.07.50.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Jul 2018 07:50:31 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 18/22] btrfs: add ALLOC_CHUNK_FORCE to the flushing code Date: Thu, 19 Jul 2018 10:50:02 -0400 Message-Id: <20180719145006.17532-18-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180719145006.17532-1-josef@toxicpanda.com> References: <20180719145006.17532-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 With my change to no longer take into account the global reserve for metadata allocation chunks we have this side-effect for mixed block group fs'es where we are no longer allocating enough chunks for the data/metadata requirements. To deal with this add a ALLOC_CHUNK_FORCE step to the flushing state machine. This will only get used if we've already made a full loop through the flushing machinery and tried committing the transaction. If we have then we can try and force a chunk allocation since we likely need it to make progress. This resolves the issues I was seeing with the mixed bg tests in xfstests with my previous patch. Signed-off-by: Josef Bacik --- fs/btrfs/ctree.h | 3 ++- fs/btrfs/extent-tree.c | 7 ++++++- include/trace/events/btrfs.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index b33f851fb97d..95f841d8b27c 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2756,7 +2756,8 @@ enum btrfs_flush_state { FLUSH_DELALLOC = 5, FLUSH_DELALLOC_WAIT = 6, ALLOC_CHUNK = 7, - COMMIT_TRANS = 8, + ALLOC_CHUNK_FORCE = 8, + COMMIT_TRANS = 9, }; int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 66b28b29839b..626fb6a92dda 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -5004,6 +5004,7 @@ static void flush_space(struct btrfs_fs_info *fs_info, btrfs_end_transaction(trans); break; case ALLOC_CHUNK: + case ALLOC_CHUNK_FORCE: trans = btrfs_join_transaction(root); if (IS_ERR(trans)) { ret = PTR_ERR(trans); @@ -5011,7 +5012,9 @@ static void flush_space(struct btrfs_fs_info *fs_info, } ret = do_chunk_alloc(trans, fs_info, btrfs_metadata_alloc_profile(fs_info), - CHUNK_ALLOC_NO_FORCE); + (state == ALLOC_CHUNK) ? + CHUNK_ALLOC_NO_FORCE : + CHUNK_ALLOC_FORCE); btrfs_end_transaction(trans); if (ret > 0 || ret == -ENOSPC) ret = 0; @@ -5164,6 +5167,8 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) } } spin_unlock(&space_info->lock); + if (flush_state == ALLOC_CHUNK_FORCE && !commit_cycles) + flush_state++; } while (flush_state <= COMMIT_TRANS); } diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index c0c536d8848a..de38e849f963 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -1052,6 +1052,7 @@ TRACE_EVENT(btrfs_trigger_flush, { FLUSH_DELAYED_REFS_NR, "FLUSH_DELAYED_REFS_NR"}, \ { FLUSH_DELAYED_REFS, "FLUSH_ELAYED_REFS"}, \ { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ + { ALLOC_CHUNK_FORCE, "ALLOC_CHUNK_FORCE"}, \ { COMMIT_TRANS, "COMMIT_TRANS"}) TRACE_EVENT(btrfs_flush_space,