From patchwork Thu Aug 30 17:41: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: 10582425 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 4CF365A4 for ; Thu, 30 Aug 2018 17:42:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 396AC2C332 for ; Thu, 30 Aug 2018 17:42:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D8922C34B; Thu, 30 Aug 2018 17:42:33 +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 BE5052C332 for ; Thu, 30 Aug 2018 17:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727378AbeH3Vpq (ORCPT ); Thu, 30 Aug 2018 17:45:46 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:38008 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727205AbeH3Vpq (ORCPT ); Thu, 30 Aug 2018 17:45:46 -0400 Received: by mail-qt0-f193.google.com with SMTP id x7-v6so11301731qtk.5 for ; Thu, 30 Aug 2018 10:42:31 -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=co/R74J17cdxXxkt+UWJEIt+wVWP+OSPQpBaG1FDfT8=; b=Yrc4A9KoZ0sZByaJxz7hpokvCfn/sIpYjgvycrRFGgxP0crWZHFffqkIv4tGQXbesK Syc6TkJnvB3g7VQwYN/G/F7EGtl0ZcFp6MaX8tL5EEIjIMdw6LLSWRt/6itp1AwoA5EO ACQ03EgbP35HjqEFfG79jZeEV83iH+N8eM/7h7MU08RY+T+4ZwLUGmINI+VapYClTGUU x6PZw2vNNjVr2EH9ioRuStG3mUaySo8oQIkdZubDNySgOct9x7u5DuvrDFGBG7hCAfMO sec43ifaIU9ygzV4apcGZyHTTisf3pkDRQ4dMT2o9ycLpima/J6wecXyhXUALhfb0t0n k/Ig== 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=co/R74J17cdxXxkt+UWJEIt+wVWP+OSPQpBaG1FDfT8=; b=DnvCMt7NX9l+u2wbOjZwaVotWVrdOBNsc5AZeOE9pNpoxpNGScladu5GHMFdIpEvCY 08Sazq8syzNgbfno7Nt41bKg/vR0FUtER8pYpS3vVS1Hz44H/E9/NuWbDCVk0H3/uhnc sII/MfFse/U+PGh1RQ+Um1z/Bx0TxEnWfNG8lNNEEbprpeRFhe8WMM0FN9A1enIxxpyt R0VN+QuTseL+G7BBaydVJ+56BHQ93wwGTXFh3328fyaZ2AzNkZlaODn/uqXnkIR454PQ RkTurS0OPtAazIZ+0tEkJrFKUKB1ktzsNIng0DyyA7laCPvfXlzJNYDnMajyTlnU3sAO SOAg== X-Gm-Message-State: APzg51DjRdH2w+6EHDa4ctX7EQhcSMphoBFtJIs4LV0cMN/C7jPP/i5R pCYvXu5DV0wEe3CiSocDCzpqDHIYoqjccg== X-Google-Smtp-Source: ANB0VdZ0GBPELU9o3/SRVdXrRB/Sdza27OCyqKT/kdQHaxxTe2R0ILlOzlcBojtHAKRcW0fRsoyRlQ== X-Received: by 2002:a37:4dc8:: with SMTP id a191-v6mr12012500qkb.181.1535650950290; Thu, 30 Aug 2018 10:42:30 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id d11-v6sm4355197qkg.14.2018.08.30.10.42.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:29 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 01/35] btrfs: add btrfs_delete_ref_head helper Date: Thu, 30 Aug 2018 13:41:51 -0400 Message-Id: <20180830174225.2200-2-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 We do this dance in cleanup_ref_head and check_ref_cleanup, unify it into a helper and cleanup the calling functions. Signed-off-by: Josef Bacik --- fs/btrfs/delayed-ref.c | 14 ++++++++++++++ fs/btrfs/delayed-ref.h | 3 ++- fs/btrfs/extent-tree.c | 24 ++++-------------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 62ff545ba1f7..3a9e4ac21794 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -393,6 +393,20 @@ btrfs_select_ref_head(struct btrfs_trans_handle *trans) return head; } +void btrfs_delete_ref_head(struct btrfs_delayed_ref_root *delayed_refs, + struct btrfs_delayed_ref_head *head) +{ + lockdep_assert_held(&delayed_refs->lock); + lockdep_assert_held(&head->lock); + + rb_erase(&head->href_node, &delayed_refs->href_root); + RB_CLEAR_NODE(&head->href_node); + atomic_dec(&delayed_refs->num_entries); + delayed_refs->num_heads--; + if (head->processing == 0) + delayed_refs->num_heads_ready--; +} + /* * Helper to insert the ref_node to the tail or merge with tail. * diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index d9f2a4ebd5db..7769177b489e 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h @@ -261,7 +261,8 @@ static inline void btrfs_delayed_ref_unlock(struct btrfs_delayed_ref_head *head) { mutex_unlock(&head->mutex); } - +void btrfs_delete_ref_head(struct btrfs_delayed_ref_root *delayed_refs, + struct btrfs_delayed_ref_head *head); struct btrfs_delayed_ref_head * btrfs_select_ref_head(struct btrfs_trans_handle *trans); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index f77226d8020a..6799950fa057 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2492,12 +2492,9 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, spin_unlock(&delayed_refs->lock); return 1; } - delayed_refs->num_heads--; - rb_erase(&head->href_node, &delayed_refs->href_root); - RB_CLEAR_NODE(&head->href_node); - spin_unlock(&head->lock); + btrfs_delete_ref_head(delayed_refs, head); spin_unlock(&delayed_refs->lock); - atomic_dec(&delayed_refs->num_entries); + spin_unlock(&head->lock); trace_run_delayed_ref_head(fs_info, head, 0); @@ -6984,22 +6981,9 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans, if (!mutex_trylock(&head->mutex)) goto out; - /* - * at this point we have a head with no other entries. Go - * ahead and process it. - */ - rb_erase(&head->href_node, &delayed_refs->href_root); - RB_CLEAR_NODE(&head->href_node); - atomic_dec(&delayed_refs->num_entries); - - /* - * we don't take a ref on the node because we're removing it from the - * tree, so we just steal the ref the tree was holding. - */ - delayed_refs->num_heads--; - if (head->processing == 0) - delayed_refs->num_heads_ready--; + btrfs_delete_ref_head(delayed_refs, head); head->processing = 0; + spin_unlock(&head->lock); spin_unlock(&delayed_refs->lock); From patchwork Thu Aug 30 17:41:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582427 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 316AD17DE for ; Thu, 30 Aug 2018 17:42:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F79E2C342 for ; Thu, 30 Aug 2018 17:42:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 141452C35E; Thu, 30 Aug 2018 17:42:35 +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 98D7C2C342 for ; Thu, 30 Aug 2018 17:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727404AbeH3Vps (ORCPT ); Thu, 30 Aug 2018 17:45:48 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:44025 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727205AbeH3Vpr (ORCPT ); Thu, 30 Aug 2018 17:45:47 -0400 Received: by mail-qk1-f195.google.com with SMTP id 130-v6so22816qkd.10 for ; Thu, 30 Aug 2018 10:42:32 -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=6KgmwomWpLZEcbjWD03lwUSb4bv1/MZXNAiN0EJMH3g=; b=yS4vQKhtDs3fCtunKcBQY5tJAj/JFAjMFqx9Hvj41uhxi7fau8Emxz8Ju9/bzTV9pw 5zI0zR0uqr73iQcYOl7olxz8JvHEkNpkWtF+YEvgT414aXMYOpPD/sPUQck+5GjLLgqj SoUTw8TK6nKCC2xLVNQKSKdPxUz2q2IE9dq8lOsw7L2NnBwSzkRfzic1hm8AMJ1E34m1 3MsDqnyUjAbDTGySsjXeE3E0LwNOi2w2+MCEUC0rlgKfN6lp9Py5AJimzBlefioEC2z5 Zj33yMvJ4hCbLyvKPIfMNZmfS/+H57rmiiKpZkcZBdk4IdwtF/sC4ZBpx/JCg6IsoO9Q tHpw== 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=6KgmwomWpLZEcbjWD03lwUSb4bv1/MZXNAiN0EJMH3g=; b=jA5SRaEWoJXfPd9oyj4tWKoYfSFVTLr9PK4bbsuxAyY8EKZagOsHQwgc0mNXbzPVkE XwjIy6OwJfMpkf+K83zsgaj260JY+MreSuECDk6VINsp/pu7+jh7LSOZzvFfOMGOD/eu f7RkEIBPCtTdAvqAXjnDXOLBBw+Lye8BKhIAKqgOSOUvNLEKh5sO8OUHoh9dtevzUbU8 a3cYtlUaowwR0DKNR8OsXFGWGwgOu5CvYNBSaiFQGi7S+lgNP7VdhBIz3LjOl4iGcMqP ULIBumAQNyQbG5BWrhn6WejRsni5J4XOa7LUEib7brp8/7sdfqoZcxWV6ITf9hQ73e5I rJ3g== X-Gm-Message-State: APzg51DmEkj1wmffzdRRS9lbMpXbJStQ9KONCzSuHnZBXoGGLjmGob0K yq4gfCSQQkHqMsxfyfRliRU9oHMO8+pJDg== X-Google-Smtp-Source: ANB0VdYlTOqyUoU/Vdw4ZECuIYZGeApID6UwxSweyBYKx/Rc3ArvVpl//TU6lCPNyc4YbF8c77JN5g== X-Received: by 2002:a37:132a:: with SMTP id d42-v6mr11831047qkh.343.1535650952037; Thu, 30 Aug 2018 10:42:32 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id o68-v6sm4147551qkf.9.2018.08.30.10.42.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:31 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 02/35] btrfs: add cleanup_ref_head_accounting helper Date: Thu, 30 Aug 2018 13:41:52 -0400 Message-Id: <20180830174225.2200-3-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 We were missing some quota cleanups in check_ref_cleanup, so break the ref head accounting cleanup into a helper and call that from both check_ref_cleanup and cleanup_ref_head. This will hopefully ensure that we don't screw up accounting in the future for other things that we add. Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval Reviewed-by: Liu Bo --- fs/btrfs/extent-tree.c | 67 +++++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 6799950fa057..4c9fd35bca07 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2461,6 +2461,41 @@ static int cleanup_extent_op(struct btrfs_trans_handle *trans, return ret ? ret : 1; } +static void cleanup_ref_head_accounting(struct btrfs_trans_handle *trans, + struct btrfs_delayed_ref_head *head) +{ + struct btrfs_fs_info *fs_info = trans->fs_info; + struct btrfs_delayed_ref_root *delayed_refs = + &trans->transaction->delayed_refs; + + if (head->total_ref_mod < 0) { + struct btrfs_space_info *space_info; + u64 flags; + + if (head->is_data) + flags = BTRFS_BLOCK_GROUP_DATA; + else if (head->is_system) + flags = BTRFS_BLOCK_GROUP_SYSTEM; + else + flags = BTRFS_BLOCK_GROUP_METADATA; + space_info = __find_space_info(fs_info, flags); + ASSERT(space_info); + percpu_counter_add_batch(&space_info->total_bytes_pinned, + -head->num_bytes, + BTRFS_TOTAL_BYTES_PINNED_BATCH); + + if (head->is_data) { + spin_lock(&delayed_refs->lock); + delayed_refs->pending_csums -= head->num_bytes; + spin_unlock(&delayed_refs->lock); + } + } + + /* Also free its reserved qgroup space */ + btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root, + head->qgroup_reserved); +} + static int cleanup_ref_head(struct btrfs_trans_handle *trans, struct btrfs_delayed_ref_head *head) { @@ -2496,31 +2531,6 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, spin_unlock(&delayed_refs->lock); spin_unlock(&head->lock); - trace_run_delayed_ref_head(fs_info, head, 0); - - if (head->total_ref_mod < 0) { - struct btrfs_space_info *space_info; - u64 flags; - - if (head->is_data) - flags = BTRFS_BLOCK_GROUP_DATA; - else if (head->is_system) - flags = BTRFS_BLOCK_GROUP_SYSTEM; - else - flags = BTRFS_BLOCK_GROUP_METADATA; - space_info = __find_space_info(fs_info, flags); - ASSERT(space_info); - percpu_counter_add_batch(&space_info->total_bytes_pinned, - -head->num_bytes, - BTRFS_TOTAL_BYTES_PINNED_BATCH); - - if (head->is_data) { - spin_lock(&delayed_refs->lock); - delayed_refs->pending_csums -= head->num_bytes; - spin_unlock(&delayed_refs->lock); - } - } - if (head->must_insert_reserved) { btrfs_pin_extent(fs_info, head->bytenr, head->num_bytes, 1); @@ -2530,9 +2540,9 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, } } - /* Also free its reserved qgroup space */ - btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root, - head->qgroup_reserved); + cleanup_ref_head_accounting(trans, head); + + trace_run_delayed_ref_head(fs_info, head, 0); btrfs_delayed_ref_unlock(head); btrfs_put_delayed_ref_head(head); return 0; @@ -6991,6 +7001,7 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans, if (head->must_insert_reserved) ret = 1; + cleanup_ref_head_accounting(trans, head); mutex_unlock(&head->mutex); btrfs_put_delayed_ref_head(head); return ret; From patchwork Thu Aug 30 17:41:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582429 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 CD31517DE for ; Thu, 30 Aug 2018 17:42:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB0622C342 for ; Thu, 30 Aug 2018 17:42:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFA482C35E; Thu, 30 Aug 2018 17:42:37 +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 9EFBB2C342 for ; Thu, 30 Aug 2018 17:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727408AbeH3Vpu (ORCPT ); Thu, 30 Aug 2018 17:45:50 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:41187 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727205AbeH3Vpt (ORCPT ); Thu, 30 Aug 2018 17:45:49 -0400 Received: by mail-qt0-f196.google.com with SMTP id t39-v6so11275486qtc.8 for ; Thu, 30 Aug 2018 10:42:34 -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=MADilgVwDBY70VVcTZ0Ev0e6vdmtIqAZcw6d3AbZzHA=; b=t0ZRXxp5f0XuqLg+oMtEjb7nBBREww/KB0BN+dPY3x2BeD+7nXOj1yJAwjMNTeKqsq 30enQg1XX371SdT9GM2sIneIfQiYh1wlHnheVwAIjHy5rFs9qGKWQ9nRrQML0oETF6qq Lgv7cHOqfw6xMnk57nGf7rS36h1t18IL/xtWtmtlUBNGKLMTlBiCS3LNRNGW1/CIouLE o8jwnKQoBii6EcesXVTpvhdvYDbU0t/01GfMbmj6GOZ1Hl0JAYgT4GSQtb36H3Nho66m HGxb5oasoaxLXapHWsBsnoy3YFeVyOpYG7PeGFiuaFW5eo+9mWb2PXue9Ak7mdUlqLlV OF7w== 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=MADilgVwDBY70VVcTZ0Ev0e6vdmtIqAZcw6d3AbZzHA=; b=WDNeptm0MWQJhqVwwHdCIIynIv/TWAOn92/AKq2JAxF1V7OUPRSbXHrQKfY59qwUri ywr+f/7deYcBZXoeyHAL5zuPXplJHRFuBB0Y4Ocai9Z6RPGyce30dJG19wtDiByeYrVi GwE2eEpPfPUJBCprS9T1O997mZoEfsaDtYoYNI5zFAGzLeDyALRLj8s8AI2DMcdWbEg+ 0Uk0zT6zyh4AvMfevk1TOppZyKXzfXmW5gtn6D7yIG02sgbleZBBzkLI6FfczLrQLqFG IyNVRlwFy5QNppPE3TDVV0Vekzoa8pC5RUzUepDt7+kZjrxd9es/ocFxKkQmk3iIB4n5 vWmQ== X-Gm-Message-State: APzg51B/gmyoCxeMWEFRN+6B4JGybGhD5kvXwFNBT6xMVBnCJA4MJrBu U49Zv/RRPB71QJQ5gtbXyvAkTrUmK1G7Kg== X-Google-Smtp-Source: ANB0Vda/auMn4pHteROxWGGwR4t4OvIIpanJ+wnzU33nSWdkB5Sdq1JLsXxDgtm58rjMwJ+NGKyFLA== X-Received: by 2002:a37:8941:: with SMTP id l62-v6mr12550041qkd.204.1535650953872; Thu, 30 Aug 2018 10:42:33 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id n24-v6sm4841749qtf.0.2018.08.30.10.42.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:32 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 03/35] btrfs: use cleanup_extent_op in check_ref_cleanup Date: Thu, 30 Aug 2018 13:41:53 -0400 Message-Id: <20180830174225.2200-4-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 Unify the extent_op handling as well, just add a flag so we don't actually run the extent op from check_ref_cleanup and instead return a value so that we can skip cleaning up the ref head. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4c9fd35bca07..87c42a2c45b1 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2443,18 +2443,23 @@ static void unselect_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_ref } static int cleanup_extent_op(struct btrfs_trans_handle *trans, - struct btrfs_delayed_ref_head *head) + struct btrfs_delayed_ref_head *head, + bool run_extent_op) { struct btrfs_delayed_extent_op *extent_op = head->extent_op; int ret; if (!extent_op) return 0; + head->extent_op = NULL; if (head->must_insert_reserved) { btrfs_free_delayed_extent_op(extent_op); return 0; + } else if (!run_extent_op) { + return 1; } + spin_unlock(&head->lock); ret = run_delayed_extent_op(trans, head, extent_op); btrfs_free_delayed_extent_op(extent_op); @@ -2506,7 +2511,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, delayed_refs = &trans->transaction->delayed_refs; - ret = cleanup_extent_op(trans, head); + ret = cleanup_extent_op(trans, head, true); if (ret < 0) { unselect_delayed_ref_head(delayed_refs, head); btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret); @@ -6977,12 +6982,8 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans, if (!RB_EMPTY_ROOT(&head->ref_tree)) goto out; - if (head->extent_op) { - if (!head->must_insert_reserved) - goto out; - btrfs_free_delayed_extent_op(head->extent_op); - head->extent_op = NULL; - } + if (cleanup_extent_op(trans, head, false)) + goto out; /* * waiting for the lock here would deadlock. If someone else has it From patchwork Thu Aug 30 17:41:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582431 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 E1E565A4 for ; Thu, 30 Aug 2018 17:42:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF1A52C342 for ; Thu, 30 Aug 2018 17:42:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C36D52C35E; Thu, 30 Aug 2018 17:42:38 +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 660A62C342 for ; Thu, 30 Aug 2018 17:42:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727251AbeH3Vpv (ORCPT ); Thu, 30 Aug 2018 17:45:51 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:34809 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbeH3Vpv (ORCPT ); Thu, 30 Aug 2018 17:45:51 -0400 Received: by mail-qt0-f195.google.com with SMTP id m13-v6so11331653qth.1 for ; Thu, 30 Aug 2018 10:42:36 -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=4X46/4+31Z+2yhmkaoQ1ZOza/zHxNuIbkb2dmlVKMr4=; b=WWMnXi0n2pkVIRmXoxE3Gmr0wReurmT8LLUDAjtLDVh0NxOIR6w2ZNgEb/1q3LpNFE kCjf6+MAUQQV+ao4iwnaIIGJGYW2s8HoOK3NBy7UdaYNqZsiNoJk6dJDV8Rb9fkbJwaZ OWglkdcOWbVtOpXbctZ2vVc+aPFsM56HR+AuK3x5ZWBcHIrpGROmER4S91oc89fM0PT0 KZwO9DSQ1tNaU+WtGgGE3JDSZQfxA+fnC1jUtIiKKn0xigAD+rAzCVu15QVOzMnWtBMW 6TBt1iaLWQvq4qB8X0d4J3bwSRW7dN4ybDUcFbQSYNjKszWUqMTrS5OUreEvXpW02zPR +ySg== 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=4X46/4+31Z+2yhmkaoQ1ZOza/zHxNuIbkb2dmlVKMr4=; b=HQWMKCKexCcWmmhRH0slLPsuEWCqjPWJZmrqvSRS1WccyZ0HhYCdJ/rNOOjnRzJ6l2 YViqSRwDm+YQPdvczhjrv8CooPOX4iLxuFvsJF2KwO4M5b2vDAIVLka0gItytfVUjoRj 7BHj4GeObrl3DbXYAoWKIjddTJ6togGQHwHAuC7HWcQBD7zaPMp42fE/pyE7IlqOvXJr 5K8Xpj41q+TtC8pxYpWo3US6ynldPsNDciNLb+5J7pel/2PF8ROWZ9Q0CMlGsulsJXJR RYEdIu08ubsvl6iH6wFeHWf6ke1KBiBXmbO8OZqmKYP9xs+6XsWWhFh43d8oW7cFz6pn ngUA== X-Gm-Message-State: APzg51DUAMbitB2n45cP8wXrlxJQH5f20BWnwiuZirrZ+yoqr1iV9DYK purVKjmLTCWtIMUWPfZBBPjyo5zm9ZntxA== X-Google-Smtp-Source: ANB0VdatUAPzbMqOGjNuqELSjcquP00MH7l18dvs2opyUbTX5rQjuUvV7Nd6p/A9NB27488VQuvrzQ== X-Received: by 2002:a0c:9953:: with SMTP id i19-v6mr12227837qvd.122.1535650955697; Thu, 30 Aug 2018 10:42:35 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id m9-v6sm4947928qta.55.2018.08.30.10.42.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:34 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 04/35] btrfs: only track ref_heads in delayed_ref_updates Date: Thu, 30 Aug 2018 13:41:54 -0400 Message-Id: <20180830174225.2200-5-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 We use this number to figure out how many delayed refs to run, but __btrfs_run_delayed_refs really only checks every time we need a new delayed ref head, so we always run at least one ref head completely no matter what the number of items on it. So instead track only the ref heads added by this trans handle and adjust the counting appropriately in __btrfs_run_delayed_refs. Signed-off-by: Josef Bacik --- fs/btrfs/delayed-ref.c | 3 --- fs/btrfs/extent-tree.c | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 3a9e4ac21794..27f7dd4e3d52 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -234,8 +234,6 @@ static inline void drop_delayed_ref(struct btrfs_trans_handle *trans, ref->in_tree = 0; btrfs_put_delayed_ref(ref); atomic_dec(&delayed_refs->num_entries); - if (trans->delayed_ref_updates) - trans->delayed_ref_updates--; } static bool merge_ref(struct btrfs_trans_handle *trans, @@ -460,7 +458,6 @@ static int insert_delayed_ref(struct btrfs_trans_handle *trans, if (ref->action == BTRFS_ADD_DELAYED_REF) list_add_tail(&ref->add_list, &href->ref_add_list); atomic_inc(&root->num_entries); - trans->delayed_ref_updates++; spin_unlock(&href->lock); return ret; } diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 87c42a2c45b1..20531389a20a 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2583,6 +2583,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, spin_unlock(&delayed_refs->lock); break; } + count++; /* grab the lock that says we are going to process * all the refs for this head */ @@ -2596,7 +2597,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, */ if (ret == -EAGAIN) { locked_ref = NULL; - count++; continue; } } @@ -2624,7 +2624,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, unselect_delayed_ref_head(delayed_refs, locked_ref); locked_ref = NULL; cond_resched(); - count++; continue; } @@ -2642,7 +2641,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, return ret; } locked_ref = NULL; - count++; continue; } @@ -2693,7 +2691,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, } btrfs_put_delayed_ref(ref); - count++; cond_resched(); } From patchwork Thu Aug 30 17:41:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582435 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 8DF4417DE for ; Thu, 30 Aug 2018 17:42:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7762B2C342 for ; Thu, 30 Aug 2018 17:42:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B5112C35E; Thu, 30 Aug 2018 17:42:43 +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 D010F2C342 for ; Thu, 30 Aug 2018 17:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727433AbeH3Vpz (ORCPT ); Thu, 30 Aug 2018 17:45:55 -0400 Received: from mail-qt0-f182.google.com ([209.85.216.182]:38618 "EHLO mail-qt0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727178AbeH3Vpz (ORCPT ); Thu, 30 Aug 2018 17:45:55 -0400 Received: by mail-qt0-f182.google.com with SMTP id x7-v6so11302531qtk.5 for ; Thu, 30 Aug 2018 10:42:38 -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=2z0yQ+Pxz5hLjGK4lpwNqJVPJBpaDsSpWjfapk7z5n8=; b=FNgc3Cci9klKmYWvM6KxkXop7N8MpXw1XxDMr1XW1avfHzraDsZj2ndEUk536NZbN0 toXA5aIwtPvg7y1rgsT91tngyGf52Fwmc2dzCvKfzp1Wef2Hk1R/IuPUV+BeZuL5xO1d pNycpsI1CsRDX9lCOoh0J8IHMwTcpT+jiOlpsJoC0ipvybCD8JMf4MRfZE41QYsUDTF4 bK4PpiC1+knm8uv/D0vKgrwc04nwC6lV6zVVlBQWa0QN2IdBfW35GDM9DQOZO8tKnPNH iTFVywNpjtMAd/xr8Sl4ucJgrCbPUboIlNAs10HweIrT3/vAtIZM9UP/D1oygxvsEeOD WUhQ== 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=2z0yQ+Pxz5hLjGK4lpwNqJVPJBpaDsSpWjfapk7z5n8=; b=KZX0v5RyoVGYGPumsJ3jz9XYoFhuy1In90WDmwrU9qHxA3I1AmhPmNehqocUWgQ7BO teMAY6UMkqANvyOETa2to6JeOQqgXoS+Zs/yJTXME+KHXye6qDnSfMYKaytUcGWbWWX4 1/vFqxMX6ejUCRa0fPnucJqD3RCUYFnAqlv5oJV+0rJOQ1RB9TqtxBjHkb12o9ilnBP4 0kHtMuHfAc87f55YhzjHHYPxsJPXL3AwtBM/i2zwcqGXRHTj0ugG8Sm/3NcTLJSXA6Fh LIv1z76ztkF+h9oDz7wxX4KKP1uu1MYddKiOBJVhxFxPIaCuhsLruH/tOi46+4h30vTr Zqfg== X-Gm-Message-State: APzg51CrKoiNfIbBOTVlzGhCaWAueUGXQMMAP4h8L1BN/JJET+66S5Aj YPC4tDkADEECLacL0nAgUygjOPFSCcVd6w== X-Google-Smtp-Source: ANB0Vdacd5xC4l1ZyF4thAKJF0NHVo4moPmt58xFGqc2f68bpsoGwNylQTiL/iF0pHEWZTHcSYx2Eg== X-Received: by 2002:ac8:585:: with SMTP id a5-v6mr12778539qth.3.1535650957581; Thu, 30 Aug 2018 10:42:37 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id b11-v6sm4260409qkc.71.2018.08.30.10.42.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:36 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 05/35] btrfs: introduce delayed_refs_rsv Date: Thu, 30 Aug 2018 13:41:55 -0400 Message-Id: <20180830174225.2200-6-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 Traditionally we've had voodoo in btrfs to account for the space that delayed refs may take up by having a global_block_rsv. This works most of the time, except when it doesn't. We've had issues reported and seen in production where sometimes the global reserve is exhausted during transaction commit before we can run all of our delayed refs, resulting in an aborted transaction. Because of this voodoo we have equally dubious flushing semantics around throttling delayed refs which we often get wrong. So instead give them their own block_rsv. This way we can always know exactly how much outstanding space we need for delayed refs. This allows us to make sure we are constantly filling that reservation up with space, and allows us to put more precise pressure on the enospc system. Instead of doing math to see if its a good time to throttle, the normal enospc code will be invoked if we have a lot of delayed refs pending, and they will be run via the normal flushing mechanism. For now the delayed_refs_rsv will hold the reservations for the delayed refs, the block group updates, and deleting csums. We could have a separate rsv for the block group updates, but the csum deletion stuff is still handled via the delayed_refs so that will stay there. Signed-off-by: Josef Bacik --- fs/btrfs/ctree.h | 24 +++- fs/btrfs/delayed-ref.c | 28 ++++- fs/btrfs/disk-io.c | 3 + fs/btrfs/extent-tree.c | 268 +++++++++++++++++++++++++++++++++++-------- fs/btrfs/transaction.c | 68 +++++------ include/trace/events/btrfs.h | 2 + 6 files changed, 294 insertions(+), 99 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 66f1d3895bca..0a4e55703d48 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -452,8 +452,9 @@ struct btrfs_space_info { #define BTRFS_BLOCK_RSV_TRANS 3 #define BTRFS_BLOCK_RSV_CHUNK 4 #define BTRFS_BLOCK_RSV_DELOPS 5 -#define BTRFS_BLOCK_RSV_EMPTY 6 -#define BTRFS_BLOCK_RSV_TEMP 7 +#define BTRFS_BLOCK_RSV_DELREFS 6 +#define BTRFS_BLOCK_RSV_EMPTY 7 +#define BTRFS_BLOCK_RSV_TEMP 8 struct btrfs_block_rsv { u64 size; @@ -794,6 +795,8 @@ struct btrfs_fs_info { struct btrfs_block_rsv chunk_block_rsv; /* block reservation for delayed operations */ struct btrfs_block_rsv delayed_block_rsv; + /* block reservation for delayed refs */ + struct btrfs_block_rsv delayed_refs_rsv; struct btrfs_block_rsv empty_block_rsv; @@ -2723,10 +2726,12 @@ enum btrfs_reserve_flush_enum { enum btrfs_flush_state { FLUSH_DELAYED_ITEMS_NR = 1, FLUSH_DELAYED_ITEMS = 2, - FLUSH_DELALLOC = 3, - FLUSH_DELALLOC_WAIT = 4, - ALLOC_CHUNK = 5, - COMMIT_TRANS = 6, + FLUSH_DELAYED_REFS_NR = 3, + FLUSH_DELAYED_REFS = 4, + FLUSH_DELALLOC = 5, + FLUSH_DELALLOC_WAIT = 6, + ALLOC_CHUNK = 7, + COMMIT_TRANS = 8, }; int btrfs_alloc_data_chunk_ondemand(struct btrfs_inode *inode, u64 bytes); @@ -2777,6 +2782,13 @@ int btrfs_cond_migrate_bytes(struct btrfs_fs_info *fs_info, void btrfs_block_rsv_release(struct btrfs_fs_info *fs_info, struct btrfs_block_rsv *block_rsv, u64 num_bytes); +void btrfs_delayed_refs_rsv_release(struct btrfs_fs_info *fs_info, int nr); +void btrfs_update_delayed_refs_rsv(struct btrfs_trans_handle *trans); +int btrfs_refill_delayed_refs_rsv(struct btrfs_fs_info *fs_info, + enum btrfs_reserve_flush_enum flush); +void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info, + struct btrfs_block_rsv *src, + u64 num_bytes); int btrfs_inc_block_group_ro(struct btrfs_block_group_cache *cache); void btrfs_dec_block_group_ro(struct btrfs_block_group_cache *cache); void btrfs_put_block_group_cache(struct btrfs_fs_info *info); diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 27f7dd4e3d52..96ce087747b2 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -467,11 +467,14 @@ static int insert_delayed_ref(struct btrfs_trans_handle *trans, * existing and update must have the same bytenr */ static noinline void -update_existing_head_ref(struct btrfs_delayed_ref_root *delayed_refs, +update_existing_head_ref(struct btrfs_trans_handle *trans, struct btrfs_delayed_ref_head *existing, struct btrfs_delayed_ref_head *update, int *old_ref_mod_ret) { + struct btrfs_delayed_ref_root *delayed_refs = + &trans->transaction->delayed_refs; + struct btrfs_fs_info *fs_info = trans->fs_info; int old_ref_mod; BUG_ON(existing->is_data != update->is_data); @@ -529,10 +532,18 @@ update_existing_head_ref(struct btrfs_delayed_ref_root *delayed_refs, * versa we need to make sure to adjust pending_csums accordingly. */ if (existing->is_data) { - if (existing->total_ref_mod >= 0 && old_ref_mod < 0) + u64 csum_items = + btrfs_csum_bytes_to_leaves(fs_info, + existing->num_bytes); + + if (existing->total_ref_mod >= 0 && old_ref_mod < 0) { delayed_refs->pending_csums -= existing->num_bytes; - if (existing->total_ref_mod < 0 && old_ref_mod >= 0) + btrfs_delayed_refs_rsv_release(fs_info, csum_items); + } + if (existing->total_ref_mod < 0 && old_ref_mod >= 0) { delayed_refs->pending_csums += existing->num_bytes; + trans->delayed_ref_updates += csum_items; + } } spin_unlock(&existing->lock); } @@ -638,7 +649,7 @@ add_delayed_ref_head(struct btrfs_trans_handle *trans, && head_ref->qgroup_reserved && existing->qgroup_ref_root && existing->qgroup_reserved); - update_existing_head_ref(delayed_refs, existing, head_ref, + update_existing_head_ref(trans, existing, head_ref, old_ref_mod); /* * we've updated the existing ref, free the newly @@ -649,8 +660,12 @@ add_delayed_ref_head(struct btrfs_trans_handle *trans, } else { if (old_ref_mod) *old_ref_mod = 0; - if (head_ref->is_data && head_ref->ref_mod < 0) + if (head_ref->is_data && head_ref->ref_mod < 0) { delayed_refs->pending_csums += head_ref->num_bytes; + trans->delayed_ref_updates += + btrfs_csum_bytes_to_leaves(trans->fs_info, + head_ref->num_bytes); + } delayed_refs->num_heads++; delayed_refs->num_heads_ready++; atomic_inc(&delayed_refs->num_entries); @@ -785,6 +800,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node); spin_unlock(&delayed_refs->lock); + btrfs_update_delayed_refs_rsv(trans); trace_add_delayed_tree_ref(fs_info, &ref->node, ref, action == BTRFS_ADD_DELAYED_EXTENT ? @@ -866,6 +882,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node); spin_unlock(&delayed_refs->lock); + btrfs_update_delayed_refs_rsv(trans); trace_add_delayed_data_ref(trans->fs_info, &ref->node, ref, action == BTRFS_ADD_DELAYED_EXTENT ? @@ -903,6 +920,7 @@ int btrfs_add_delayed_extent_op(struct btrfs_fs_info *fs_info, NULL, NULL, NULL); spin_unlock(&delayed_refs->lock); + btrfs_update_delayed_refs_rsv(trans); return 0; } diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 5124c15705ce..0e42401756b8 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2692,6 +2692,9 @@ int open_ctree(struct super_block *sb, btrfs_init_block_rsv(&fs_info->empty_block_rsv, BTRFS_BLOCK_RSV_EMPTY); btrfs_init_block_rsv(&fs_info->delayed_block_rsv, BTRFS_BLOCK_RSV_DELOPS); + btrfs_init_block_rsv(&fs_info->delayed_refs_rsv, + BTRFS_BLOCK_RSV_DELREFS); + atomic_set(&fs_info->async_delalloc_pages, 0); atomic_set(&fs_info->defrag_running, 0); atomic_set(&fs_info->qgroup_op_seq, 0); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 20531389a20a..6e7f350754d2 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2472,6 +2472,7 @@ static void cleanup_ref_head_accounting(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_delayed_ref_root *delayed_refs = &trans->transaction->delayed_refs; + int nr_items = 1; if (head->total_ref_mod < 0) { struct btrfs_space_info *space_info; @@ -2493,12 +2494,15 @@ static void cleanup_ref_head_accounting(struct btrfs_trans_handle *trans, spin_lock(&delayed_refs->lock); delayed_refs->pending_csums -= head->num_bytes; spin_unlock(&delayed_refs->lock); + nr_items += btrfs_csum_bytes_to_leaves(fs_info, + head->num_bytes); } } /* Also free its reserved qgroup space */ btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root, head->qgroup_reserved); + btrfs_delayed_refs_rsv_release(fs_info, nr_items); } static int cleanup_ref_head(struct btrfs_trans_handle *trans, @@ -2796,37 +2800,20 @@ u64 btrfs_csum_bytes_to_leaves(struct btrfs_fs_info *fs_info, u64 csum_bytes) int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info) { - struct btrfs_block_rsv *global_rsv; - u64 num_heads = trans->transaction->delayed_refs.num_heads_ready; - u64 csum_bytes = trans->transaction->delayed_refs.pending_csums; - unsigned int num_dirty_bgs = trans->transaction->num_dirty_bgs; - u64 num_bytes, num_dirty_bgs_bytes; + struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; + struct btrfs_block_rsv *delayed_refs_rsv = &fs_info->delayed_refs_rsv; + u64 reserved; int ret = 0; - num_bytes = btrfs_calc_trans_metadata_size(fs_info, 1); - num_heads = heads_to_leaves(fs_info, num_heads); - if (num_heads > 1) - num_bytes += (num_heads - 1) * fs_info->nodesize; - num_bytes <<= 1; - num_bytes += btrfs_csum_bytes_to_leaves(fs_info, csum_bytes) * - fs_info->nodesize; - num_dirty_bgs_bytes = btrfs_calc_trans_metadata_size(fs_info, - num_dirty_bgs); - global_rsv = &fs_info->global_block_rsv; - - /* - * If we can't allocate any more chunks lets make sure we have _lots_ of - * wiggle room since running delayed refs can create more delayed refs. - */ - if (global_rsv->space_info->full) { - num_dirty_bgs_bytes <<= 1; - num_bytes <<= 1; - } - spin_lock(&global_rsv->lock); - if (global_rsv->reserved <= num_bytes + num_dirty_bgs_bytes) - ret = 1; + reserved = global_rsv->reserved; spin_unlock(&global_rsv->lock); + + spin_lock(&delayed_refs_rsv->lock); + reserved += delayed_refs_rsv->reserved; + if (delayed_refs_rsv->size >= reserved) + ret = 1; + spin_unlock(&delayed_refs_rsv->lock); return ret; } @@ -3601,6 +3588,8 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans) */ mutex_lock(&trans->transaction->cache_write_mutex); while (!list_empty(&dirty)) { + bool drop_reserve = true; + cache = list_first_entry(&dirty, struct btrfs_block_group_cache, dirty_list); @@ -3673,6 +3662,7 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans) list_add_tail(&cache->dirty_list, &cur_trans->dirty_bgs); btrfs_get_block_group(cache); + drop_reserve = false; } spin_unlock(&cur_trans->dirty_bgs_lock); } else if (ret) { @@ -3683,6 +3673,8 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans) /* if its not on the io list, we need to put the block group */ if (should_put) btrfs_put_block_group(cache); + if (drop_reserve) + btrfs_delayed_refs_rsv_release(fs_info, 1); if (ret) break; @@ -3831,6 +3823,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, /* if its not on the io list, we need to put the block group */ if (should_put) btrfs_put_block_group(cache); + btrfs_delayed_refs_rsv_release(fs_info, 1); spin_lock(&cur_trans->dirty_bgs_lock); } spin_unlock(&cur_trans->dirty_bgs_lock); @@ -4807,8 +4800,10 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, { struct reserve_ticket *ticket = NULL; struct btrfs_block_rsv *delayed_rsv = &fs_info->delayed_block_rsv; + struct btrfs_block_rsv *delayed_refs_rsv = &fs_info->delayed_refs_rsv; struct btrfs_trans_handle *trans; u64 bytes; + u64 reclaim_bytes = 0; trans = (struct btrfs_trans_handle *)current->journal_info; if (trans) @@ -4841,12 +4836,16 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, return -ENOSPC; spin_lock(&delayed_rsv->lock); - if (delayed_rsv->size > bytes) - bytes = 0; - else - bytes -= delayed_rsv->size; + reclaim_bytes += delayed_rsv->reserved; spin_unlock(&delayed_rsv->lock); + spin_lock(&delayed_refs_rsv->lock); + reclaim_bytes += delayed_refs_rsv->reserved; + spin_unlock(&delayed_refs_rsv->lock); + if (reclaim_bytes >= bytes) + goto commit; + bytes -= reclaim_bytes; + if (__percpu_counter_compare(&space_info->total_bytes_pinned, bytes, BTRFS_TOTAL_BYTES_PINNED_BATCH) < 0) { @@ -4896,6 +4895,20 @@ static void flush_space(struct btrfs_fs_info *fs_info, shrink_delalloc(fs_info, num_bytes * 2, num_bytes, state == FLUSH_DELALLOC_WAIT); break; + case FLUSH_DELAYED_REFS_NR: + case FLUSH_DELAYED_REFS: + trans = btrfs_join_transaction(root); + if (IS_ERR(trans)) { + ret = PTR_ERR(trans); + break; + } + if (state == FLUSH_DELAYED_REFS_NR) + nr = calc_reclaim_items_nr(fs_info, num_bytes); + else + nr = 0; + btrfs_run_delayed_refs(trans, nr); + btrfs_end_transaction(trans); + break; case ALLOC_CHUNK: trans = btrfs_join_transaction(root); if (IS_ERR(trans)) { @@ -5368,6 +5381,93 @@ int btrfs_cond_migrate_bytes(struct btrfs_fs_info *fs_info, return 0; } +/** + * btrfs_migrate_to_delayed_refs_rsv - transfer bytes to our delayed refs rsv. + * @fs_info - the fs info for our fs. + * @src - the source block rsv to transfer from. + * @num_bytes - the number of bytes to transfer. + * + * This transfers up to the num_bytes amount from the src rsv to the + * delayed_refs_rsv. Any extra bytes are returned to the space info. + */ +void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info, + struct btrfs_block_rsv *src, + u64 num_bytes) +{ + struct btrfs_block_rsv *delayed_refs_rsv = &fs_info->delayed_refs_rsv; + u64 to_free = 0; + + spin_lock(&src->lock); + src->reserved -= num_bytes; + src->size -= num_bytes; + spin_unlock(&src->lock); + + spin_lock(&delayed_refs_rsv->lock); + if (delayed_refs_rsv->size > delayed_refs_rsv->reserved) { + u64 delta = delayed_refs_rsv->size - + delayed_refs_rsv->reserved; + if (num_bytes > delta) { + to_free = num_bytes - delta; + num_bytes = delta; + } + } else { + to_free = num_bytes; + num_bytes = 0; + } + + if (num_bytes) + delayed_refs_rsv->reserved += num_bytes; + if (delayed_refs_rsv->reserved >= delayed_refs_rsv->size) + delayed_refs_rsv->full = 1; + spin_unlock(&delayed_refs_rsv->lock); + + if (num_bytes) + trace_btrfs_space_reservation(fs_info, "delayed_refs_rsv", + 0, num_bytes, 1); + if (to_free) + space_info_add_old_bytes(fs_info, delayed_refs_rsv->space_info, + to_free); +} + +/** + * btrfs_refill_delayed_refs_rsv - refill the delayed block rsv. + * @fs_info - the fs_info for our fs. + * @flush - control how we can flush for this reservation. + * + * This will refill the delayed block_rsv up to 1 items size worth of space and + * will return -ENOSPC if we can't make the reservation. + */ +int btrfs_refill_delayed_refs_rsv(struct btrfs_fs_info *fs_info, + enum btrfs_reserve_flush_enum flush) +{ + struct btrfs_block_rsv *block_rsv = &fs_info->delayed_refs_rsv; + u64 limit = btrfs_calc_trans_metadata_size(fs_info, 1); + u64 num_bytes = 0; + int ret = -ENOSPC; + + spin_lock(&block_rsv->lock); + if (block_rsv->reserved < block_rsv->size) { + num_bytes = block_rsv->size - block_rsv->reserved; + num_bytes = min(num_bytes, limit); + } + spin_unlock(&block_rsv->lock); + + if (!num_bytes) + return 0; + + ret = reserve_metadata_bytes(fs_info->extent_root, block_rsv, + num_bytes, flush); + if (!ret) { + block_rsv_add_bytes(block_rsv, num_bytes, 0); + trace_btrfs_space_reservation(fs_info, "delayed_refs_rsv", + 0, num_bytes, 1); + return 0; + } + + return ret; +} + + /* * This is for space we already have accounted in space_info->bytes_may_use, so * basically when we're returning space from block_rsv's. @@ -5690,6 +5790,31 @@ static int btrfs_inode_rsv_refill(struct btrfs_inode *inode, return ret; } +static u64 __btrfs_block_rsv_release(struct btrfs_fs_info *fs_info, + struct btrfs_block_rsv *block_rsv, + u64 num_bytes, u64 *qgroup_to_release) +{ + struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; + struct btrfs_block_rsv *delayed_rsv = &fs_info->delayed_refs_rsv; + struct btrfs_block_rsv *target = delayed_rsv; + + if (target->full || target == block_rsv) + target = global_rsv; + + if (block_rsv->space_info != target->space_info) + target = NULL; + + return block_rsv_release_bytes(fs_info, block_rsv, target, num_bytes, + qgroup_to_release); +} + +void btrfs_block_rsv_release(struct btrfs_fs_info *fs_info, + struct btrfs_block_rsv *block_rsv, + u64 num_bytes) +{ + __btrfs_block_rsv_release(fs_info, block_rsv, num_bytes, NULL); +} + /** * btrfs_inode_rsv_release - release any excessive reservation. * @inode - the inode we need to release from. @@ -5704,7 +5829,6 @@ static int btrfs_inode_rsv_refill(struct btrfs_inode *inode, static void btrfs_inode_rsv_release(struct btrfs_inode *inode, bool qgroup_free) { struct btrfs_fs_info *fs_info = inode->root->fs_info; - struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; struct btrfs_block_rsv *block_rsv = &inode->block_rsv; u64 released = 0; u64 qgroup_to_release = 0; @@ -5714,8 +5838,8 @@ static void btrfs_inode_rsv_release(struct btrfs_inode *inode, bool qgroup_free) * are releasing 0 bytes, and then we'll just get the reservation over * the size free'd. */ - released = block_rsv_release_bytes(fs_info, block_rsv, global_rsv, 0, - &qgroup_to_release); + released = __btrfs_block_rsv_release(fs_info, block_rsv, 0, + &qgroup_to_release); if (released > 0) trace_btrfs_space_reservation(fs_info, "delalloc", btrfs_ino(inode), released, 0); @@ -5726,16 +5850,25 @@ static void btrfs_inode_rsv_release(struct btrfs_inode *inode, bool qgroup_free) qgroup_to_release); } -void btrfs_block_rsv_release(struct btrfs_fs_info *fs_info, - struct btrfs_block_rsv *block_rsv, - u64 num_bytes) +/** + * btrfs_delayed_refs_rsv_release - release a ref head's reservation. + * @fs_info - the fs_info for our fs. + * + * This drops the delayed ref head's count from the delayed refs rsv and free's + * any excess reservation we had. + */ +void btrfs_delayed_refs_rsv_release(struct btrfs_fs_info *fs_info, int nr) { + struct btrfs_block_rsv *block_rsv = &fs_info->delayed_refs_rsv; struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; + u64 num_bytes = btrfs_calc_trans_metadata_size(fs_info, nr); + u64 released = 0; - if (global_rsv == block_rsv || - block_rsv->space_info != global_rsv->space_info) - global_rsv = NULL; - block_rsv_release_bytes(fs_info, block_rsv, global_rsv, num_bytes, NULL); + released = block_rsv_release_bytes(fs_info, block_rsv, global_rsv, + num_bytes, NULL); + if (released) + trace_btrfs_space_reservation(fs_info, "delayed_refs_rsv", + 0, released, 0); } static void update_global_block_rsv(struct btrfs_fs_info *fs_info) @@ -5800,9 +5933,10 @@ static void init_global_block_rsv(struct btrfs_fs_info *fs_info) fs_info->trans_block_rsv.space_info = space_info; fs_info->empty_block_rsv.space_info = space_info; fs_info->delayed_block_rsv.space_info = space_info; + fs_info->delayed_refs_rsv.space_info = space_info; - fs_info->extent_root->block_rsv = &fs_info->global_block_rsv; - fs_info->csum_root->block_rsv = &fs_info->global_block_rsv; + fs_info->extent_root->block_rsv = &fs_info->delayed_refs_rsv; + fs_info->csum_root->block_rsv = &fs_info->delayed_refs_rsv; fs_info->dev_root->block_rsv = &fs_info->global_block_rsv; fs_info->tree_root->block_rsv = &fs_info->global_block_rsv; if (fs_info->quota_root) @@ -5822,8 +5956,34 @@ static void release_global_block_rsv(struct btrfs_fs_info *fs_info) WARN_ON(fs_info->chunk_block_rsv.reserved > 0); WARN_ON(fs_info->delayed_block_rsv.size > 0); WARN_ON(fs_info->delayed_block_rsv.reserved > 0); + WARN_ON(fs_info->delayed_refs_rsv.reserved > 0); + WARN_ON(fs_info->delayed_refs_rsv.size > 0); } +/* + * btrfs_update_delayed_refs_rsv - adjust the size of the delayed refs rsv + * @trans - the trans that may have generated delayed refs + * + * This is to be called anytime we may have adjusted trans->delayed_ref_updates, + * it'll calculate the additional size and add it to the delayed_refs_rsv. + */ +void btrfs_update_delayed_refs_rsv(struct btrfs_trans_handle *trans) +{ + struct btrfs_fs_info *fs_info = trans->fs_info; + struct btrfs_block_rsv *delayed_rsv = &fs_info->delayed_refs_rsv; + u64 num_bytes; + + if (!trans->delayed_ref_updates) + return; + + num_bytes = btrfs_calc_trans_metadata_size(fs_info, + trans->delayed_ref_updates); + spin_lock(&delayed_rsv->lock); + delayed_rsv->size += num_bytes; + delayed_rsv->full = 0; + spin_unlock(&delayed_rsv->lock); + trans->delayed_ref_updates = 0; +} /* * To be called after all the new block groups attached to the transaction @@ -6117,6 +6277,7 @@ static int update_block_group(struct btrfs_trans_handle *trans, u64 old_val; u64 byte_in_group; int factor; + int ret = 0; /* block accounting for super block */ spin_lock(&info->delalloc_root_lock); @@ -6130,8 +6291,10 @@ static int update_block_group(struct btrfs_trans_handle *trans, while (total) { cache = btrfs_lookup_block_group(info, bytenr); - if (!cache) - return -ENOENT; + if (!cache) { + ret = -ENOENT; + break; + } factor = btrfs_bg_type_to_factor(cache->flags); /* @@ -6190,6 +6353,7 @@ static int update_block_group(struct btrfs_trans_handle *trans, list_add_tail(&cache->dirty_list, &trans->transaction->dirty_bgs); trans->transaction->num_dirty_bgs++; + trans->delayed_ref_updates++; btrfs_get_block_group(cache); } spin_unlock(&trans->transaction->dirty_bgs_lock); @@ -6207,7 +6371,8 @@ static int update_block_group(struct btrfs_trans_handle *trans, total -= num_bytes; bytenr += num_bytes; } - return 0; + btrfs_update_delayed_refs_rsv(trans); + return ret; } static u64 first_logical_byte(struct btrfs_fs_info *fs_info, u64 search_start) @@ -8221,7 +8386,12 @@ use_block_rsv(struct btrfs_trans_handle *trans, goto again; } - if (btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { + /* + * The global reserve still exists to save us from ourselves, so don't + * warn_on if we are short on our delayed refs reserve. + */ + if (block_rsv->type != BTRFS_BLOCK_RSV_DELREFS && + btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { static DEFINE_RATELIMIT_STATE(_rs, DEFAULT_RATELIMIT_INTERVAL * 10, /*DEFAULT_RATELIMIT_BURST*/ 1); @@ -10251,6 +10421,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, int factor; struct btrfs_caching_control *caching_ctl = NULL; bool remove_em; + bool remove_rsv = false; block_group = btrfs_lookup_block_group(fs_info, group_start); BUG_ON(!block_group); @@ -10315,6 +10486,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, if (!list_empty(&block_group->dirty_list)) { list_del_init(&block_group->dirty_list); + remove_rsv = true; btrfs_put_block_group(block_group); } spin_unlock(&trans->transaction->dirty_bgs_lock); @@ -10524,6 +10696,8 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, ret = btrfs_del_item(trans, root, path); out: + if (remove_rsv) + btrfs_delayed_refs_rsv_release(fs_info, 1); btrfs_free_path(path); return ret; } diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 3b84f5015029..99741254e27e 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -455,7 +455,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, bool enforce_qgroups) { struct btrfs_fs_info *fs_info = root->fs_info; - + struct btrfs_block_rsv *delayed_refs_rsv = &fs_info->delayed_refs_rsv; struct btrfs_trans_handle *h; struct btrfs_transaction *cur_trans; u64 num_bytes = 0; @@ -484,6 +484,9 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, * the appropriate flushing if need be. */ if (num_items && root != fs_info->chunk_root) { + struct btrfs_block_rsv *rsv = &fs_info->trans_block_rsv; + u64 delayed_refs_bytes = 0; + qgroup_reserved = num_items * fs_info->nodesize; ret = btrfs_qgroup_reserve_meta_pertrans(root, qgroup_reserved, enforce_qgroups); @@ -491,6 +494,11 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, return ERR_PTR(ret); num_bytes = btrfs_calc_trans_metadata_size(fs_info, num_items); + if (delayed_refs_rsv->full == 0) { + delayed_refs_bytes = num_bytes; + num_bytes <<= 1; + } + /* * Do the reservation for the relocation root creation */ @@ -499,8 +507,24 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, reloc_reserved = true; } - ret = btrfs_block_rsv_add(root, &fs_info->trans_block_rsv, - num_bytes, flush); + ret = btrfs_block_rsv_add(root, rsv, num_bytes, flush); + if (ret) + goto reserve_fail; + if (delayed_refs_bytes) { + btrfs_migrate_to_delayed_refs_rsv(fs_info, rsv, + delayed_refs_bytes); + num_bytes -= delayed_refs_bytes; + } + } else if (num_items == 0 && flush == BTRFS_RESERVE_FLUSH_ALL && + !delayed_refs_rsv->full) { + /* + * Some people call with btrfs_start_transaction(root, 0) + * because they can be throttled, but have some other mechanism + * for reserving space. We still want these guys to refill the + * delayed block_rsv so just add 1 items worth of reservation + * here. + */ + ret = btrfs_refill_delayed_refs_rsv(fs_info, flush); if (ret) goto reserve_fail; } @@ -768,22 +792,12 @@ static int should_end_transaction(struct btrfs_trans_handle *trans) int btrfs_should_end_transaction(struct btrfs_trans_handle *trans) { struct btrfs_transaction *cur_trans = trans->transaction; - int updates; - int err; smp_mb(); if (cur_trans->state >= TRANS_STATE_BLOCKED || cur_trans->delayed_refs.flushing) return 1; - updates = trans->delayed_ref_updates; - trans->delayed_ref_updates = 0; - if (updates) { - err = btrfs_run_delayed_refs(trans, updates * 2); - if (err) /* Error code will also eval true */ - return err; - } - return should_end_transaction(trans); } @@ -813,11 +827,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, { struct btrfs_fs_info *info = trans->fs_info; struct btrfs_transaction *cur_trans = trans->transaction; - u64 transid = trans->transid; - unsigned long cur = trans->delayed_ref_updates; int lock = (trans->type != TRANS_JOIN_NOLOCK); int err = 0; - int must_run_delayed_refs = 0; if (refcount_read(&trans->use_count) > 1) { refcount_dec(&trans->use_count); @@ -828,27 +839,6 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, btrfs_trans_release_metadata(trans); trans->block_rsv = NULL; - if (!list_empty(&trans->new_bgs)) - btrfs_create_pending_block_groups(trans); - - trans->delayed_ref_updates = 0; - if (!trans->sync) { - must_run_delayed_refs = - btrfs_should_throttle_delayed_refs(trans, info); - cur = max_t(unsigned long, cur, 32); - - /* - * don't make the caller wait if they are from a NOLOCK - * or ATTACH transaction, it will deadlock with commit - */ - if (must_run_delayed_refs == 1 && - (trans->type & (__TRANS_JOIN_NOLOCK | __TRANS_ATTACH))) - must_run_delayed_refs = 2; - } - - btrfs_trans_release_metadata(trans); - trans->block_rsv = NULL; - if (!list_empty(&trans->new_bgs)) btrfs_create_pending_block_groups(trans); @@ -893,10 +883,6 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, } kmem_cache_free(btrfs_trans_handle_cachep, trans); - if (must_run_delayed_refs) { - btrfs_async_run_delayed_refs(info, cur, transid, - must_run_delayed_refs == 1); - } return err; } diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h index b401c4e36394..7d205e50b09c 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -1048,6 +1048,8 @@ TRACE_EVENT(btrfs_trigger_flush, { FLUSH_DELAYED_ITEMS, "FLUSH_DELAYED_ITEMS"}, \ { FLUSH_DELALLOC, "FLUSH_DELALLOC"}, \ { FLUSH_DELALLOC_WAIT, "FLUSH_DELALLOC_WAIT"}, \ + { FLUSH_DELAYED_REFS_NR, "FLUSH_DELAYED_REFS_NR"}, \ + { FLUSH_DELAYED_REFS, "FLUSH_ELAYED_REFS"}, \ { ALLOC_CHUNK, "ALLOC_CHUNK"}, \ { COMMIT_TRANS, "COMMIT_TRANS"}) From patchwork Thu Aug 30 17:41:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582433 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 C1AC817DE for ; Thu, 30 Aug 2018 17:42:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF3882C34B for ; Thu, 30 Aug 2018 17:42:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3A942C35F; Thu, 30 Aug 2018 17:42:42 +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 30A6F2C34B for ; Thu, 30 Aug 2018 17:42:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727451AbeH3Vp4 (ORCPT ); Thu, 30 Aug 2018 17:45:56 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:45925 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbeH3Vpz (ORCPT ); Thu, 30 Aug 2018 17:45:55 -0400 Received: by mail-qk1-f194.google.com with SMTP id z125-v6so22674qkb.12 for ; Thu, 30 Aug 2018 10:42:40 -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=QID6sbzQnZ5mudS/me9bf30Y9AWtvUfPLtB787pk2fc=; b=ZFIM1UOELFtl6Kbcq3DBdqkwYGKhWgCmT+8JVi/HYu5IPNW7jixMquFdd03+dRaRrK Aox6m78yziw/Os60W9OMkMLnZki4OaCA1OSkDowV8uKEvxWUfOSKwBBUvPEFzGtB5XD1 Efkn5kbkhRst+RQPg9UFl/XJiy2woJMePpgNB10BjBZJFmVeI0BVXsP0Fw8C8ryuFMcz N9N103UIutiZPTFiKNFkW+trI079Aqm83lQB9xuNJY7grvnc2REswaolAObTEKWfsvNb KnjSR1Y5/tebVzFJinwkAr8KSUHFZVD3EQXkpA4NiSArvYFtLDAqUWFCZdCRMg+gaehy gGcw== 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=QID6sbzQnZ5mudS/me9bf30Y9AWtvUfPLtB787pk2fc=; b=TgA67YSoWFWucYUG6vPl5wdQYA5MeVdmsH20LPTNakgtZww8U6SdB2LhOlqOMy0Z6M AUr+xO3EjnpA+LNJIjT43pHZGyPBd6+AfiN93pM2tqotClYaiWSMeUgi6F/QSiHW7cR0 GuH6HWKvenq4fCami3kzd+6MjJ28EB0w9UB7SPWr/d3vDTjgu6+JXPaUYbkxOTjQugk+ jHfxm4PFDABIhFVUO/gZQYmi6uzo/dXav2AHQGTkf1SuPjUJUX4AfMglTN6CgG9o6N6j zR7AFZJoIEFuwwLNjpMcgcSMYlGSgEJlyr+pAjuzDk4olWZ5uj6arXpsR5DvgAHy3NYL kU8g== X-Gm-Message-State: APzg51DVY0e2kVDPnafQwgk+mrz5oVxJD0OCWqS7awufcRrV38EvckuF GO6Mk0+0G+aitXPUAAInpegInrNeUfp05A== X-Google-Smtp-Source: ANB0VdaylBRIygUYGhcFcbMKihlZIijAlABDjZX6eLOw4K6TYvzj+ena0HjaTI4EmpiaaDivxdq5kQ== X-Received: by 2002:a37:283:: with SMTP id v3-v6mr12603028qkg.200.1535650959470; Thu, 30 Aug 2018 10:42:39 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id m12-v6sm4390881qkl.54.2018.08.30.10.42.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:38 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 06/35] btrfs: check if free bgs for commit Date: Thu, 30 Aug 2018 13:41:56 -0400 Message-Id: <20180830174225.2200-7-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 may_commit_transaction will skip committing the transaction if we don't have enough pinned space or if we're trying to find space for a SYSTEM chunk. However if we have pending free block groups in this transaction we still want to commit as we may be able to allocate a chunk to make our reservation. So instead of just returning ENOSPC, check if we have free block groups pending, and if so commit the transaction to allow us to use that free space. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 6e7f350754d2..80615a579b18 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4804,6 +4804,7 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, struct btrfs_trans_handle *trans; u64 bytes; u64 reclaim_bytes = 0; + bool do_commit = true; trans = (struct btrfs_trans_handle *)current->journal_info; if (trans) @@ -4832,8 +4833,10 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, * See if there is some space in the delayed insertion reservation for * this reservation. */ - if (space_info != delayed_rsv->space_info) - return -ENOSPC; + if (space_info != delayed_rsv->space_info) { + do_commit = false; + goto commit; + } spin_lock(&delayed_rsv->lock); reclaim_bytes += delayed_rsv->reserved; @@ -4848,15 +4851,18 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, if (__percpu_counter_compare(&space_info->total_bytes_pinned, bytes, - BTRFS_TOTAL_BYTES_PINNED_BATCH) < 0) { - return -ENOSPC; - } - + BTRFS_TOTAL_BYTES_PINNED_BATCH) < 0) + do_commit = false; commit: trans = btrfs_join_transaction(fs_info->extent_root); if (IS_ERR(trans)) return -ENOSPC; + if (!do_commit && + !test_bit(BTRFS_TRANS_HAVE_FREE_BGS, &trans->transaction->flags)) { + btrfs_end_transaction(trans); + return -ENOSPC; + } return btrfs_commit_transaction(trans); } From patchwork Thu Aug 30 17:41:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582437 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 9214A5A4 for ; Thu, 30 Aug 2018 17:42:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80F562C342 for ; Thu, 30 Aug 2018 17:42:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74D752C35E; Thu, 30 Aug 2018 17:42:44 +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 24C552C342 for ; Thu, 30 Aug 2018 17:42:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727475AbeH3Vp5 (ORCPT ); Thu, 30 Aug 2018 17:45:57 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:42330 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbeH3Vp5 (ORCPT ); Thu, 30 Aug 2018 17:45:57 -0400 Received: by mail-qt0-f193.google.com with SMTP id z8-v6so11277190qto.9 for ; Thu, 30 Aug 2018 10:42:42 -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=0rAC9tvuiK7bLRwuUTWbBVuATC+YP1TtV4PYoG5wgv4=; b=FQ94kSllFQlXowCnI8xWF3JlYJckGr1+RBFarizuOTRFmvtbP2fBSLOrD100KzRk9A T0qdbnL7CuQl3dWJdRpn7WmxFG+6eftJTg3XbMsv1lWQB1tYTaXn9dRwnwPO2+w/9mLu vp9ivT1nRObOXl5cfdGglKWv5hV+9uRlRv/GwK0e9eE+WEAvUpasiQ68PMEG2Zmbj8Bn xKZokrCA+C7mdyzbNPChfOYhK/s+znsSDigzP9wqKMs/iDHG/kzsnJ7B/s0zBrM47ltM +uh+sTTPsqO3pcShK1srwMYQ6btm2Yb6Mu2pX57wvvA0zT92yNXZWtFBkrUSXBx3PES7 47Wg== 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=0rAC9tvuiK7bLRwuUTWbBVuATC+YP1TtV4PYoG5wgv4=; b=ZGChLaNkQAGdywu0C+pBSnQ/Exckypd/PorrqlIIV6VKF38JKuTE2nRJzS/OoRPI+x /HoQ1eV+07P4pIA5wgMjpTwTVX8E0jjtIR4h07yAm/uu8/ixZRyiPESE88MIqkZoRtmw j5POnZRNxR3gwz05T2wu7/u+r7W0D4c0zh5CFOSDgeSnLrzxhBpytinCsPvWPUAF8GZn AyycSX1TRUQegtveWeHx89552alSAX2Z3rCsPOKmXyi9FWou/V2yo/PVq4IZEflSYz1m fR75ZZHvOPSTf2wJPl4Es+2TGjdUJPsaejIYWsGkhU5Ily6Bm5gZ/PI1U4quLAfOw+2l RsGQ== X-Gm-Message-State: APzg51CiLhZSAPoWkkmEj7Odes7QuBKLOyTqp1uuudGZgmDQkVmCtYeb 9Ny4jGAYLaxORACLb+KdJQtUS8PLwZSFNA== X-Google-Smtp-Source: ANB0Vda5WzQyzaZGbyi7v2zSi3MMXUBarF+zvO9gRX0euISFqXLd7t3nMsZUTGuIHOoNyIaTZOULsw== X-Received: by 2002:a37:ad0a:: with SMTP id f10-v6mr12400502qkm.186.1535650961307; Thu, 30 Aug 2018 10:42:41 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id p18-v6sm5222995qtp.3.2018.08.30.10.42.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:40 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 07/35] btrfs: dump block_rsv whe dumping space info Date: Thu, 30 Aug 2018 13:41:57 -0400 Message-Id: <20180830174225.2200-8-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 For enospc_debug having the block rsvs is super helpful to see if we've done something wrong. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 80615a579b18..df826f713034 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7910,6 +7910,15 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info, return ret; } +static void dump_block_rsv(struct btrfs_block_rsv *rsv) +{ + spin_lock(&rsv->lock); + printk(KERN_ERR "%d: size %llu reserved %llu\n", + rsv->type, (unsigned long long)rsv->size, + (unsigned long long)rsv->reserved); + spin_unlock(&rsv->lock); +} + static void dump_space_info(struct btrfs_fs_info *fs_info, struct btrfs_space_info *info, u64 bytes, int dump_block_groups) @@ -7929,6 +7938,12 @@ static void dump_space_info(struct btrfs_fs_info *fs_info, info->bytes_readonly); spin_unlock(&info->lock); + dump_block_rsv(&fs_info->global_block_rsv); + dump_block_rsv(&fs_info->trans_block_rsv); + dump_block_rsv(&fs_info->chunk_block_rsv); + dump_block_rsv(&fs_info->delayed_block_rsv); + dump_block_rsv(&fs_info->delayed_refs_rsv); + if (!dump_block_groups) return; From patchwork Thu Aug 30 17:41:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582439 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 12CCB5A4 for ; Thu, 30 Aug 2018 17:42:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01B9E2C342 for ; Thu, 30 Aug 2018 17:42:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA7602C35E; Thu, 30 Aug 2018 17:42:45 +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 9D89D2C342 for ; Thu, 30 Aug 2018 17:42:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727494AbeH3Vp7 (ORCPT ); Thu, 30 Aug 2018 17:45:59 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:36781 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbeH3Vp7 (ORCPT ); Thu, 30 Aug 2018 17:45:59 -0400 Received: by mail-qt0-f196.google.com with SMTP id t5-v6so11316797qtn.3 for ; Thu, 30 Aug 2018 10:42:43 -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=hQA2QiaAcDFMD13ptawL3ysOtVrK0z54ONtFPBPf75M=; b=Ev2toNaFA+TKSNSfcVwWuppv/LQ6jwFD6I8ie6WXzxuUr4qEdchY0EBYI5JbMoI6on 3Ks/SfhVXLClHJI89AgUbiWLBdzWpdBNUB1zo3qE5ZqcTiIUlu9fGIrluxIeriGc6rtv Pf69Bepwfu+uX4teq+/T0EJp+nWaws81oKmxYLWd48b4AqQc1AmB0jgoy2RzMyOmfmiE keuUn6Plwj4dU+gjKRZIjtEoeMv60INMmKfYOMtKz9B1W+dJMlrnTc9kcXXO3sc2z7lr Dj/sRJIZz+9LfaFAbDYNohb0mgdsSZqHJQe5Si4v89evFxPP4Zs592sgGY+0i2J1ofqB 0w3g== 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=hQA2QiaAcDFMD13ptawL3ysOtVrK0z54ONtFPBPf75M=; b=AkB7/j5l/a7OBm/4Sa/YJmmUngsmibMHeypPdKmVbv08bDSgqs5q/0eyB/Jrolrqls PMrw0hRx68gc2p0sjNuZQsIpz4G+3geZKs/LkGjhMHpwyMdPEmT9F4b/xNx5NbTTww35 Pt18RiQ7l80EQ0sWTzdVHVnyBuN3lQl6s+2/9oAGSdBkbbLIW5S6ucjd8uxFyMdc0FTB B3LZ2rt0JYZh9yFXTRm2Yo9BtuPuW0jxGgDBrKxDUqrAq5UaawjwfazvALw6mH9znn+G MvE2tqGNXVhzNbvaQWGp5jY256GDpxxf8UHYyQlkvNIVFqjUwISAOl6jp1gfJctJd+lD 2lUQ== X-Gm-Message-State: APzg51DvnfQyjXYpm1qEkcRxp/+cmaS9JvV2IVtBNDZAzYi4VsHLaPI1 Df78Cit1jTAlPQhc9MOv5Nm5BbIy/rqesw== X-Google-Smtp-Source: ANB0VdYQ0PQDc//oLEWOvl/IFt5D8WOSKvzGNXg1L8aOYGOmUnFUeRBmh4PfzxE544y8ZkJ+5ULj6g== X-Received: by 2002:ae9:e314:: with SMTP id v20-v6mr12580573qkf.69.1535650963083; Thu, 30 Aug 2018 10:42:43 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id p23-v6sm5027360qtf.6.2018.08.30.10.42.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:42 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 08/35] btrfs: release metadata before running delayed refs Date: Thu, 30 Aug 2018 13:41:58 -0400 Message-Id: <20180830174225.2200-9-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 We want to release the unused reservation we have since it refills the delayed refs reserve, which will make everything go smoother when running the delayed refs if we're short on our reservation. Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval Reviewed-by: Nikolay Borisov Reviewed-by: Liu Bo --- fs/btrfs/transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 99741254e27e..ebb0c0405598 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1915,6 +1915,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) return ret; } + btrfs_trans_release_metadata(trans); + trans->block_rsv = NULL; + /* make a pass through all the delayed refs we have so far * any runnings procs may add more while we are here */ @@ -1924,9 +1927,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) return ret; } - btrfs_trans_release_metadata(trans); - trans->block_rsv = NULL; - cur_trans = trans->transaction; /* From patchwork Thu Aug 30 17:41:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582441 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 795C517DE for ; Thu, 30 Aug 2018 17:42:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 688742C342 for ; Thu, 30 Aug 2018 17:42:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CD9F2C35E; Thu, 30 Aug 2018 17:42:47 +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 0CF7A2C342 for ; Thu, 30 Aug 2018 17:42:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727502AbeH3VqA (ORCPT ); Thu, 30 Aug 2018 17:46:00 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:33380 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726727AbeH3VqA (ORCPT ); Thu, 30 Aug 2018 17:46:00 -0400 Received: by mail-qk1-f194.google.com with SMTP id z78-v6so22638qka.0 for ; Thu, 30 Aug 2018 10:42:45 -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=kU9V3lvyuRw1EbYvwZbyCQBU1wFCwS4cJYSwYekxq9E=; b=lyAGcGSb7g+Fcqcu6s2vChy4m0EZKnWDh68Gng7rXhn4ICGYTy0DWJKC613BzNwBhy HK+jSLtPRokIyTwil+yTtaGnN+32dS/lVb1eSZtCTEGN6gh4/Isdci9lUaJOvgs9q5ZZ kTNV2Kcn72Rrv2Wv/ygyrqagtkROHSmUiyCxvjxwrpHRNjtrl20prZvtYrJu0HYqlJ/A ViMyQcBlDzvLw+eHAbAmaasNsHRsRpydLVnUSTZYRlCn2IdDFGQ8lffNM2WFZHkP/mu4 tkbdBviGSPl9dMxB6Bk+5q9KFe3cK0K3xGxmbnfP7qYAAjw1ULAvHM+a8brkhi+0cCcc UuQA== 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=kU9V3lvyuRw1EbYvwZbyCQBU1wFCwS4cJYSwYekxq9E=; b=BBu1vkDI3j53aOhZZqjn+LEoetPBnY5PMyhpLUQTMxZGJ5pBy2IkhjHRdqdEfbBZLa pYboOJVbBz1F4UQNwYRXPTTlwnLohdoQO7CKkbmzAdA+sl0BRVqDCvnuGg7r2sbPxIUH xL06ly4cE4qb1CL5aoXzK1LODvwZvoHRFdpeMh+NewUSXNkfQqnn4p19s6mWNgnF1Mtw WhmTtbQDzZPXoqKqTkBBlfbdxumGCeFN8a8Ukc+1IgI2aQ8WigwXqlKo6mSXTzrcdSR0 TE6f8Vzv1cgWCBor48us1gBs6BL4ifCb3lB49UUmcH4GE+b33GMN9VCY+Tr6CqGOqbrg 4r1Q== X-Gm-Message-State: APzg51BVIBiJ9TdyNzVMApimYFiuPGon3g34QznhqsaGLBI6ga20bNTb +jtxmrIVm8/kdb6ZhoCVxrDg5V/99eYnng== X-Google-Smtp-Source: ANB0VdZISCWWi/ugJnUeWslqhFXJvu1M8DQ8BqXOdv2V71Ll76bg9EeAk3RTX0flYamV6BNOI2eTmw== X-Received: by 2002:a37:4a46:: with SMTP id x67-v6mr12509106qka.60.1535650964865; Thu, 30 Aug 2018 10:42:44 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id y142-v6sm4207288qka.5.2018.08.30.10.42.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:43 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 09/35] btrfs: protect space cache inode alloc with nofs Date: Thu, 30 Aug 2018 13:41:59 -0400 Message-Id: <20180830174225.2200-10-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 If we're allocating a new space cache inode it's likely going to be under a transaction handle, so we need to use memalloc_nofs_save() in order to avoid deadlocks, and more importantly lockdep messages that make xfstests fail. Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval --- fs/btrfs/free-space-cache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index c3888c113d81..db93a5f035a0 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "ctree.h" #include "free-space-cache.h" #include "transaction.h" @@ -47,6 +48,7 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root, struct btrfs_free_space_header *header; struct extent_buffer *leaf; struct inode *inode = NULL; + unsigned nofs_flag; int ret; key.objectid = BTRFS_FREE_SPACE_OBJECTID; @@ -68,7 +70,9 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root, btrfs_disk_key_to_cpu(&location, &disk_key); btrfs_release_path(path); + nofs_flag = memalloc_nofs_save(); inode = btrfs_iget(fs_info->sb, &location, root, NULL); + memalloc_nofs_restore(nofs_flag); if (IS_ERR(inode)) return inode; From patchwork Thu Aug 30 17:42:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582443 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 0BD8617DE for ; Thu, 30 Aug 2018 17:42:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDD6D2C34B for ; Thu, 30 Aug 2018 17:42:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0AC52C35E; Thu, 30 Aug 2018 17:42:49 +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 7214A2C342 for ; Thu, 30 Aug 2018 17:42:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727271AbeH3VqD (ORCPT ); Thu, 30 Aug 2018 17:46:03 -0400 Received: from mail-qt0-f172.google.com ([209.85.216.172]:34040 "EHLO mail-qt0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqC (ORCPT ); Thu, 30 Aug 2018 17:46:02 -0400 Received: by mail-qt0-f172.google.com with SMTP id m13-v6so11332704qth.1 for ; Thu, 30 Aug 2018 10:42:47 -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=mF05QDPtkYklFH9N7AHCrveKet6hlcBDmcpEwQiI+8E=; b=veLW4agFKggLnBcxJrCYUQXaml/ABD3ZimDw+Vdq+a3O52toTj5W+kafri903oVQ8Y JVwm9mmWZPhgTTUgG9G3EzM2IGL2MF7KjJUWkEn5z7i2LCx92UqTBKoy16a7/ply7Uje 0XDB8gaNgQyrC/OPxlOwlkjeVOUoW5ozVuZ2/9pOmynVZ2x2vJoO3EPSrTfRq6VBv50w y2jn6w5nA1UpiSA6dolbmO06G/LHBv1E9Z8I35oDdLVU9B8Cp7LbECB0bjaMn8+Sr48B hQV2gWZFZlDy6PjVxQL5g4XEKT92C9WO9aPHkysb8pJX6cI6u57Pqf7WdANcPotnsF9u ZESg== 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=mF05QDPtkYklFH9N7AHCrveKet6hlcBDmcpEwQiI+8E=; b=j5XEjAVPEsqFBOLZX0kdmEOxdsPGgTbVJKYno8KdBuYGX2vVjmqXFlHy28l/ogutil 7OcfnrZvzvc1yya45rGPIYBNpgCSX4tZ4gHLEXMBASCTl8c081L+LG0jkhnEAc41d1/F zgN7ROUUuM74Zuilq1CN6FxA6rqjanRy+kIOg1xVspP8y5thiU31W8IcL6f+nmYzBUcY BDqVvh892z3CuxsGMEJESfKB8YzIwtcrDZpzIbqSF/UdFOD+MESKkB75vqP7ui9GMJAI +GhfyU5V6JIa7+MguA0RrtweKMRcSInpmlfIm2Uw+KcMoy3UZqHgAFFrxSfFKFBCcFD/ audQ== X-Gm-Message-State: APzg51Cz+A9N06eUCHVTU5ckqV2gn70Lv+hgIP5c1biAkqkt9zrWBBRA H++cfwcYCAP8ntuR716XLd7e6pB8xUIERg== X-Google-Smtp-Source: ANB0Vdb371x/hKi+W6DGIHc8RQvCYzFVadGWX21UkF/BJbaqCgmTkm8DtDNkn5HoCzKfydOKFR8xzw== X-Received: by 2002:ac8:5210:: with SMTP id r16-v6mr12901007qtn.11.1535650966602; Thu, 30 Aug 2018 10:42:46 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id c15-v6sm4129624qkm.42.2018.08.30.10.42.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:45 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 10/35] btrfs: fix truncate throttling Date: Thu, 30 Aug 2018 13:42:00 -0400 Message-Id: <20180830174225.2200-11-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 We have a bunch of magic to make sure we're throttling delayed refs when truncating a file. Now that we have a delayed refs rsv and a mechanism for refilling that reserve simply use that instead of all of this magic. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 78 ++++++++++++-------------------------------------------- 1 file changed, 16 insertions(+), 62 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 212fa71317d6..10455d0aa71c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4493,31 +4493,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) return err; } -static int truncate_space_check(struct btrfs_trans_handle *trans, - struct btrfs_root *root, - u64 bytes_deleted) -{ - struct btrfs_fs_info *fs_info = root->fs_info; - int ret; - - /* - * This is only used to apply pressure to the enospc system, we don't - * intend to use this reservation at all. - */ - bytes_deleted = btrfs_csum_bytes_to_leaves(fs_info, bytes_deleted); - bytes_deleted *= fs_info->nodesize; - ret = btrfs_block_rsv_add(root, &fs_info->trans_block_rsv, - bytes_deleted, BTRFS_RESERVE_NO_FLUSH); - if (!ret) { - trace_btrfs_space_reservation(fs_info, "transaction", - trans->transid, - bytes_deleted, 1); - trans->bytes_reserved += bytes_deleted; - } - return ret; - -} - /* * Return this if we need to call truncate_block for the last bit of the * truncate. @@ -4562,7 +4537,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, u64 bytes_deleted = 0; bool be_nice = false; bool should_throttle = false; - bool should_end = false; BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY); @@ -4775,15 +4749,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, btrfs_abort_transaction(trans, ret); break; } - if (btrfs_should_throttle_delayed_refs(trans, fs_info)) - btrfs_async_run_delayed_refs(fs_info, - trans->delayed_ref_updates * 2, - trans->transid, 0); if (be_nice) { - if (truncate_space_check(trans, root, - extent_num_bytes)) { - should_end = true; - } if (btrfs_should_throttle_delayed_refs(trans, fs_info)) should_throttle = true; @@ -4795,7 +4761,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, if (path->slots[0] == 0 || path->slots[0] != pending_del_slot || - should_throttle || should_end) { + should_throttle) { if (pending_del_nr) { ret = btrfs_del_items(trans, root, path, pending_del_slot, @@ -4807,23 +4773,23 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, pending_del_nr = 0; } btrfs_release_path(path); - if (should_throttle) { - unsigned long updates = trans->delayed_ref_updates; - if (updates) { - trans->delayed_ref_updates = 0; - ret = btrfs_run_delayed_refs(trans, - updates * 2); - if (ret) - break; - } - } + /* - * if we failed to refill our space rsv, bail out - * and let the transaction restart + * We can generate a lot of delayed refs, so we need to + * throttle every once and a while and make sure we're + * adding enough space to keep up with the work we are + * generating. Since we hold a transaction here we can + * only FLUSH_LIMIT, if this fails we just return EAGAIN + * and let the normal space allocation stuff do it's + * work. */ - if (should_end) { - ret = -EAGAIN; - break; + if (should_throttle) { + ret = btrfs_refill_delayed_refs_rsv(fs_info, + BTRFS_RESERVE_FLUSH_LIMIT); + if (ret) { + ret = -EAGAIN; + break; + } } goto search_again; } else { @@ -4849,18 +4815,6 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, } btrfs_free_path(path); - - if (be_nice && bytes_deleted > SZ_32M && (ret >= 0 || ret == -EAGAIN)) { - unsigned long updates = trans->delayed_ref_updates; - int err; - - if (updates) { - trans->delayed_ref_updates = 0; - err = btrfs_run_delayed_refs(trans, updates * 2); - if (err) - ret = err; - } - } return ret; } From patchwork Thu Aug 30 17:42:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582445 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 9874F5A4 for ; Thu, 30 Aug 2018 17:42:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 864942C34B for ; Thu, 30 Aug 2018 17:42:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A5F52C35F; Thu, 30 Aug 2018 17:42:51 +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 268692C34B for ; Thu, 30 Aug 2018 17:42:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727521AbeH3VqE (ORCPT ); Thu, 30 Aug 2018 17:46:04 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:39486 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqE (ORCPT ); Thu, 30 Aug 2018 17:46:04 -0400 Received: by mail-qt0-f194.google.com with SMTP id o15-v6so11286379qtk.6 for ; Thu, 30 Aug 2018 10:42:49 -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=KxD4zZYGrkiS/KH9ef2/jTBi92YtXUr6II8ijYi0L2s=; b=xHthkQw9EmRT1TtCZPhGFX9xHVcDfblgQSKgQj4gnHqzIIHQBgzhJnEUxW7LHXdJmA ShAdGxgrZ/xieqzRiohzld1uNQAlq9Ni90+eM3BXBYbW88noFT3utFXaOoo8pDxN9eBD nkPCIPC/CaAVWKf98S/6uSBXftNzTUnSQBLb86oc3r5bJbWbU+P7RycrU6RVbDGn8LRN wbJY25fVC1VTYdpIQytbjApd4H+j3/k+R/DwxeXAdbqjz0r1KUqDVo76N2OcLFHNkIo+ OujfV2qHYylgfUyMVLtXLoQuBru/y2Pjp171gXKbMW6DqvuE24sTYg8W3lQaCiY2TRdO Zp/Q== 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=KxD4zZYGrkiS/KH9ef2/jTBi92YtXUr6II8ijYi0L2s=; b=M1AeHdPpsZFgNEqGHtyJaIc4icC4q0maOSduu7vKHLezcsUi67H7+c2diX/taNInRR EIBbVh4CMjIcR8kCFnYS3fP7vDmdxvjPBZvbOlKC1hQkGraaKaVwM8fwUoYxBxBLcf5A 2wc2qatRzQuhGpt7omuwVojxwCvn7beAg4jdepgh+c4w/CKw0pYTNvU/hb3gvb1VojuM smxbFE8q5hS9h7rAiSirgtJWnkpbo3ejDXlYWRqp6e6Paw7Wx/Fp9m3rSvBoPH35J51u JSyXn9ux8zP4Ev17TapY9yyHBnshUx9t/B4pmRNL+mnRXsYZN52In1ZvX7pawASDoXyR LYOA== X-Gm-Message-State: APzg51DAHv8T/5tiXeg8jYOkif3t1I1qwpXz5YHP3/Yth3LUMsZBroRh mm3zVWouB0YKaIoEz1zGSCY0hF2kFggLHA== X-Google-Smtp-Source: ANB0VdbHp+XidXE4k25h/GuJ2/k9KuCUe1SWQKeHlefVj7kD4sHPxfFNks2mkU41VnNg5LzjF35DvA== X-Received: by 2002:a37:1adb:: with SMTP id l88-v6mr11835354qkh.43.1535650968416; Thu, 30 Aug 2018 10:42:48 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id f23-v6sm4870934qtc.65.2018.08.30.10.42.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:47 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 11/35] btrfs: don't use global rsv for chunk allocation Date: Thu, 30 Aug 2018 13:42:01 -0400 Message-Id: <20180830174225.2200-12-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 We've done this forever because of the voodoo around knowing how much space we have. However we have better ways of doing this now, and on normal file systems we'll easily have a global reserve of 512MiB, and since metadata chunks are usually 1GiB that means we'll allocate metadata chunks more readily. Instead use the actual used amount when determining if we need to allocate a chunk or not. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index df826f713034..783341e3653e 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4366,21 +4366,12 @@ static inline u64 calc_global_rsv_need_space(struct btrfs_block_rsv *global) static int should_alloc_chunk(struct btrfs_fs_info *fs_info, struct btrfs_space_info *sinfo, int force) { - struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; u64 bytes_used = btrfs_space_info_used(sinfo, false); u64 thresh; if (force == CHUNK_ALLOC_FORCE) return 1; - /* - * We need to take into account the global rsv because for all intents - * and purposes it's used space. Don't worry about locking the - * global_rsv, it doesn't change except when the transaction commits. - */ - if (sinfo->flags & BTRFS_BLOCK_GROUP_METADATA) - bytes_used += calc_global_rsv_need_space(global_rsv); - /* * in limited mode, we want to have some free space up to * about 1% of the FS size. From patchwork Thu Aug 30 17:42: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: 10582447 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 2140417DE for ; Thu, 30 Aug 2018 17:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B05E27CEE for ; Thu, 30 Aug 2018 17:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F34B22C35F; Thu, 30 Aug 2018 17:42:52 +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 92FB02C363 for ; Thu, 30 Aug 2018 17:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727536AbeH3VqG (ORCPT ); Thu, 30 Aug 2018 17:46:06 -0400 Received: from mail-qt0-f177.google.com ([209.85.216.177]:45819 "EHLO mail-qt0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqG (ORCPT ); Thu, 30 Aug 2018 17:46:06 -0400 Received: by mail-qt0-f177.google.com with SMTP id g44-v6so11257305qtb.12 for ; Thu, 30 Aug 2018 10:42:50 -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=5NmhNwD7gQYYw449r9Kp/13F/zzYmanGbb7uHn9UesE=; b=OEoSy9BtEQJMfZIaHGxPZhMOQo4uDR2a/PIveZG5voFyxhq0VM4FHLMZV4pfYCjlzk Q9OOb9jDp6uSVGVQWtisKCG/XorCLjc7r+BmxgqRMmD+3DprvBCGh6AEbckDJFFkxSKz I6O9aYO6/R6e7TJs4SuGfK4RhtXyRdPg3/CD1M7s3zoKkTn2L+AlzuUBYWWthRFDDsrI nL7K2FSJnRFMh3GmOIWp7sZ60Bh27L7AL+L9VOIb2P0uIRyFRNOTgAo6fkEPxT6rY43l hvz8iWhs+Ahqx5ceXD9K+crFjAdemYXAA0JjB9EVd4Lm6fRAbcw52u/m/75SG+FGFacv wF9g== 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=5NmhNwD7gQYYw449r9Kp/13F/zzYmanGbb7uHn9UesE=; b=An3zdgOxjUz14cOGW0vUDiSCaPgihUaDUWAshHqYds7fdT4HDpO3QVXdJTrnpxsE5k 0Ym9LuZ1LRp1XnrOcxjo2V9q6AwCx7EdOycgGFFWML1pkc7/BgpEuWUbJ372R4LtA0us 7oZC6GZLbkyJTSqUQJIbABqNm3vvdn8NGerxL9hwY/qbVMLTUhKu5GMSmyzfrBvDTWIL j0gYai1v6MpcwtP2UX4K8WFT+cBOmy5Ugij4E5rwDjdnoz7+ZUJ5Sl1hQjJ/vMiU74Yv jm0V8Av4S5TXMgDEIZx4e0nAP31fCJ7h1o5VUKShcRFmci7IxHcGd5vBh5eC6tSMwHUM G57Q== X-Gm-Message-State: APzg51BoJ8f3FHXsxfr5zWDhYPZl4OVCDPu4XYrLs4FQY5ztDjuTxsix aZHH0mPiaMoY7GqAzhFojUtUimEJTZ+0cg== X-Google-Smtp-Source: ANB0VdaoZfqT/1d94lQp7NYvccX2tPDNaQTVkOiSdYR8MMxJMLQ5H2UvVi3jUpaXamO7ccwNkN9Ytw== X-Received: by 2002:ac8:1019:: with SMTP id z25-v6mr13251063qti.25.1535650970152; Thu, 30 Aug 2018 10:42:50 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id w9-v6sm5170148qta.13.2018.08.30.10.42.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:49 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 12/35] btrfs: add ALLOC_CHUNK_FORCE to the flushing code Date: Thu, 30 Aug 2018 13:42:02 -0400 Message-Id: <20180830174225.2200-13-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 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 0a4e55703d48..791e287c2292 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2731,7 +2731,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 783341e3653e..22e1f9f55f4f 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4907,6 +4907,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); @@ -4914,7 +4915,9 @@ static void flush_space(struct btrfs_fs_info *fs_info, } ret = do_chunk_alloc(trans, 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; @@ -5060,6 +5063,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 7d205e50b09c..fdb23181b5b7 100644 --- a/include/trace/events/btrfs.h +++ b/include/trace/events/btrfs.h @@ -1051,6 +1051,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, From patchwork Thu Aug 30 17:42:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582449 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 B1C7017DE for ; Thu, 30 Aug 2018 17:42:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FF1A284DA for ; Thu, 30 Aug 2018 17:42:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92C6428676; Thu, 30 Aug 2018 17:42:54 +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 2ECD9284DA for ; Thu, 30 Aug 2018 17:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727552AbeH3VqH (ORCPT ); Thu, 30 Aug 2018 17:46:07 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:33843 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqH (ORCPT ); Thu, 30 Aug 2018 17:46:07 -0400 Received: by mail-qt0-f193.google.com with SMTP id m13-v6so11333170qth.1 for ; Thu, 30 Aug 2018 10:42:52 -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=8E5OuvZ7AaYb8DpVhuhicVW4rDtNpOHtUOUobLOXJHU=; b=2EH9NM7gZC77fH2ttjxeB9AwptS1Yra1DE+Z5CHTASu+RJjzQ+LpE40LnoSFknCnJ4 +pJYiQdLBqTAOoteeE+svVvBhJQiU0P3r+V02EhH61M0cTT2bhsvQ/sika68zLD7MQ2I THphCS1XIs64YIUNb/Ikyqir6SODZxI0pQazQljBTb3K4aYWT3FkAJMGTvz4NGQWsfdW xY4bCjyQ+rZHd8/zBhndxs1T4+gKRhx5nThYgEWVDMovhIJvbM0S6niXJkYOe46jPwbb umqvN4A20fNEE28gB6/0RIl6leAISM/WwDzuRC5/bWkVog/7HcuQ0q0C3CyM6sW9bgMB m25g== 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=8E5OuvZ7AaYb8DpVhuhicVW4rDtNpOHtUOUobLOXJHU=; b=FXvdHtZvzr91YzTeGPRR3/KYJiKozd4rlFmF3bNtzHvpYguPbyEn7NVys8fImiLp44 jxyurYU48Y7HSdgLAM5MB6Vmzkjz+JdgttumgpVZRtVhWsESxs3n6+awBnZNfqZH/z2M Yc7HNVZicjuSenY/gKjtdqgTkAYf2/Keh72LraDQf5sXUVo9pMMBScJTA8jTv1VVAVNV y19zChT71i9lV5ZiwHwrPtBJQm1DByV8/0OESMX27u+fPR2sOTHkKxVpDaHFQ4RETfae MoLMno/Y3XVP7bg7z28WzSQieFcoak4zGildtMg+sUb2X6NfN3KSL8tel2hlys++8DeV aFqA== X-Gm-Message-State: APzg51CJnzQ1TwHK2cudZ0Xf4LGSPZn2VE7yeHJZyrmqLZyRsuY2ZLfy fU+U07Y9O2elYFZQ2vx8wbcbiJEcWwdcHQ== X-Google-Smtp-Source: ANB0VdYNUVYYj9p+tMCOFBoEYtQO9uRl2wENlnpilX0MVKcrYhzQ0/4nZmVx8Outqw2gEaZX4iPK/g== X-Received: by 2002:a37:ad03:: with SMTP id f3-v6mr4436717qkm.140.1535650971883; Thu, 30 Aug 2018 10:42:51 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id k21-v6sm3963986qtj.11.2018.08.30.10.42.50 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:51 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 13/35] btrfs: reset max_extent_size properly Date: Thu, 30 Aug 2018 13:42:03 -0400 Message-Id: <20180830174225.2200-14-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 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. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 22e1f9f55f4f..f4e7caf37d6c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4565,6 +4565,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags, goto out; } else { ret = 1; + space_info->max_extent_size = 0; } space_info->force_alloc = CHUNK_ALLOC_NO_FORCE; @@ -8064,11 +8065,17 @@ static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, if (pin) pin_down_extent(fs_info, cache, start, len, 1); else { + struct btrfs_space_info *space_info = cache->space_info; + if (btrfs_test_opt(fs_info, DISCARD)) ret = btrfs_discard_extent(fs_info, start, len, NULL, BTRFS_CLEAR_OP_DISCARD); btrfs_add_free_space(cache, start, len); btrfs_free_reserved_bytes(cache, len, delalloc); + + spin_lock(&space_info->lock); + space_info->max_extent_size = 0; + spin_unlock(&space_info->lock); trace_btrfs_reserved_extent_free(fs_info, start, len); } From patchwork Thu Aug 30 17:42:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582451 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 2431F5A4 for ; Thu, 30 Aug 2018 17:42:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12DE0284DA for ; Thu, 30 Aug 2018 17:42:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0749728676; Thu, 30 Aug 2018 17:42:57 +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 86F1F284DA for ; Thu, 30 Aug 2018 17:42:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727563AbeH3VqK (ORCPT ); Thu, 30 Aug 2018 17:46:10 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:41257 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqK (ORCPT ); Thu, 30 Aug 2018 17:46:10 -0400 Received: by mail-qt0-f193.google.com with SMTP id t39-v6so11277268qtc.8 for ; Thu, 30 Aug 2018 10:42:54 -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=Fo6EOyJtNYgs9weKg1tN5gFaXxf6U3sEn1FWsWite88=; b=rL3IF81iof928+mTNi2deYs5VbCEzr1xWdrK1bEb9i+4jE8+ZiskiGOK7iP74aaq5q yCQ8+VgBHRQEy0oU2QkzWUCESjagVaTW78ugRLciWASaIaj0TpGZeMxP1rHMYzC+zcmx NatT58T7/PwRll1hqz/G+imuv5SxeIUwn1BEjG/r4rByo6m6ZUPnNhaG8ToyiiYOhEw0 hEv+xW+EWogk+awV2SlNDXOeIA7j5YbJi74+sQbeu7SccfCTbcGpRuo59GSnSXdiJF15 WvMqz8/ZnPCfHT/gyEvmUUYVy6JOCo7k2HY1oGzmFMuMwJur3GB8MhKXLS/K2UD/duDG JU9A== 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=Fo6EOyJtNYgs9weKg1tN5gFaXxf6U3sEn1FWsWite88=; b=olOO6qJTt7qCpNOtRuGSZZUyWvAQ8VqH36ZBx6+pweEgBJ7CctMQLCPCIeMMeWuFTW H6TdDMv9PnYOW9hZv1LsKrurID4VUklahi2LbmRNUN4uCKcVj3PCGHOLy6/dIADAjLvu 5ygCxdi3XQbhiiwGX+T5hD4yj5yF+jPkRytPv4BxpBZO8eH8b0Tj21tcEvph0y4HT9ov H9YLNMjKIp/IhNZzv6fPFfE8L1iPvTvQFhTwgS3xbsvq1FX4DfAtGfOX44Sbq23YPrKM WSeduNHMM5wau9y8BaulEixuZeMWNsbxxS+jTXF0IdQJx9epiw0eoJmnZQLzCc4mtxyU kJjg== X-Gm-Message-State: APzg51DPp6P3Fhex6CKanmkdp19JQiscghhRqALOpzEoY0Kil1U5hgD4 BKiMDcQhc2X8dyBAaqKc+oDp7jWY5iEzOw== X-Google-Smtp-Source: ANB0Vdabjs+DTBZlUqxdszqWew/QtGTCptzdLNw9u/3CSFLHO/dWwT1blruuEd+YYO562YNMI9tEnw== X-Received: by 2002:ac8:2481:: with SMTP id s1-v6mr13025892qts.87.1535650973666; Thu, 30 Aug 2018 10:42:53 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id p57-v6sm4902413qtj.42.2018.08.30.10.42.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:52 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 14/35] btrfs: don't enospc all tickets on flush failure Date: Thu, 30 Aug 2018 13:42:04 -0400 Message-Id: <20180830174225.2200-15-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 With the introduction of the per-inode block_rsv it became possible to have really really large reservation requests made because of data fragmentation. Since the ticket stuff assumed that we'd always have relatively small reservation requests it just killed all tickets if we were unable to satisfy the current request. However this is generally not the case anymore. So fix this logic to instead see if we had a ticket that we were able to give some reservation to, and if we were continue the flushing loop again. Likewise we make the tickets use the space_info_add_old_bytes() method of returning what reservation they did receive in hopes that it could satisfy reservations down the line. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index f4e7caf37d6c..7c0e99e1f56c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4771,6 +4771,7 @@ static void shrink_delalloc(struct btrfs_fs_info *fs_info, u64 to_reclaim, } struct reserve_ticket { + u64 orig_bytes; u64 bytes; int error; struct list_head list; @@ -4993,7 +4994,7 @@ static inline int need_do_async_reclaim(struct btrfs_fs_info *fs_info, !test_bit(BTRFS_FS_STATE_REMOUNTING, &fs_info->fs_state)); } -static void wake_all_tickets(struct list_head *head) +static bool wake_all_tickets(struct list_head *head) { struct reserve_ticket *ticket; @@ -5002,7 +5003,10 @@ static void wake_all_tickets(struct list_head *head) list_del_init(&ticket->list); ticket->error = -ENOSPC; wake_up(&ticket->wait); + if (ticket->bytes != ticket->orig_bytes) + return true; } + return false; } /* @@ -5057,8 +5061,12 @@ static void btrfs_async_reclaim_metadata_space(struct work_struct *work) if (flush_state > COMMIT_TRANS) { commit_cycles++; if (commit_cycles > 2) { - wake_all_tickets(&space_info->tickets); - space_info->flush = 0; + if (wake_all_tickets(&space_info->tickets)) { + flush_state = FLUSH_DELAYED_ITEMS_NR; + commit_cycles--; + } else { + space_info->flush = 0; + } } else { flush_state = FLUSH_DELAYED_ITEMS_NR; } @@ -5112,10 +5120,11 @@ static void priority_reclaim_metadata_space(struct btrfs_fs_info *fs_info, static int wait_reserve_ticket(struct btrfs_fs_info *fs_info, struct btrfs_space_info *space_info, - struct reserve_ticket *ticket, u64 orig_bytes) + struct reserve_ticket *ticket) { DEFINE_WAIT(wait); + u64 reclaim_bytes = 0; int ret = 0; spin_lock(&space_info->lock); @@ -5136,14 +5145,12 @@ static int wait_reserve_ticket(struct btrfs_fs_info *fs_info, ret = ticket->error; if (!list_empty(&ticket->list)) list_del_init(&ticket->list); - if (ticket->bytes && ticket->bytes < orig_bytes) { - u64 num_bytes = orig_bytes - ticket->bytes; - space_info->bytes_may_use -= num_bytes; - trace_btrfs_space_reservation(fs_info, "space_info", - space_info->flags, num_bytes, 0); - } + if (ticket->bytes && ticket->bytes < ticket->orig_bytes) + reclaim_bytes = ticket->orig_bytes - ticket->bytes; spin_unlock(&space_info->lock); + if (reclaim_bytes) + space_info_add_old_bytes(fs_info, space_info, reclaim_bytes); return ret; } @@ -5169,6 +5176,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, { struct reserve_ticket ticket; u64 used; + u64 reclaim_bytes = 0; int ret = 0; ASSERT(orig_bytes); @@ -5204,6 +5212,7 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, * the list and we will do our own flushing further down. */ if (ret && flush != BTRFS_RESERVE_NO_FLUSH) { + ticket.orig_bytes = orig_bytes; ticket.bytes = orig_bytes; ticket.error = 0; init_waitqueue_head(&ticket.wait); @@ -5244,25 +5253,21 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, return ret; if (flush == BTRFS_RESERVE_FLUSH_ALL) - return wait_reserve_ticket(fs_info, space_info, &ticket, - orig_bytes); + return wait_reserve_ticket(fs_info, space_info, &ticket); ret = 0; priority_reclaim_metadata_space(fs_info, space_info, &ticket); spin_lock(&space_info->lock); if (ticket.bytes) { - if (ticket.bytes < orig_bytes) { - u64 num_bytes = orig_bytes - ticket.bytes; - space_info->bytes_may_use -= num_bytes; - trace_btrfs_space_reservation(fs_info, "space_info", - space_info->flags, - num_bytes, 0); - - } + if (ticket.bytes < orig_bytes) + reclaim_bytes = orig_bytes - ticket.bytes; list_del_init(&ticket.list); ret = -ENOSPC; } spin_unlock(&space_info->lock); + + if (reclaim_bytes) + space_info_add_old_bytes(fs_info, space_info, reclaim_bytes); ASSERT(list_empty(&ticket.list)); return ret; } From patchwork Thu Aug 30 17:42:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582453 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 43D3417DE for ; Thu, 30 Aug 2018 17:42:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C6E284DA for ; Thu, 30 Aug 2018 17:42:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2891328676; Thu, 30 Aug 2018 17:42:58 +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 D081D284DA for ; Thu, 30 Aug 2018 17:42:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727572AbeH3VqL (ORCPT ); Thu, 30 Aug 2018 17:46:11 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:38099 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqL (ORCPT ); Thu, 30 Aug 2018 17:46:11 -0400 Received: by mail-qt0-f193.google.com with SMTP id x7-v6so11304078qtk.5 for ; Thu, 30 Aug 2018 10:42:56 -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=iVdjKP73AAIgXhtYXJOwe/s1mAUajIn/crILotUVzmE=; b=K3U7yiReTNV8tLdlhlyCDveaiyYKD6/S1YomreVW9abR6MgP/aTV13WO/pFdg0iGBj CP/AfEQ32ggKi6OdSuISyqbem6zfO+lqANTdm7cIXfyTObDUW5KteNud2RyVX2oogjss 8d2kf8hymTjIZDJR7S7tewGoF0EsPMgmTiq3ZUe3p66OvND2JHsplkfUzHqrQWzonVQj DqqEEMv4HNJnT5rfzKuWa0KE4iJVQJxnyEHmJphxIwyQz0W2yidwNJ1MmmxLnfw7qpwU qK9ZmUFhVOLMtyBqBTXnaNcNNmWvWeO9PSYTSIKFVmyu+BpyMFxjOhXn5gu2XUbLYS1Q bpwQ== 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=iVdjKP73AAIgXhtYXJOwe/s1mAUajIn/crILotUVzmE=; b=AIXeNKrzjEfsc0gM4jXf5Id8LUp3ypNlW9XrO0I2KyUMHgwGyGfovIyzaEohzYQ3eN YXtgT4k+fhi43AOhCOm337PROwa/0CeyzpsF7DDDM7eIsNMDpKsDalbaZEfHsY1PTwWv 3awhjSRnWp5cvBFcMfCFrf2s3/VbJZzbhuFB79ZjwPnAdnLpfNNdl4aN2z5IkvG79Sb7 RYSyWVR51LORle7s2t/bpSv9uGPL9aKknrrhL3SCc/60vf4Y+x1wlMQ4lmGghxWtPXFj tqVMN7N4e1b8ZZBY0IE5Fp67LLnfhTjBq9ooPYl/2DEYgbQGJFFLlr4+E+Fp+RF2bfG3 7MUA== X-Gm-Message-State: APzg51AW72AzIaWGN5hxxIEjutv+ENBHswwUSjw19X7VK8Ix1q4pgfIH 2lo23nlJ2qkQrvB3DbJF3JSWgQ8U+dGGJg== X-Google-Smtp-Source: ANB0VdZibFGxS1vgCRNXEP6eY/HUHh2D0ur4/JpobQ7Ljla+QbCV5JvW/+PBPDGlNYiiwKFFfNRH4A== X-Received: by 2002:ac8:3c3:: with SMTP id z3-v6mr13021518qtg.39.1535650975493; Thu, 30 Aug 2018 10:42:55 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id f129-v6sm4097800qkb.40.2018.08.30.10.42.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:54 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 15/35] btrfs: run delayed iputs before committing Date: Thu, 30 Aug 2018 13:42:05 -0400 Message-Id: <20180830174225.2200-16-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 We want to have a complete picture of any delayed inode updates before we make the decision to commit or not, so make sure we run delayed iputs before making the decision to commit or not. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 7c0e99e1f56c..064db7ebaf67 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -4831,6 +4831,10 @@ static int may_commit_transaction(struct btrfs_fs_info *fs_info, goto commit; } + mutex_lock(&fs_info->cleaner_delayed_iput_mutex); + btrfs_run_delayed_iputs(fs_info); + mutex_unlock(&fs_info->cleaner_delayed_iput_mutex); + spin_lock(&delayed_rsv->lock); reclaim_bytes += delayed_rsv->reserved; spin_unlock(&delayed_rsv->lock); From patchwork Thu Aug 30 17:42:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582455 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 EE7CA17DE for ; Thu, 30 Aug 2018 17:42:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD75F284DA for ; Thu, 30 Aug 2018 17:42:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D20C128676; Thu, 30 Aug 2018 17:42:59 +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 7B776284DA for ; Thu, 30 Aug 2018 17:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727579AbeH3VqN (ORCPT ); Thu, 30 Aug 2018 17:46:13 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:46091 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqN (ORCPT ); Thu, 30 Aug 2018 17:46:13 -0400 Received: by mail-qt0-f196.google.com with SMTP id d4-v6so11271525qtn.13 for ; Thu, 30 Aug 2018 10:42:57 -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=jJPeB19zhafSC+yi5Z5s/Zy/SgSSyvmQWLZyzp2Gm9E=; b=FMTVQn156BkVpMlU2gFYQmaYyijTlskF9YhgisCN+VEFBAUwvPijUccbeUludyQOcz UuuMEuu2h14VpvG/pFftRPvvUTRX3YO3p7k+0r8x1AFug/MMfubb4/SQecQ2u8BZ1SVM mf1ZjHag1J14LFMm57hDUUrCpdg1oCi/1hQRE3Z5eW3oD33p0cLFFgQC+UjfEsawW2A2 weEJ0t6Ee+332DLZqCQWdqMiHU0MDb974cpeyGxf/zH379twWxRX24LloBSPMnCmlSXu AaPYwfXpM/xnoQA/G5TokgxWd2Bu39lHKgdyL+vcbbDhmNTQyLoE+1ttBPSMKkwdlcET zdYQ== 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=jJPeB19zhafSC+yi5Z5s/Zy/SgSSyvmQWLZyzp2Gm9E=; b=VG/7eOJU0bU0N64Z52aMX3s7cNefZ1ygvRud6ftmqBDL5JPhEs9whUzvhwFXwfC+bF F2kGqv5PTJ39tCVQtmL26iSytEAxmawgvdEy0+m/2zRCysp1mglwIKFAtBwHRy0/pi3N bOyGlXc2UvDJt5ZyzruDeWMS8YNH2YLe7cf3SxNbeW+fAzMoIzMaBnZaRTS7v7d/qrAn qIL0Ms6V+W9L9vG4hIQitI6RoB96m/uesbPMvDsSiyLMi8XEG3zLAnm6SoadSMfhTBty dYcygmBeYMUh3wdNs2H2cGakOSHL3fXbM5rsJPTo+tGh7wPMcTfCbRIrE+I1w1rdgmjq MKtQ== X-Gm-Message-State: APzg51DlafI4Efipsa+vw2qeryhP9Lk1VZsnSFAyT2F2pyV930pFnfrt D2AATRAjNQ7GEZioi//mhh3WHqBce70spQ== X-Google-Smtp-Source: ANB0VdaCLPT5fYQ1gLMBurFwls6QKuGmtMBRu+sPwRqOmUPfVgIhT2RpYFEp4Kb6ADUjf6twXsCWeA== X-Received: by 2002:a37:4904:: with SMTP id w4-v6mr11979534qka.85.1535650977202; Thu, 30 Aug 2018 10:42:57 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id t17-v6sm5048043qtj.50.2018.08.30.10.42.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:56 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 16/35] btrfs: loop in inode_rsv_refill Date: Thu, 30 Aug 2018 13:42:06 -0400 Message-Id: <20180830174225.2200-17-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 With severe fragmentation we can end up with our inode rsv size being huge during writeout, which would cause us to need to make very large metadata reservations. However we may not actually need that much once writeout is complete. So instead try to make our reservation, and if we couldn't make it re-calculate our new reservation size and try again. If our reservation size doesn't change between tries then we know we are actually out of space and can error out. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 064db7ebaf67..664b867ae499 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -5769,10 +5769,11 @@ static int btrfs_inode_rsv_refill(struct btrfs_inode *inode, { struct btrfs_root *root = inode->root; struct btrfs_block_rsv *block_rsv = &inode->block_rsv; - u64 num_bytes = 0; + u64 num_bytes = 0, last = 0; u64 qgroup_num_bytes = 0; int ret = -ENOSPC; +again: spin_lock(&block_rsv->lock); if (block_rsv->reserved < block_rsv->size) num_bytes = block_rsv->size - block_rsv->reserved; @@ -5797,8 +5798,22 @@ static int btrfs_inode_rsv_refill(struct btrfs_inode *inode, spin_lock(&block_rsv->lock); block_rsv->qgroup_rsv_reserved += qgroup_num_bytes; spin_unlock(&block_rsv->lock); - } else + } else { btrfs_qgroup_free_meta_prealloc(root, qgroup_num_bytes); + + /* + * If we are fragmented we can end up with a lot of outstanding + * extents which will make our size be much larger than our + * reserved amount. If we happen to try to do a reservation + * here that may result in us trying to do a pretty hefty + * reservation, which we may not need once delalloc flushing + * happens. If this is the case try and do the reserve again. + */ + if (flush == BTRFS_RESERVE_FLUSH_ALL && last != num_bytes) { + last = num_bytes; + goto again; + } + } return ret; } From patchwork Thu Aug 30 17:42:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582457 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 01BE75A4 for ; Thu, 30 Aug 2018 17:43:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E483B28673 for ; Thu, 30 Aug 2018 17:43:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D899F28681; Thu, 30 Aug 2018 17:43:02 +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 C661F284DA for ; Thu, 30 Aug 2018 17:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727592AbeH3VqP (ORCPT ); Thu, 30 Aug 2018 17:46:15 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:44382 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqP (ORCPT ); Thu, 30 Aug 2018 17:46:15 -0400 Received: by mail-qt0-f194.google.com with SMTP id k38-v6so11283492qtk.11 for ; Thu, 30 Aug 2018 10:42:59 -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=BgDRhtJ88t7ugG2XXq1rTUKV8IL4k8Uo9zOi0L9ZWBs=; b=qPMYGDJ1JuxdsezjIyoxY2VolmDM4ON2S38UZy1WhGxliwZd4TYD/TkY+nRM+h75fQ E3eBQgw0LM9Lce1KzSes2DCVMrlM5YTwGC5X7qjlbsa9O7uc26R7BepBvGeX8ndGO+PU OPBcVi0RMKUSVu81qKPKIQ9G52lHO2TBcCbD2ahFzyNkulSToayO8S5yegepo4YhEKNT nHxyRRZuqv99bCef781E1xY4mKeZ8pxKUzf5wCOtDwhUxy0FOkcPLck1zkjh7s2Q7miz whUErWv8d+VF+Rk3dBHANIAxl37kVTxVekb11ktIaF4DmwrvU0kV1M/4cLHob4UWkw0Q yt0Q== 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=BgDRhtJ88t7ugG2XXq1rTUKV8IL4k8Uo9zOi0L9ZWBs=; b=mgiJBWPtcLzBrnMJsjTWysJczVdq+DFxN6drds4EOLTcwfzx8hY+DhrRr2QklJhdTp 8uqUBE04ds4bGXFK7HipNz8X5EnFAq858XMZ331plpKrXjVKt+JHa9RiowOTIfRchZZQ 8WQTFIUS+QZ+Zl5cIz0oMorUz/1qupwpmaIof+RqhxqrSfGDPNVNlmjhabMUDIvSyuxo BrdA2G8lSoIv6IPMEznXM3QqgkFPkmcoPCw/cdp84iPGzs+wQ/SEnd221BBlJp2i4XkR HPGQ+DG4/SbJkn46i+6oqhWh7tWAlAsdfozOrIxmnAJZYzNFlPpVu50p3E7oliLlQObN ZliA== X-Gm-Message-State: APzg51DRJ4ct/NVlyuJ7ZRARvA7hOddT6dROERVsSOlDF7mOWPWx56dN 9hoAQAfTlC3s3l/jR/ayrpUdEmwGAF11bQ== X-Google-Smtp-Source: ANB0VdaeuyXWGZdlP28yZMY/akDSh+cv67rIFwyKZkDa+gMFQ5wmwViOb95mYR+W9WnaHtPIJF+IpA== X-Received: by 2002:ac8:4807:: with SMTP id g7-v6mr12322584qtq.301.1535650978971; Thu, 30 Aug 2018 10:42:58 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id p5-v6sm4147494qkd.81.2018.08.30.10.42.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:58 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 17/35] btrfs: move the dio_sem higher up the callchain Date: Thu, 30 Aug 2018 13:42:07 -0400 Message-Id: <20180830174225.2200-18-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 We're getting a lockdep splat because we take the dio_sem under the log_mutex. What we really need is to protect fsync() from logging an extent map for an extent we never waited on higher up, so just guard the whole thing with dio_sem. Signed-off-by: Josef Bacik --- fs/btrfs/file.c | 12 ++++++++++++ fs/btrfs/tree-log.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 095f0bb86bb7..c07110edb9de 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -2079,6 +2079,14 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) goto out; inode_lock(inode); + + /* + * We take the dio_sem here because the tree log stuff can race with + * lockless dio writes and get an extent map logged for an extent we + * never waited on. We need it this high up for lockdep reasons. + */ + down_write(&BTRFS_I(inode)->dio_sem); + atomic_inc(&root->log_batch); /* @@ -2087,6 +2095,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) */ ret = btrfs_wait_ordered_range(inode, start, len); if (ret) { + up_write(&BTRFS_I(inode)->dio_sem); inode_unlock(inode); goto out; } @@ -2110,6 +2119,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) * checked called fsync. */ ret = filemap_check_wb_err(inode->i_mapping, file->f_wb_err); + up_write(&BTRFS_I(inode)->dio_sem); inode_unlock(inode); goto out; } @@ -2128,6 +2138,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) trans = btrfs_start_transaction(root, 0); if (IS_ERR(trans)) { ret = PTR_ERR(trans); + up_write(&BTRFS_I(inode)->dio_sem); inode_unlock(inode); goto out; } @@ -2149,6 +2160,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) * file again, but that will end up using the synchronization * inside btrfs_sync_log to keep things safe. */ + up_write(&BTRFS_I(inode)->dio_sem); inode_unlock(inode); /* diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 1650dc44a5e3..66b7e059b765 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -4374,7 +4374,6 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, INIT_LIST_HEAD(&extents); - down_write(&inode->dio_sem); write_lock(&tree->lock); test_gen = root->fs_info->last_trans_committed; logged_start = start; @@ -4440,7 +4439,6 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, } WARN_ON(!list_empty(&extents)); write_unlock(&tree->lock); - up_write(&inode->dio_sem); btrfs_release_path(path); if (!ret) From patchwork Thu Aug 30 17:42:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582459 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 6BF751805 for ; Thu, 30 Aug 2018 17:43:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57690284DA for ; Thu, 30 Aug 2018 17:43:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B04728681; Thu, 30 Aug 2018 17:43:03 +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 DD2B4284DA for ; Thu, 30 Aug 2018 17:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbeH3VqQ (ORCPT ); Thu, 30 Aug 2018 17:46:16 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:38128 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbeH3VqQ (ORCPT ); Thu, 30 Aug 2018 17:46:16 -0400 Received: by mail-qt0-f195.google.com with SMTP id x7-v6so11304534qtk.5 for ; Thu, 30 Aug 2018 10:43:01 -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=gRjtR9nbMSjYn5Z9+dN2dXdWyVc7PQdwC8wJ+EjtSOY=; b=iT2lfRWhpt52s4EGsinqTUo5VtmmOTbBPjONwZEoSm37JU7VXEbHabh8yW8uZ70Xbs pswY548dhx/0Y423KgCr5anaNf4QQQOqg2HD/d9tpF9EtU+S6L351lW6C//abrsaGqso 85s67JeX1QhqyY4Ggk25GWj8ZPQNvIhwjjAYeuy8YHpFfrKOF/iC4rMy5EFod+TIsSGz FGmGkMYCRYp45x98KSFdc9qkplNvN3dkYjkF+UK5BGQbZaiCain3Hnpa3XbaEYwJPd2m 2n5JNWNcVgbQGfOS3fELigufsIr/m+0GUJrcngqdcoz7PaNBg3ynTuU50drk7oaiIG9U GK+g== 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=gRjtR9nbMSjYn5Z9+dN2dXdWyVc7PQdwC8wJ+EjtSOY=; b=qIQEhyHcgyRHtp/ybg1OHfw8CmkkkwfosVIuoBV/87Zab1qG101RyxKtji9ccarHlH ESJHraIAUnHjXrNsGa2F21LTlo3umFdQcDULtb075k08itoQ69fZKj9h/EKeWeWlIobi rQXU5bmdmcsEh1lRTznHtTm/COIkN34fvkEmr8FVCac2zfifxXbGpAbDbvyKiZAT90cJ yMaoSkVaZ6chILFaCRoRa+pp+L558FU+wH6bbcwjKmKir9Kiy8vxHghciFQPwZLd95Nt FRK5+9vEnMcSBHI2bWJUbwcuQWtXKkuWyp/fV6sFk3hLPfd5umU1pR/yYdYpFyP6Xzzj +cew== X-Gm-Message-State: APzg51AI23OnXAikwJja8FHdGywbdVh8V//cCElJ/WMHWHDxbnU/Imzo bPLmA9yh4N2jwkmlekvZPc7jvwEvPTcPXQ== X-Google-Smtp-Source: ANB0Vda809aEaEo9qVu8eTZOEK4hk91F/LGTsIlsYAmwYDTguIrxXYQbH4g2Fir3RHoukisbFIHfVw== X-Received: by 2002:ac8:24d0:: with SMTP id t16-v6mr12893874qtt.116.1535650980708; Thu, 30 Aug 2018 10:43:00 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id p4-v6sm4907810qkl.41.2018.08.30.10.42.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:42:59 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 18/35] btrfs: set max_extent_size properly Date: Thu, 30 Aug 2018 13:42:08 -0400 Message-Id: <20180830174225.2200-19-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 We can't use entry->bytes if our entry is a bitmap entry, we need to use entry->max_extent_size in that case. Fix up all the logic to make this consistent. Signed-off-by: Josef Bacik --- fs/btrfs/free-space-cache.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index db93a5f035a0..53521027dd78 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1766,6 +1766,18 @@ static int search_bitmap(struct btrfs_free_space_ctl *ctl, return -1; } +static void set_max_extent_size(struct btrfs_free_space *entry, + u64 *max_extent_size) +{ + if (entry->bitmap) { + if (entry->max_extent_size > *max_extent_size) + *max_extent_size = entry->max_extent_size; + } else { + if (entry->bytes > *max_extent_size) + *max_extent_size = entry->bytes; + } +} + /* Cache the size of the max extent in bytes */ static struct btrfs_free_space * find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, @@ -1787,8 +1799,7 @@ find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, for (node = &entry->offset_index; node; node = rb_next(node)) { entry = rb_entry(node, struct btrfs_free_space, offset_index); if (entry->bytes < *bytes) { - if (entry->bytes > *max_extent_size) - *max_extent_size = entry->bytes; + set_max_extent_size(entry, max_extent_size); continue; } @@ -1806,8 +1817,7 @@ find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, } if (entry->bytes < *bytes + align_off) { - if (entry->bytes > *max_extent_size) - *max_extent_size = entry->bytes; + set_max_extent_size(entry, max_extent_size); continue; } @@ -1819,8 +1829,8 @@ find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, *offset = tmp; *bytes = size; return entry; - } else if (size > *max_extent_size) { - *max_extent_size = size; + } else { + set_max_extent_size(entry, max_extent_size); } continue; } @@ -2680,8 +2690,7 @@ static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group_cache *block_group, err = search_bitmap(ctl, entry, &search_start, &search_bytes, true); if (err) { - if (search_bytes > *max_extent_size) - *max_extent_size = search_bytes; + set_max_extent_size(entry, max_extent_size); return 0; } @@ -2718,8 +2727,8 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group, entry = rb_entry(node, struct btrfs_free_space, offset_index); while (1) { - if (entry->bytes < bytes && entry->bytes > *max_extent_size) - *max_extent_size = entry->bytes; + if (entry->bytes < bytes) + set_max_extent_size(entry, max_extent_size); if (entry->bytes < bytes || (!entry->bitmap && entry->offset < min_start)) { 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); From patchwork Thu Aug 30 17:42:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582463 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 2A3A41805 for ; Thu, 30 Aug 2018 17:43:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 192A3284DA for ; Thu, 30 Aug 2018 17:43:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DBF228676; Thu, 30 Aug 2018 17:43:07 +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 B092D284DA for ; Thu, 30 Aug 2018 17:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727675AbeH3VqU (ORCPT ); Thu, 30 Aug 2018 17:46:20 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:41961 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727582AbeH3VqU (ORCPT ); Thu, 30 Aug 2018 17:46:20 -0400 Received: by mail-qk1-f196.google.com with SMTP id h138-v6so22939qke.8 for ; Thu, 30 Aug 2018 10:43:05 -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=VD0XiwwWoL+eG/ntpbfeg7SK6ePf5272Lw4r2/bMF0M=; b=gyDli+rYE7+XxZhBo1r+ECon5NN+rc8rmM7ePHhNwDUHmUXbjZtkhzCu3ZQS5g/3sl pKPSfvlat3YhA9pFpHKNfX9DgAMZYbfsAhv0KUisrJ6uugWaVV5BJYg54dVT5R3cPR/+ Mx5QCKXbqJM28V6pCpkeMCD2cb/sv/OvzkWmXu0ePfAQzzAPvvAffopJrKDmEtcIeUXh VfFOHBVgp6VgVEfW3pGr82b6lO72I6QBQ4oAbKcA83uktfVNYByueWI9AzCsOp/4Hucd xT1AbSvbL1QrL752KXi4HQy+uJkDwOm2S49NrmVpT+cQ4wt5WAGj+zOAnNeqQbjJWSNi HxAw== 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=VD0XiwwWoL+eG/ntpbfeg7SK6ePf5272Lw4r2/bMF0M=; b=EShTY6tKkjqe/nNh4vU3aycHr4tP/9qBA0Gw4LVqAxetyPS3Vb8YCovxfwGgzOwJ9p m7u6wVTZru+DpPHF/X1jCygQKJjJa9cIwJEdQaKhcJJ1f4GKN5/YxWrZrsRmVVQeRIpu E5rTuZypOr5FUXwRqa3UarWnzZ5y/0sfF1fV0jPKDHoOldWz/B8jA1FyY7cT/RgcN+X1 hpzem+/T2ua3vR8rKoVyb5XxthkZvzKaPwOIZnRJyHzbFBwA4wkrFGasZkJ+iPyBUx+1 RPYQzCiCfD7KBVm4aQ1g/7xvpvjsa54zb0Tgaiq2PdpVK0L1eBjqA9gY/HO2QghOgNHq yjQg== X-Gm-Message-State: APzg51BLNow8hmW3LBTO4+N83bvf568vq7jPp3+/FUFAlycKWJmyddY0 6QiC18qb8hR54kJsZOU911S6s/FBpaV/eA== X-Google-Smtp-Source: ANB0VdbBiuoPKc5BMR1fg9zUJvzzeBnx5b/f0uYCy889TA4Q56ZoNZfJzdl0sXBp/B+4klpM9lvz6w== X-Received: by 2002:a37:6dc4:: with SMTP id i187-v6mr12506092qkc.34.1535650984341; Thu, 30 Aug 2018 10:43:04 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id b134-v6sm4501513qka.63.2018.08.30.10.43.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:03 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 20/35] btrfs: reset max_extent_size on clear in a bitmap Date: Thu, 30 Aug 2018 13:42:10 -0400 Message-Id: <20180830174225.2200-21-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 We need to clear the max_extent_size when we clear bits from a bitmap since it could have been from the range that contains the max_extent_size. Signed-off-by: Josef Bacik Reviewed-by: Liu Bo --- fs/btrfs/free-space-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 53521027dd78..7faca05e61ea 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1683,6 +1683,8 @@ static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, bitmap_clear(info->bitmap, start, count); info->bytes -= bytes; + if (info->max_extent_size > ctl->unit) + info->max_extent_size = 0; } static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, From patchwork Thu Aug 30 17:42:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582465 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 4BD8A5A4 for ; Thu, 30 Aug 2018 17:43:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 392BF284DA for ; Thu, 30 Aug 2018 17:43:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BDAD28676; Thu, 30 Aug 2018 17:43:09 +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 C126C284DA for ; Thu, 30 Aug 2018 17:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727679AbeH3VqW (ORCPT ); Thu, 30 Aug 2018 17:46:22 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:45093 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3VqW (ORCPT ); Thu, 30 Aug 2018 17:46:22 -0400 Received: by mail-qt0-f193.google.com with SMTP id g44-v6so11258773qtb.12 for ; Thu, 30 Aug 2018 10:43:06 -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=NIWxUwG4u6mwzl5co7wrzycjU3C9VR1V8gjr46ELak0=; b=F3d1CObm5vzK3XFFdT+Z1FR7RGgxCyT21SHGloLi7qDINPsdgDpHiuFxhguW94u5H4 Wkx0U/9gU9Tx9GTOVbMomlR0kdITrWbeP/65fgaaVLyw1eZ6ZudxtAvl8Rl7/6o2XEA7 wXrbwx26Pcj5UffEr2RXB/neI6PiFa3le9l+O127pPP5dkBccKMD8DGENK3w3vfrqFKV 6HdsrRHQBNgwpTwzWOBGODN+CWVCpQZC85TMYcC2tZVcFyM0ttgVGurgGzhYPz45VqO2 1PpTVEBqobt2sg8zwLt+hSi4uv7lQz23GoIyj0OFJ44thhg4h9ULC2t8NIs0yHagu6Ce yeKw== 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=NIWxUwG4u6mwzl5co7wrzycjU3C9VR1V8gjr46ELak0=; b=Kn4Qf+vvcOS3vy84YwD44hBlvcVRW2AAJsLX4/8aZzbTqjcE+u65PgZdZLbmly+BHQ ZmRZ/KmnjAMxoOm2QjfUrQEXd1f1+37FHsFBsK7hAjt2dY6PMN0zTNVzQR71YVyUM5Xp OZN8U7kdK9uOAJjTOls7w56r8plEOOxla7/pvXaw4mHqh0U9c/qpgziejZKgkFhg6SD2 AiC+6CJOXFNmXaBlAfMhuGqMTSU+GjEXAtM13cKafCoqttPMG4xhVSQS/at3e3oUT7cK JtWx5xNw3QKi1XOBa0WnXpsUpA+VBZT72qo3MsQs7ZU0nkSkkK5nnzXW2iVSPHL0RT2q g0sw== X-Gm-Message-State: APzg51DeKBSogmh95dTn8TddicDZnLjvA1RViC/lqLPNxfY+Sev+25G5 2XrzvytYl2c/6v0/fw3ySLlScyAJh1+FQw== X-Google-Smtp-Source: ANB0Vdbupu8d2sfD8d+rPJbbfYN9k5juKNy2BF0qJQEBhLyzIfz2DvIzlo5U7VFoEYk/+x4mgNSLyw== X-Received: by 2002:a37:b842:: with SMTP id i63-v6mr11934670qkf.187.1535650986085; Thu, 30 Aug 2018 10:43:06 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id x46-v6sm4738923qtc.9.2018.08.30.10.43.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:05 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 21/35] btrfs: only run delayed refs if we're committing Date: Thu, 30 Aug 2018 13:42:11 -0400 Message-Id: <20180830174225.2200-22-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 I noticed in a giant dbench run that we spent a lot of time on lock contention while running transaction commit. This is because dbench results in a lot of fsync()'s that do a btrfs_transaction_commit(), and they all run the delayed refs first thing, so they all contend with each other. This leads to seconds of 0 throughput. Change this to only run the delayed refs if we're the ones committing the transaction. This makes the latency go away and we get no more lock contention. Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval --- fs/btrfs/transaction.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index ebb0c0405598..2bb19e2ded5e 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1918,15 +1918,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) btrfs_trans_release_metadata(trans); trans->block_rsv = NULL; - /* make a pass through all the delayed refs we have so far - * any runnings procs may add more while we are here - */ - ret = btrfs_run_delayed_refs(trans, 0); - if (ret) { - btrfs_end_transaction(trans); - return ret; - } - cur_trans = trans->transaction; /* @@ -1939,12 +1930,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) if (!list_empty(&trans->new_bgs)) btrfs_create_pending_block_groups(trans); - ret = btrfs_run_delayed_refs(trans, 0); - if (ret) { - btrfs_end_transaction(trans); - return ret; - } - if (!test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &cur_trans->flags)) { int run_it = 0; @@ -2015,6 +2000,15 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) spin_unlock(&fs_info->trans_lock); } + /* + * We are now the only one in the commit area, we can run delayed refs + * without hitting a bunch of lock contention from a lot of people + * trying to commit the transaction at once. + */ + ret = btrfs_run_delayed_refs(trans, 0); + if (ret) + goto cleanup_transaction; + extwriter_counter_dec(cur_trans, trans->type); ret = btrfs_start_delalloc_flush(fs_info); From patchwork Thu Aug 30 17:42:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582467 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 1A66817DE for ; Thu, 30 Aug 2018 17:43:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A026284DA for ; Thu, 30 Aug 2018 17:43:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1FB828676; Thu, 30 Aug 2018 17:43:10 +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 9ED15284DA for ; Thu, 30 Aug 2018 17:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727683AbeH3VqY (ORCPT ); Thu, 30 Aug 2018 17:46:24 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:43088 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3VqX (ORCPT ); Thu, 30 Aug 2018 17:46:23 -0400 Received: by mail-qt0-f194.google.com with SMTP id g53-v6so11274580qtg.10 for ; Thu, 30 Aug 2018 10:43:08 -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=rHRaQ156gyHs+qQIoPL4cB69riQ0Y4jB65i9RwV19ws=; b=DfphsexseSCSq35787EwhzDZOUR0eRB+ib3j7Nt6D9v3NwFLLVWv5MPp/D3b2A9z6b 8HpX9xNzYxQhs7I7LFJBKdGks4THL74BF4ycRQ1rJ/w4PDda2iTySRwMN3084vBOvJh0 mF5KfB6/lu4bGBA8xciG+IYjFcgXGxgIxywJmEby9t+IXgjoA2EXeLhLPA2/ymmvR2JN D1E+rToK+nZsHZrArkcAD38xB20IVucOoNcScy/ghO/XcNpahAhsMmxWp66DYnab5BYJ roqHXN8Zvvm2a5JkldumS2m7bT+WgP21btBphUyArgBNTpm9fLxZDBCcrl/HsJKFVD3D 7UIQ== 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=rHRaQ156gyHs+qQIoPL4cB69riQ0Y4jB65i9RwV19ws=; b=J7cMAXU9ph7lfi+D1dWhi4Afy3+9rjEsV4gLOfOO/RNzH3M2O5HR44uDMLHEpcqtq3 sGojxz1HSACXanHgsYnA7Ls634qm5yzt3s8+UIVlnlmy913oAin7GRPcZscWp9EHZNsW PAIxS3tREUNL/CTy+5BJlvCc/TmPs+6+luGoVk3aoJt0uoTYmslN1ok5yMBzIfWos4yy KEuiDa+oZpq16saxZgD8ok0AH8LnpFSH03fEYjZYFAsiEnPokfQFdovjdp+vpYvM4/yP h8Dv2bSqpTeu8n/iMgfwiXKVyvrHcMSa2MIYPEW4Df88exzbun5ehMLJq9X/lDhv9Hu2 kEPg== X-Gm-Message-State: APzg51A+uYvFUS6vbkb2SUgbZmxqIryoB7N3U788oYQbcyWKPuoAziUt Kjn8SGqRcx4E8nIkympVhF6rRewaWUxv0A== X-Google-Smtp-Source: ANB0VdYANyafdz3/QtLGELOXdFIfEfyrFkX+MRUiEywLLgE5s3H0mupMcDnRu2R1TiU7/7SF2v+vuw== X-Received: by 2002:ac8:4649:: with SMTP id f9-v6mr13080944qto.34.1535650987854; Thu, 30 Aug 2018 10:43:07 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id o5-v6sm4961225qtc.63.2018.08.30.10.43.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:06 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 22/35] btrfs: make sure we create all new bgs Date: Thu, 30 Aug 2018 13:42:12 -0400 Message-Id: <20180830174225.2200-23-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 We can actually allocate new chunks while we're creating our bg's, so instead of doing list_for_each_safe, just do while (!list_empty()) so we make sure to catch any new bg's that get added to the list. Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval Reviewed-by: Liu Bo --- 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 ca98c39308f6..fc30ff96f0d6 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10331,7 +10331,7 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info) void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans) { struct btrfs_fs_info *fs_info = trans->fs_info; - struct btrfs_block_group_cache *block_group, *tmp; + struct btrfs_block_group_cache *block_group; struct btrfs_root *extent_root = fs_info->extent_root; struct btrfs_block_group_item item; struct btrfs_key key; @@ -10339,7 +10339,10 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans) bool can_flush_pending_bgs = trans->can_flush_pending_bgs; trans->can_flush_pending_bgs = false; - list_for_each_entry_safe(block_group, tmp, &trans->new_bgs, bg_list) { + while (!list_empty(&trans->new_bgs)) { + block_group = list_first_entry(&trans->new_bgs, + struct btrfs_block_group_cache, + bg_list); if (ret) goto next; From patchwork Thu Aug 30 17:42:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582469 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 1515E17DE for ; Thu, 30 Aug 2018 17:43:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0468F284DA for ; Thu, 30 Aug 2018 17:43:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ED14328676; Thu, 30 Aug 2018 17:43:11 +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 98AC6284DA for ; Thu, 30 Aug 2018 17:43:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727691AbeH3VqZ (ORCPT ); Thu, 30 Aug 2018 17:46:25 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:45111 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3VqZ (ORCPT ); Thu, 30 Aug 2018 17:46:25 -0400 Received: by mail-qt0-f194.google.com with SMTP id g44-v6so11259148qtb.12 for ; Thu, 30 Aug 2018 10:43:10 -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=Er/itZiSy6nL1jO5ftCZDD3fOMgMo4baPf1MXLpwYlU=; b=L9g3QdeAlQRJMCcykGe0dRaSNvNoYKzARQbAHELjWaNTTTJUAjTesBRiTxFrtRqXLA L6ipqyCvBkL4eUji20GTmRVPR5y+OcfJVUZHyFbX/wZQUHTcyNRdGQsSF9h37eBzaVyx koCz4SpFbhM5y9pnfEm3Maz+Qx4KgTlCzWsWX+qn8/IoAkk6YncOhF2t78mA3SOwKsFd KvU3pzq4wcu3rZUYHwoAuBaF4W5ceuFJ4nKPFQn/7AFn5r2UUSxTstlrJOJAEUccUPfH XAdpe6uDNOR+9jjXx9sbB5H78rKH2eIn1FCngjzsgiC90g9hmkdHm7LlEOcgdHXo4Kju 79vQ== 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=Er/itZiSy6nL1jO5ftCZDD3fOMgMo4baPf1MXLpwYlU=; b=aovWQkQOpXxQ0ShyPf6bZ4ghxXefArhBjKjF3DsHjuO8hJ0uyxJIib7mCuyBjmXrAP 1qaJMl8x2Zqx+fPQVlHAozAZ9lEa3ey5oJt7K43P4M05zDNUL8uVtzw6mrS/gQZnheuu L5X50iKyS93UWctmod4j74saPPY1deouoZfIYnSaDj1SacpGII3qjYGRvbDJLCCX+y2e HLYuRoa7cmvPVyjePaYBgHxiR6S0QONj/6zJ8CxOzzu5KE7XDuI+ANNdJDcNKTkjhWJi y4fZaoPfbvmxMPKT6tjmGVcoh2U64kxts4V94npfVbUG4pUVhHvDiKlU/YDHzkNaO8eq vsMg== X-Gm-Message-State: APzg51D8Np8V2crdzKJDQfpWXLjK7SeTttNtaT3UHGbANYw80DmSvZzo DqDwiVFeSYPP25I2tHO1iOnJkcVAFSF2pg== X-Google-Smtp-Source: ANB0VdagLg3cj0x/jSxPZdlANDb0zhL6mmBcG2RWmpYCPe4UG6MjUZirtSjdp5l/8fqBt63YOj7svA== X-Received: by 2002:ae9:f10c:: with SMTP id k12-v6mr12282744qkg.342.1535650989723; Thu, 30 Aug 2018 10:43:09 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id a10-v6sm240861qkj.60.2018.08.30.10.43.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:08 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 23/35] btrfs: assert on non-empty delayed iputs Date: Thu, 30 Aug 2018 13:42:13 -0400 Message-Id: <20180830174225.2200-24-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 I ran into an issue where there was some reference being held on an inode that I couldn't track. This assert wasn't triggered, but it at least rules out we're doing something stupid. Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval --- fs/btrfs/disk-io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 0e42401756b8..11ea2ea7439e 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3979,6 +3979,7 @@ void close_ctree(struct btrfs_fs_info *fs_info) kthread_stop(fs_info->transaction_kthread); kthread_stop(fs_info->cleaner_kthread); + ASSERT(list_empty(&fs_info->delayed_iputs)); set_bit(BTRFS_FS_CLOSING_DONE, &fs_info->flags); btrfs_free_qgroup_config(fs_info); From patchwork Thu Aug 30 17:42:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582471 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 111A95A4 for ; Thu, 30 Aug 2018 17:43:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3E6A284DA for ; Thu, 30 Aug 2018 17:43:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E825128676; Thu, 30 Aug 2018 17:43:14 +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 73EA4284DA for ; Thu, 30 Aug 2018 17:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727698AbeH3Vq2 (ORCPT ); Thu, 30 Aug 2018 17:46:28 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:39583 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vq1 (ORCPT ); Thu, 30 Aug 2018 17:46:27 -0400 Received: by mail-qt0-f194.google.com with SMTP id o15-v6so11288527qtk.6 for ; Thu, 30 Aug 2018 10:43:12 -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=CA+3sPpWVpECIxDBWrod57M0ejok1QEYG2zP0b1DHoc=; b=rG1VF7ZHEYvFlx4nGhIistNciSoYbzjhJP8lhN+eJtHSj7uLhGer3LFB92LKeIdNQ1 z/Rqn3Pwqjz479AQkyvsFxSXYef/T+oSAdyDm6o3ZfOi4g2kg5mqhW3fPfcg9PAx6TaV C4/7mLtFPkgEgNegCIH9NHtXpaxoSO3WHDjTG9FJI3lP2eanWuvSvoiU7CyiwMeEM7rc /8zwwDF3ob9mjkd8hiTomTNwoRn+2KIvl2vMYwrRLmxwN5Un6sNlMCAgzA2X4rPAwUdI 0bFEkdllvBBzw3tu0cXZWlJe6Be7EoM+oHO3FlSUI027Oa1bBzgx2K8993ZP4MoEUNls F0Yg== 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=CA+3sPpWVpECIxDBWrod57M0ejok1QEYG2zP0b1DHoc=; b=ATmp5iadWJfprbtjgGEzO1wVASQ4XZ02TbkFBbxXJVw5UomRsI+oIog0jEe6xuN/+D B3MeIB9Hi2qu4pIXgDOU79YOiikuV893AdvU2vBprCgAADYh3E2dMtGbyYWukF6IBRZQ vefnP8lmMNbnoiX1tyetRtg6DT/7djyZz6rfnHJJ6McTGqSsQjr80LIPF1fUooX85whM C2s4OugmML/i349iBe1DDJ1jLMSH/D4JgV98SQvze9ZgGA6riyoms6YJiOKEEje+N8+9 9RDh8XpjkvSffXcku0Aqz3IKW3hR+02fmn9IozxmIqHli6S6yLl36b84ub3plAMg5YPD SmAg== X-Gm-Message-State: APzg51C2pv/V1ymGTEKMkrNF/1/Gxwib94OF+EwOxeWYofP9l84zJc8N tTqybS6Nleyy+lsJiijCaOn1954R0+GTfQ== X-Google-Smtp-Source: ANB0VdbakfnzMFzdLS0M7GfYmolvU18zvUbrLPsc2xF4zA2DMbqPft+awdITaNylTLm1vQPevt33wQ== X-Received: by 2002:ac8:38a7:: with SMTP id f36-v6mr12979953qtc.337.1535650991798; Thu, 30 Aug 2018 10:43:11 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id b11-v6sm4261389qkc.71.2018.08.30.10.43.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:10 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 24/35] btrfs: pass delayed_refs_root to btrfs_delayed_ref_lock Date: Thu, 30 Aug 2018 13:42:14 -0400 Message-Id: <20180830174225.2200-25-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 We don't need the trans except to get the delayed_refs_root, so just pass the delayed_refs_root into btrfs_delayed_ref_lock and call it a day. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/delayed-ref.c | 5 +---- fs/btrfs/delayed-ref.h | 2 +- fs/btrfs/extent-tree.c | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index 96ce087747b2..87778645bf4a 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -197,12 +197,9 @@ find_ref_head(struct rb_root *root, u64 bytenr, return NULL; } -int btrfs_delayed_ref_lock(struct btrfs_trans_handle *trans, +int btrfs_delayed_ref_lock(struct btrfs_delayed_ref_root *delayed_refs, struct btrfs_delayed_ref_head *head) { - struct btrfs_delayed_ref_root *delayed_refs; - - delayed_refs = &trans->transaction->delayed_refs; lockdep_assert_held(&delayed_refs->lock); if (mutex_trylock(&head->mutex)) return 0; diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index 7769177b489e..ee636d7a710a 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h @@ -255,7 +255,7 @@ void btrfs_merge_delayed_refs(struct btrfs_trans_handle *trans, struct btrfs_delayed_ref_head * btrfs_find_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_refs, u64 bytenr); -int btrfs_delayed_ref_lock(struct btrfs_trans_handle *trans, +int btrfs_delayed_ref_lock(struct btrfs_delayed_ref_root *delayed_refs, struct btrfs_delayed_ref_head *head); static inline void btrfs_delayed_ref_unlock(struct btrfs_delayed_ref_head *head) { diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index fc30ff96f0d6..32579221d900 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2591,7 +2591,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, /* grab the lock that says we are going to process * all the refs for this head */ - ret = btrfs_delayed_ref_lock(trans, locked_ref); + ret = btrfs_delayed_ref_lock(delayed_refs, locked_ref); spin_unlock(&delayed_refs->lock); /* * we may have dropped the spin lock to get the head From patchwork Thu Aug 30 17:42:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582473 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 BD82517DE for ; Thu, 30 Aug 2018 17:43:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8F63284DA for ; Thu, 30 Aug 2018 17:43:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D71328676; Thu, 30 Aug 2018 17:43:16 +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 46558284DA for ; Thu, 30 Aug 2018 17:43:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727704AbeH3Vqa (ORCPT ); Thu, 30 Aug 2018 17:46:30 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:33697 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vq3 (ORCPT ); Thu, 30 Aug 2018 17:46:29 -0400 Received: by mail-qt0-f195.google.com with SMTP id r37-v6so11324579qtc.0 for ; Thu, 30 Aug 2018 10:43:14 -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=o/hKWFbg93dQprcCBuORYDrOymdPLseeaONvipoztVE=; b=1cF+EhFHmU4YpsGY9VBrB62+a+bG0owhHVuQ3zelY6iDoBwPKBTHrv0+gmqhu2eU7E m8mhkYYpSM3D/S6Y9q1CnW+BGu7lYdwC5TolJbVnkrCMra43jZaBlUs/qjyNWj9iWzm4 FoWI/lPAPM1vFkg9yO6rkcWzGoUibHJpw1gQJ5Heg7dHf6iTixoMypgvFzovpR976Ze0 M5tc4MUcs6lJB+zvBoMc56xE54720ByvFHsU1IIIdphCuEpl/rkWWmQeNwGObW6rqB27 Efkl69nkBtjmNqNlo9bn1+2CXgBo2NDwHCULzqUmxlmWeYZqfDyRRGvy7/8UHV45iB44 w49Q== 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=o/hKWFbg93dQprcCBuORYDrOymdPLseeaONvipoztVE=; b=fTskDgKWGkQLblPE1BuUeSLdRLS75pptqMAq56Jt0NDCmfwXZKbcvUTq40cqkOckwr iy5v/fjNJN+TjJwaGOon+JRVwqQxGEBnTnc680BSRU5u197/7ibkn+csxnxY9t09tvmj FW3SLI5YQcKXq6HsIJV3VcXunTQdlN5vjea4YoErqZaIO/RaAlTfi12s93tNCz9NZKUx J+H0hapmvxngtd2hl9ftsL+D8QsZdWWGM0zQbePbornyqw3H7iTayygW8y+wszx8/hgs GWTulQZSHgg+hLH3nA417x4OLbm+x+En+SIgHSt1GRwmkfHaeofalZx5N1eeRg/dNZOk fDlA== X-Gm-Message-State: APzg51CiNUdcV7JDyZNrYtk5zZLosATHka4Nv9gKT4tVQzPXeVTtVs/W 4zcshjYkM69w5na9s/NxvUwRyPSHGU07ug== X-Google-Smtp-Source: ANB0VdbRdxmtXEmLVytGtIOCVnlkA+AIA9q9L46z/8tmkVVOIk5BK5fd74U+24u3WlDFOSik/jMXGg== X-Received: by 2002:a0c:c602:: with SMTP id v2-v6mr12313151qvi.31.1535650993607; Thu, 30 Aug 2018 10:43:13 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id b134-v6sm4501775qka.63.2018.08.30.10.43.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:12 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 25/35] btrfs: make btrfs_destroy_delayed_refs use btrfs_delayed_ref_lock Date: Thu, 30 Aug 2018 13:42:15 -0400 Message-Id: <20180830174225.2200-26-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 We have this open coded in btrfs_destroy_delayed_refs, use the helper instead. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/disk-io.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 11ea2ea7439e..c72ab2ca7627 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4214,16 +4214,9 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, head = rb_entry(node, struct btrfs_delayed_ref_head, href_node); - if (!mutex_trylock(&head->mutex)) { - refcount_inc(&head->refs); - spin_unlock(&delayed_refs->lock); - - mutex_lock(&head->mutex); - mutex_unlock(&head->mutex); - btrfs_put_delayed_ref_head(head); - spin_lock(&delayed_refs->lock); + if (btrfs_delayed_ref_lock(delayed_refs, head)) continue; - } + spin_lock(&head->lock); while ((n = rb_first(&head->ref_tree)) != NULL) { ref = rb_entry(n, struct btrfs_delayed_ref_node, From patchwork Thu Aug 30 17:42:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582475 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 327C217DE for ; Thu, 30 Aug 2018 17:43:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21F3E284DA for ; Thu, 30 Aug 2018 17:43:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1642328676; Thu, 30 Aug 2018 17:43:18 +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 BE8EA284DA for ; Thu, 30 Aug 2018 17:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727713AbeH3Vqb (ORCPT ); Thu, 30 Aug 2018 17:46:31 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:44455 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqb (ORCPT ); Thu, 30 Aug 2018 17:46:31 -0400 Received: by mail-qt0-f193.google.com with SMTP id k38-v6so11284966qtk.11 for ; Thu, 30 Aug 2018 10:43:16 -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=rWvLztEWJyWKHy/ruHqdFw5Y+kzYhdUJU97N+CsRy/Y=; b=vOMyB7JVVI7y+ZsN/SNbStsmZ6Qq3hTV2v05dvggDNxQmIwMO+R3+goDE+Lg2E+75c KVpKLLumPA/FwAbI67udBTa6rP9uC0kOjtpBmFvAwPOHoQof5BKoJWz5UVBu/VFeqKcb grgJIOiDND+FbRAxBqMophJx8Rb65njmiwRJVE5F6fWoO4sZ93aHWmdApzxuu/fkX+tQ /uuORyextSVysrs3u3DO11HWy0vhzdlnuQJzo4nVAIKckD2IKk3ubNcDoH/JByuDhi06 SX5aoQ/Q2fMHleZtvackIj4EGTLTRPpcYHqgM/Z0T1Eunkh3/mNqnSAS7/T1Ch/EhuXu nu7Q== 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=rWvLztEWJyWKHy/ruHqdFw5Y+kzYhdUJU97N+CsRy/Y=; b=UIBZbWvyD/JdYAiy/VmTekJ5a9D18JkbdTsYwj42WpB7sC4TtuVXx9qTcyuzAn25fP IToeHM1oZpF0Mt5Ax6JlcmaGWqNYkaYup2xYLqit2p2F338nilnj+gR9+zgaEbpAZyjU 3QLWenPagrkodr+/HWu7+P2ZP31fQyQkdsmPvvF/ePMUdwiY496yTIv9PvxV9ue7kikc vjClPlWhwngvq3IO0uA/dgGx1HQd0jtXKTfqVACv4SgbwkeyW8YynKlPFIKceWrUO3+a MW88KOLovHIW0QLXMrvsa807fy9REhYQQsofXORhmFedIJ1q98BwByUHkXl/0dpptJvd aZDA== X-Gm-Message-State: APzg51C6vNI+jVA0GPxesmx+LyvU9u8Z+0xV1tC35pGjEI66KAh0U8Sb lZvSyo2GCZPAlqWizJotnYF4T9fJAcHHFw== X-Google-Smtp-Source: ANB0VdbEJLeOh+clTMX8v2S6xVGkCDt0jgP+6+Usow7wcjgTpwMzDNYaeCO5XX0XcnsLeTd45wFr4g== X-Received: by 2002:ac8:8e8:: with SMTP id y37-v6mr13106504qth.339.1535650995349; Thu, 30 Aug 2018 10:43:15 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id l23-v6sm4879700qta.30.2018.08.30.10.43.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:14 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 26/35] btrfs: make btrfs_destroy_delayed_refs use btrfs_delete_ref_head Date: Thu, 30 Aug 2018 13:42:16 -0400 Message-Id: <20180830174225.2200-27-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 Instead of open coding this stuff use the helper instead. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/disk-io.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index c72ab2ca7627..1d3f5731d616 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4232,12 +4232,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, if (head->must_insert_reserved) pin_bytes = true; btrfs_free_delayed_extent_op(head->extent_op); - delayed_refs->num_heads--; - if (head->processing == 0) - delayed_refs->num_heads_ready--; - atomic_dec(&delayed_refs->num_entries); - rb_erase(&head->href_node, &delayed_refs->href_root); - RB_CLEAR_NODE(&head->href_node); + btrfs_delete_ref_head(delayed_refs, head); spin_unlock(&head->lock); spin_unlock(&delayed_refs->lock); mutex_unlock(&head->mutex); From patchwork Thu Aug 30 17:42:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582477 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 0B00C5A4 for ; Thu, 30 Aug 2018 17:43:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2546284DA for ; Thu, 30 Aug 2018 17:43:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6D4628676; Thu, 30 Aug 2018 17:43:20 +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 6F5B2284DA for ; Thu, 30 Aug 2018 17:43:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727719AbeH3Vqe (ORCPT ); Thu, 30 Aug 2018 17:46:34 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:33966 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqd (ORCPT ); Thu, 30 Aug 2018 17:46:33 -0400 Received: by mail-qt0-f194.google.com with SMTP id m13-v6so11335625qth.1 for ; Thu, 30 Aug 2018 10:43:17 -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=RhNEqAeDiaZy+WCOV4asYMVkNrAm7MjH/FE8VgCMwgU=; b=oDVpW9Z97nGB8yzn9d60GzJ1Z9bpDJj5pDgdk2kWUImFP5qKMWzG0UtJKK+LSQrCrW Da94V1Z18uwh0ZPvWx6UB5ojyx3PQZfuJZgF7ubalENYrMHZTLnkCPpmJfrPrs6OVQjh u3wIRUMzc1sMme7TR42RmfxDmO1MJ3y4TdU162ovi1Chg+ZaT5g+EhmrcAs9hpToAnhc 80rIcnNvnI+SCHMvmBoSc5/ASsbOlQ0rThrhEJ/0nW+l0AS93OB1IY6vmik5VsC+SjR0 lM1tkrUstzAItqellqYwukBoTSdbOIhdJofDvgFBHGFBxPdcDQioTj1lQWRqqCVfsmi1 DumA== 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=RhNEqAeDiaZy+WCOV4asYMVkNrAm7MjH/FE8VgCMwgU=; b=Jltgqgh0p835fkytUrCLYUOCHpnx59XG7B62o3vKcfEPE+KfEUm3kwQGQ+QX3qCNso iaT+DbnQZcFQjOhpadIUa4Cgx5LrjBE5ou5dudVTOLUUwoZIj595Trh/l19aIhMl1kF/ 6gZwE2UDSHJmbbxtDFy2BGUKOdd9bFoEKzNr33jeJjMORon+gzBOFZt+wPZfph9mMF/q lzBLXr2uI9VMq8VhZO0WyIKREyy2lDSxHmfzfQhaFiSm3w12U9IQTjeMLczSEHOt1bpk hmoR4SksvYthTG/n8TcGT4vj+Uhm4VgOT64EpoIG4mokKc72T8F+F6wd+Ojq5JXvbyLB 6QXg== X-Gm-Message-State: APzg51CrpxkjTqwqpJtCJoQRKMHKmpOnjF4AjlOeKWDQ9Bv4oe6XwONd RCIcjiVOVeWKwyncbN7YJbf5ge1y5T4jyQ== X-Google-Smtp-Source: ANB0VdbDFqL9H7XClqjGA9PKJj79D1UuT6baKHjrAF8wokNTBUmiaerbH9F5xvygN1E1E5PHz2N05w== X-Received: by 2002:a37:d18d:: with SMTP id o13-v6mr12076026qkl.51.1535650997089; Thu, 30 Aug 2018 10:43:17 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id j88-v6sm4345751qte.49.2018.08.30.10.43.16 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:16 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 27/35] btrfs: handle delayed ref head accounting cleanup in abort Date: Thu, 30 Aug 2018 13:42:17 -0400 Message-Id: <20180830174225.2200-28-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 We weren't doing any of the accounting cleanup when we aborted transactions. Fix this by making cleanup_ref_head_accounting global and calling it from the abort code, this fixes the issue where our accounting was all wrong after the fs aborts. Signed-off-by: Josef Bacik --- fs/btrfs/ctree.h | 5 +++++ fs/btrfs/disk-io.c | 1 + fs/btrfs/extent-tree.c | 13 ++++++------- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 791e287c2292..67923b2030b8 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -35,6 +35,7 @@ struct btrfs_trans_handle; struct btrfs_transaction; struct btrfs_pending_snapshot; +struct btrfs_delayed_ref_root; extern struct kmem_cache *btrfs_trans_handle_cachep; extern struct kmem_cache *btrfs_bit_radix_cachep; extern struct kmem_cache *btrfs_path_cachep; @@ -2624,6 +2625,10 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, unsigned long count); int btrfs_async_run_delayed_refs(struct btrfs_fs_info *fs_info, unsigned long count, u64 transid, int wait); +void +btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info, + struct btrfs_delayed_ref_root *delayed_refs, + struct btrfs_delayed_ref_head *head); int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len); int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info, u64 bytenr, diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 1d3f5731d616..caaca8154a1a 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4240,6 +4240,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, if (pin_bytes) btrfs_pin_extent(fs_info, head->bytenr, head->num_bytes, 1); + btrfs_cleanup_ref_head_accounting(fs_info, delayed_refs, head); btrfs_put_delayed_ref_head(head); cond_resched(); spin_lock(&delayed_refs->lock); diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 32579221d900..031d2b11ddee 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2466,12 +2466,11 @@ static int cleanup_extent_op(struct btrfs_trans_handle *trans, return ret ? ret : 1; } -static void cleanup_ref_head_accounting(struct btrfs_trans_handle *trans, - struct btrfs_delayed_ref_head *head) +void +btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info, + struct btrfs_delayed_ref_root *delayed_refs, + struct btrfs_delayed_ref_head *head) { - struct btrfs_fs_info *fs_info = trans->fs_info; - struct btrfs_delayed_ref_root *delayed_refs = - &trans->transaction->delayed_refs; int nr_items = 1; if (head->total_ref_mod < 0) { @@ -2549,7 +2548,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, } } - cleanup_ref_head_accounting(trans, head); + btrfs_cleanup_ref_head_accounting(fs_info, delayed_refs, head); trace_run_delayed_ref_head(fs_info, head, 0); btrfs_delayed_ref_unlock(head); @@ -7191,7 +7190,7 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans, if (head->must_insert_reserved) ret = 1; - cleanup_ref_head_accounting(trans, head); + btrfs_cleanup_ref_head_accounting(trans->fs_info, delayed_refs, head); mutex_unlock(&head->mutex); btrfs_put_delayed_ref_head(head); return ret; From patchwork Thu Aug 30 17:42:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582479 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 0D5815A4 for ; Thu, 30 Aug 2018 17:43:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE03228673 for ; Thu, 30 Aug 2018 17:43:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E251028681; Thu, 30 Aug 2018 17:43:21 +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 905ED28673 for ; Thu, 30 Aug 2018 17:43:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbeH3Vqf (ORCPT ); Thu, 30 Aug 2018 17:46:35 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:40278 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqf (ORCPT ); Thu, 30 Aug 2018 17:46:35 -0400 Received: by mail-qt0-f195.google.com with SMTP id h4-v6so11301781qtj.7 for ; Thu, 30 Aug 2018 10:43:19 -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=rdFMLganFUJmkufg/fNzG2rGuQGdhIppXIRGG3mh4TA=; b=dkgbkVXxP3RMEuImg/akojiAZjjyOOXo15jvBPGhGF4eJ9XMofVhdry0gjAhpPP0EM 46rJA+0y34dhyHpul+5GiF6UchVcd0ikFor4tlKe/G+BOL/M0Ma+muQCDqLxUY2oZIKR b+NkeAauuDXWGfrFzoDrWQqP/LA+YGKbkfXBxSq9ugIh5m9CiBGvW+0FCvyJpx1NyaRZ cMSqsd8cuF5IB99n880rKVl+BIJQMwRggAFxahAFj8HetL0P2eTwwOHia5RWg6zdXgO7 E7rOz21bt6WyQmTC94QWlaQmu+Ji3nxzuky6Ro3yydKUHhmukFsS9kxDPzO4rbT9++Xt MNYg== 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=rdFMLganFUJmkufg/fNzG2rGuQGdhIppXIRGG3mh4TA=; b=d49FytgagJw/bTbjgDTFD6V0Wi+jYGh6qBZ6TElUrfUkSKP4NlFxaFFmKncHeVh8Mn n1B3Fl0Ijm9vnZiWgjh6TI8IGEB9W/HzQKdiy1LBcSvO1Dus6sz/ZcCV+H0H3FWWbgxo TUdnoiqtNdw17y6dIgXuaMGUmG43ABUkP6iILrWch9iBHMZeF/0Dn/JMeNYNdXdHlh5k Mbj3M4X5ZJRePdA4WOacNDP8MaWj5AYtF7GjunU+3bxFhoLAV2zNz4+Qk1+v9EvdHzLk tz5Hd+aXiukfq096v/CELz6OgAxoTKV8ueCaLifRuMW4WLbA1JFmzjsoHiRfXfR88Ere NThQ== X-Gm-Message-State: APzg51BG8bdacKrRhn8qzXXxazXw3P50FAMT+EuvC67cwSWyz0gqsaRF TC0BIVefo7jhrkTX7RX/8Ip5/8jti7C99Q== X-Google-Smtp-Source: ANB0Vda5IhS3twcpG+DbR7ncp/4uBdr9KUBPhsuv2lmQgU//1OpSfR+TA7i6OMwYjSPnbjXV6g9fgw== X-Received: by 2002:a0c:d5d3:: with SMTP id h19-v6mr12666698qvi.218.1535650998889; Thu, 30 Aug 2018 10:43:18 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id n63-v6sm4291938qkd.80.2018.08.30.10.43.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:18 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 28/35] btrfs: call btrfs_create_pending_block_groups unconditionally Date: Thu, 30 Aug 2018 13:42:18 -0400 Message-Id: <20180830174225.2200-29-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 The first thing we do is loop through the list, this if (!list_empty()) btrfs_create_pending_block_groups(); thing is just wasted space. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/extent-tree.c | 3 +-- fs/btrfs/transaction.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 031d2b11ddee..90f267f4dd0f 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2970,8 +2970,7 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, } if (run_all) { - if (!list_empty(&trans->new_bgs)) - btrfs_create_pending_block_groups(trans); + btrfs_create_pending_block_groups(trans); spin_lock(&delayed_refs->lock); node = rb_first(&delayed_refs->href_root); diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 2bb19e2ded5e..89d14f135837 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -839,8 +839,7 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, btrfs_trans_release_metadata(trans); trans->block_rsv = NULL; - if (!list_empty(&trans->new_bgs)) - btrfs_create_pending_block_groups(trans); + btrfs_create_pending_block_groups(trans); btrfs_trans_release_chunk_metadata(trans); @@ -1927,8 +1926,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) cur_trans->delayed_refs.flushing = 1; smp_wmb(); - if (!list_empty(&trans->new_bgs)) - btrfs_create_pending_block_groups(trans); + btrfs_create_pending_block_groups(trans); if (!test_bit(BTRFS_TRANS_DIRTY_BG_RUN, &cur_trans->flags)) { int run_it = 0; From patchwork Thu Aug 30 17:42:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582481 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 9DA1B1805 for ; Thu, 30 Aug 2018 17:43:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8454328676 for ; Thu, 30 Aug 2018 17:43:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7839D2C363; Thu, 30 Aug 2018 17:43:23 +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 0E40228676 for ; Thu, 30 Aug 2018 17:43:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727727AbeH3Vqg (ORCPT ); Thu, 30 Aug 2018 17:46:36 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:44485 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqg (ORCPT ); Thu, 30 Aug 2018 17:46:36 -0400 Received: by mail-qt0-f196.google.com with SMTP id k38-v6so11285517qtk.11 for ; Thu, 30 Aug 2018 10:43:21 -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=fO7/zB41YFxTFsoapdxATBT+tWvYEisHvJIXvVumirM=; b=hSGP35YZtOFg0PtlUiWrlox2XP4Q02vfyQJiskXyEeMT0Get5nSdPQpsJHOjSCEGSV PAdNUqr7k9gHWAJpBb/G23db1PYrtsUYaZwS45rKaxdK91OQnPYukrbCnBu3U5JPzvZb rSB3YyF1wU2XFHBBkN+BgoaFN29dnDEmQQq+TiRdLatmLEO8ADOaMA2nAwKMD+uLWHcH 1Dp+tBAGGjCJNDNVt3T9/LtiM/beh/LKFluygcO1b2Fr7QLlwo6CuRLMeJIDDfCv++lm xsalhkrWy/81Q+6yWs9vkYR+TiHo7ZXuNFaYp7epePxR0LSGz5gHqtp0gc0ncoNDYsJp KJpQ== 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=fO7/zB41YFxTFsoapdxATBT+tWvYEisHvJIXvVumirM=; b=fzwE9Bq06u7kchkFCMrfVa+0fZDDq4MlQjnOzON0bqA0QDdklifnwCnz6w5+PtY/Zy E9oOfyRHAN4IR/Zu41BaIavQvKJH6W4JMrg6OdPCVhzi1RiQx/jXMjF2Ln63weGqGvHP zYbAHfDujVJfNpZ4GLJpuMxODdv4hT7/3r0FRdnrX0q8Da/HYtPx4mL8JwkTxUvIO/pw vbRQmUF+ZcWZJN81+PKW+TWQQlzDrloipIK1pCMWIC9WR040gC4dPP/9r2caK0MCRcvJ I4Yki1dcl2MLKFmvvZAwcgNwnQZIoiAhNfmf7aOpPRq635zZlG73FuugAx5r8f5N9gda rnrQ== X-Gm-Message-State: APzg51BVhURqrjVmbLAQR79J1HFjfDCnmjDcvgKWMjE/kHhDA4oRzjsJ 3KxqVvG+TJ9ABsjiFH+CrvkIhWKPPoeyBg== X-Google-Smtp-Source: ANB0Vdb4BJUbyOIYFRiHrDQw2EZ6e5vretxjwj2n/5eWnVPFcnsvQFMd5vc1sNZNPY4rgEiofgmEWQ== X-Received: by 2002:a37:ad0a:: with SMTP id f10-v6mr12402653qkm.186.1535651000609; Thu, 30 Aug 2018 10:43:20 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id v10-v6sm4945076qtv.77.2018.08.30.10.43.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:19 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 29/35] btrfs: just delete pending bgs if we are aborted Date: Thu, 30 Aug 2018 13:42:19 -0400 Message-Id: <20180830174225.2200-30-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 We still need to do all of the accounting cleanup for pending block groups if we abort. So set the ret to trans->aborted so if we aborted the cleanup happens and everybody is happy. Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval --- fs/btrfs/extent-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 90f267f4dd0f..132a1157982c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -10333,7 +10333,7 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans) struct btrfs_root *extent_root = fs_info->extent_root; struct btrfs_block_group_item item; struct btrfs_key key; - int ret = 0; + int ret = trans->aborted; bool can_flush_pending_bgs = trans->can_flush_pending_bgs; trans->can_flush_pending_bgs = false; From patchwork Thu Aug 30 17:42:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582483 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 0748F5A4 for ; Thu, 30 Aug 2018 17:43:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB2B628676 for ; Thu, 30 Aug 2018 17:43:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF8262C363; Thu, 30 Aug 2018 17:43:24 +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 8B18E28676 for ; Thu, 30 Aug 2018 17:43:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727733AbeH3Vqi (ORCPT ); Thu, 30 Aug 2018 17:46:38 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:42494 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqi (ORCPT ); Thu, 30 Aug 2018 17:46:38 -0400 Received: by mail-qt0-f194.google.com with SMTP id z8-v6so11280964qto.9 for ; Thu, 30 Aug 2018 10:43:22 -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=l11WaW/DYx1K0SX0a4CXfC5K2UbiabuVvcP8mlSURVg=; b=c3lSC9q5kW/eVIqceW4irdEFmWUWqaB+EiKX/wa+e3QTX1XJilUzeDhNhg7RI9R2Rp 5DrQxUR83Lp8NRk/Ab/45f6SGCnCsdknExmyUYnqVHCJwdXHUYuLLh+Fz+N2Tr1q19tr KRlDXczWK0oUWXuk2axBt9YRLllsUMSeV4uUAoyXiYHaMx/gGEtelCURTyTCC7ewIF+v 1nnyb54niSoFskzQWUhO+7qlB01u/OgiB6qgnlkXa77HQNPIZUy9A96+NzGTqyBxkbsU ccHU7zV8LBTebfYvVbmlPwSS53PgQ4A38PL9NSKmRSDKa7MwrbnrNh7fOakVdVytikdb cXOA== 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=l11WaW/DYx1K0SX0a4CXfC5K2UbiabuVvcP8mlSURVg=; b=k7bZ/JO1IC/UXkudJ+/LXyUuafr12zjsmgv4O7KqkDQGyUZhwvAgES3h3UCN4nM3y8 fSxt68L5XJRwsaAbQRdjeecdjNTJx8sh/PXd+gUA8q4spkW14FktCU6MKhsAkcQxODUr Mr06cCCdi8fJfPczwkx8Kx6miHASysvj+zkvs6aQfPogzGGf8+hDzmgtZwWfwWrWFtHF 1LapTu2yLal8qx5mQIYgzBQCGyx1fZbZ/3cukitpTBuggoj1mid+LdApYwPznJ+VEYu6 cck5X/uNt+/rya/Pb9eQA9KwxNpteeUoaPcy2RkN+KyK/FtBhqmEZIjOoj1nkGXfMkk2 37dA== X-Gm-Message-State: APzg51BACqvkYdpYcS7DDUBCxJnTDPLIxcoO2xHSHsyNk5VV/Gv3rkQh KudVXAjuwTDoWasGTGGOsAPn35VpS3OQgA== X-Google-Smtp-Source: ANB0Vdakki2F2XEvuZ8mA6crLtm2OX1qZV2vSQZ3QVdscTTlSgUIb1bGI62Jw3Zty3v5iaJOPzKjNQ== X-Received: by 2002:a0c:fb42:: with SMTP id b2-v6mr12529145qvq.215.1535651002299; Thu, 30 Aug 2018 10:43:22 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id n8-v6sm4758731qtk.38.2018.08.30.10.43.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:21 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 30/35] btrfs: cleanup pending bgs on transaction abort Date: Thu, 30 Aug 2018 13:42:20 -0400 Message-Id: <20180830174225.2200-31-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 We may abort the transaction during a commit and not have a chance to run the pending bgs stuff, which will leave block groups on our list and cause us accounting issues and leaked memory. Fix this by running the pending bgs when we cleanup a transaction. Signed-off-by: Josef Bacik Reviewed-by: Omar Sandoval --- fs/btrfs/transaction.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 89d14f135837..0f39a0d302d3 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -2273,6 +2273,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans) btrfs_scrub_continue(fs_info); cleanup_transaction: btrfs_trans_release_metadata(trans); + btrfs_create_pending_block_groups(trans); btrfs_trans_release_chunk_metadata(trans); trans->block_rsv = NULL; btrfs_warn(fs_info, "Skipping commit of aborted transaction."); From patchwork Thu Aug 30 17:42:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582485 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 A04CD5A4 for ; Thu, 30 Aug 2018 17:43:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F95128676 for ; Thu, 30 Aug 2018 17:43:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83F222C363; Thu, 30 Aug 2018 17:43:26 +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 2C84D28676 for ; Thu, 30 Aug 2018 17:43:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727738AbeH3Vqk (ORCPT ); Thu, 30 Aug 2018 17:46:40 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:40304 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqk (ORCPT ); Thu, 30 Aug 2018 17:46:40 -0400 Received: by mail-qt0-f196.google.com with SMTP id h4-v6so11302289qtj.7 for ; Thu, 30 Aug 2018 10:43:24 -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=Vmwt0Cy/WxIAbUmDMizmrqJULNUg9H158POyDXrkHZU=; b=VFw6N4ngsgzHjqFws7CdPulPkOFp7qEP/bxO5mMR9GTan/Pu/aO2Y1F7q+AeyZ+OXc M9m+tuWLntnZMP11MwO7UgDj5m2bysa2z25UR63We5x7eGXx/QlXp4QQXx72lOfjrUY2 RK9KHs+bmfUlj10Cc2UcytKQ5Squd8jPVgA11+IqJ8HTp6AmdCHbZNnhplVyj8z+QrHf d/4jy60IusCVBfHBAU63o3NCSpNxwKv+C0nyXpZnesMM04lfaPaWnSQEWenCccvFKl9r m3fwgdRhDRBJLF2Wd+ipyDFPDPCOS0GzNaRX6dV9rRYjAJeHYI3yDtQYok2swIJg1pxN d/zQ== 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=Vmwt0Cy/WxIAbUmDMizmrqJULNUg9H158POyDXrkHZU=; b=CDWwqjiTGwIN69hinDW9fZYDUivgQIGqkiciL2dJwER3QPJD+gMb/wYCuQFeLgGupj l7s5yJXy/nYc3PYfxp30SEFIpC8Q2D70FL6v4r9oUSHV7BnyocGIidi+GxkL2N6Ri5/W kRnoMnkQOHn37IsMBNAufCWq4hOvGHIgb4B9G1rbG4wzzTSjtdiG835Meh07HQ0lD0kz /Qpcq/8n3bhEIw24SxoOpNFS7NQiJpLB2MGKsyP2QaJGFX6hPZ/pgdlAI6WYUlZaJF/t 4IllLLhWlbN+b1RPs5XpKa5Or0FIrBlzOXshQF9jzHZ2fdZH/G4gBllABgnMVXtKRdG2 TYGA== X-Gm-Message-State: APzg51Dd+SxdJ43ZOl/h0Mxmf3B4zoGBrHEou5XW8g7OkFRKf9ln7OJd sutPnJv5gTpfuXHtPWR+rhlDDiRWsIrJdw== X-Google-Smtp-Source: ANB0VdZaV87n58Jl1bE1zZgmdNAs2aXm3U08iop/K1Fw4I5IPqZR+WiadfL71ZQRg6WZ/ZacsbvplQ== X-Received: by 2002:aed:3bc5:: with SMTP id s5-v6mr12812763qte.207.1535651004090; Thu, 30 Aug 2018 10:43:24 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id x76-v6sm4466515qkx.25.2018.08.30.10.43.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:23 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 31/35] btrfs: clear delayed_refs_rsv for dirty bg cleanup Date: Thu, 30 Aug 2018 13:42:21 -0400 Message-Id: <20180830174225.2200-32-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 We keep track of dirty bg's as a reservation in the delayed_refs_rsv, so when we abort and we cleanup those dirty bgs we need to drop their reservation so we don't have accounting issues and lots of scary messages on umount. Signed-off-by: Josef Bacik --- fs/btrfs/disk-io.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index caaca8154a1a..54fbdc944a3f 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4412,6 +4412,7 @@ void btrfs_cleanup_dirty_bgs(struct btrfs_transaction *cur_trans, spin_unlock(&cur_trans->dirty_bgs_lock); btrfs_put_block_group(cache); + btrfs_delayed_refs_rsv_release(fs_info, 1); spin_lock(&cur_trans->dirty_bgs_lock); } spin_unlock(&cur_trans->dirty_bgs_lock); From patchwork Thu Aug 30 17:42:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582487 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 D3A3C17DE for ; Thu, 30 Aug 2018 17:43:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C256F28676 for ; Thu, 30 Aug 2018 17:43:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6EBB2C363; Thu, 30 Aug 2018 17:43:28 +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 599C228676 for ; Thu, 30 Aug 2018 17:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727744AbeH3Vqm (ORCPT ); Thu, 30 Aug 2018 17:46:42 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:44506 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqm (ORCPT ); Thu, 30 Aug 2018 17:46:42 -0400 Received: by mail-qt0-f195.google.com with SMTP id k38-v6so11285983qtk.11 for ; Thu, 30 Aug 2018 10:43:26 -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=9YVjB9RAV9lj9QQFAj3ibH+qCVpd/gWk9al08NfwLZE=; b=sceDzIgHavoikJ9c6TpEsvaAYxZa1I6eP2jPnv255n+5BxumiZ5MpMWCkXtwv+kJwu l3LO2NrjxepzQQbbPiqEroTjTXkSjTrd1QOw/oqS/tIZhFGmwSMPEXyHsFOE/rbiPn23 TCMIkiZO7XRAtJT/FpJU3w3dyaX4rNsgarYcT0X7gfzFHg/97EKjstXIrfSXPRRQA22G cj899CF8nujzX8iFTXgYfkHlfDfO9DqkolIbeU7EyD41L5kRcgLFn9hsrPc0Cpd9ZBni F0RUv5yor3eixu9h8iUK92S/XkzHO1cA7FJtTtmmV/0opbSZYI35qvQ4R5jj2BFV1kQ8 nN3A== 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=9YVjB9RAV9lj9QQFAj3ibH+qCVpd/gWk9al08NfwLZE=; b=TIyfPUcaMhuzF4RHr2e5KvV2l0f74K2SVO6L1Qyab3BC2W6RCUZIXWbBVUHir8bIYb sFVMpzSdVVAyNXSNqm3vbtaunF5UNpvzL+BCqsALxdR/y+oZuLIpjvNB43SSOt0+jltf 2H/f8Zvqpa4IjqbFQN0RLI2zyi6ufpZWv3or/uC+ZAJMumg+96zri/NyUy2ob59PoyxF H3Ipx5jG1EcV4okarD4rSrMqXKjpQbZ5dtjJXE7N3aqDj9UhTrYC2zFjilc7axXHYaiJ VqOnSLFR3275XUMzwHIc0YlQ2Vq6+W8LYS/q740191LuMrDBq7jYnpRNACYYxAPLaG6s V0bA== X-Gm-Message-State: APzg51AKz1ZjpgN15if64j6m5OqgAWNPNgXt3dkGysRYU9TnvnVJtGny QIjgV3KFP+GgjE/8MLMojqm6ymD+zWgLRw== X-Google-Smtp-Source: ANB0VdaXdsUmLbkjsepW9zc5+e76MMnPzNEseRrT48g+3Ya0PhYil8KxDuNP3lp0Y8aHWreU9q+lRw== X-Received: by 2002:a0c:c252:: with SMTP id w18-v6mr12701293qvh.183.1535651005881; Thu, 30 Aug 2018 10:43:25 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id m95-v6sm4309467qte.69.2018.08.30.10.43.24 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:24 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 32/35] btrfs: only free reserved extent if we didn't insert it Date: Thu, 30 Aug 2018 13:42:22 -0400 Message-Id: <20180830174225.2200-33-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 When we insert the file extent once the ordered extent completes we free the reserved extent reservation as it'll have been migrated to the bytes_used counter. However if we error out after this step we'll still clear the reserved extent reservation, resulting in a negative accounting of the reserved bytes for the block group and space info. Fix this by only doing the free if we didn't successfully insert a file extent for this extent. Signed-off-by: Josef Bacik --- fs/btrfs/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 10455d0aa71c..3391f6a9fc77 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2992,6 +2992,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) bool truncated = false; bool range_locked = false; bool clear_new_delalloc_bytes = false; + bool clear_reserved_extent = true; if (!test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) && !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags) && @@ -3095,10 +3096,12 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) logical_len, logical_len, compress_type, 0, 0, BTRFS_FILE_EXTENT_REG); - if (!ret) + if (!ret) { + clear_reserved_extent = false; btrfs_release_delalloc_bytes(fs_info, ordered_extent->start, ordered_extent->disk_len); + } } unpin_extent_cache(&BTRFS_I(inode)->extent_tree, ordered_extent->file_offset, ordered_extent->len, @@ -3159,8 +3162,13 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent) * wrong we need to return the space for this ordered extent * back to the allocator. We only free the extent in the * truncated case if we didn't write out the extent at all. + * + * If we made it past insert_reserved_file_extent before we + * errored out then we don't need to do this as the accounting + * has already been done. */ if ((ret || !logical_len) && + clear_reserved_extent && !test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) && !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags)) btrfs_free_reserved_extent(fs_info, From patchwork Thu Aug 30 17:42:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582489 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 6A84317DE for ; Thu, 30 Aug 2018 17:43:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 599F128676 for ; Thu, 30 Aug 2018 17:43:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DBFE2C363; Thu, 30 Aug 2018 17:43:30 +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 E399528676 for ; Thu, 30 Aug 2018 17:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727749AbeH3Vqo (ORCPT ); Thu, 30 Aug 2018 17:46:44 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:42514 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqn (ORCPT ); Thu, 30 Aug 2018 17:46:43 -0400 Received: by mail-qt0-f193.google.com with SMTP id z8-v6so11281428qto.9 for ; Thu, 30 Aug 2018 10:43:28 -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=cdGLSjoEMzv5wkf8dGrK1Mg8LFxsgil57MfSR7TIG9s=; b=YTsYUfJU+IyL0vuutjMj4tSxwUGwdNIbal3TctEMHTzOSMnB3CeKn79UdSxdd/Ef7G rfCMVTwlJppAvzfEq1OUafrPFAQdzO8PF+f1w0eghLzQQhSE2lmV76iB7kU4X+4A5Aat n3d8ATxr/iI5ox3e6hBJi5HoQ3dE9WLAz+XgRjQuS0SUk5pqU/okNjX+aP1Gt8gvA4vq qEWgodXBikrMOmBr6JW+wKJ3hcH63fkp6LkS+Hs1aM91czp4KdX3T+avZIqz7S7i61jb UnnMdExHmZ5Q0fTnBHGYlbO6fDaaY9NO/+NOcamBCvt8ZQgg34xOHXOb8ckTY+Zp8g5c sy9A== 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=cdGLSjoEMzv5wkf8dGrK1Mg8LFxsgil57MfSR7TIG9s=; b=Z3wnwxOFljR/buszVJTgscOE1m9oGHc8swzpyPhzj9UnGu6GyPMinHuf1NkEya7uKy CBAkCoHZPWIZlZ5No78nr4bUG9la8GJNZoxVECFGrYrJ4IhGjWSo3x0f58HB7Od+p8L8 4PAtnsrRnj8Be7e6gb7fzs7ZeBX/NxfJghJZxWIgqD8X4AxehqK3RdN/69jpEfQUQlbR BEQMTrz9/mQk5Jvd0PER2yt/+zK1AH7JX8OQ9QGq1fr/QEMbsTGQkLjUsU4V/n9yykWi +/dQNHBvgiLWAjE1z5yK/mMdkROjN1q+fBEMnFsL2FbZVeirknNp2Ap4tVVHlD9CkcI8 pYFg== X-Gm-Message-State: APzg51D+EmwiGizkFmAzVSiOZUJ1h++QOcrfDuHnzygsXMLIhbWeAA5e oNqhbxHmmYpmSOEnSNn7VO0lTXqkMsxhOw== X-Google-Smtp-Source: ANB0VdbN6ERtW0OlwtXOyRgvvQzgLoRSihOh9THgYWpdTECU4qTZ5HfLbMp3JIPEasdCzC7Rc0Sbiw== X-Received: by 2002:a37:6512:: with SMTP id z18-v6mr12339244qkb.269.1535651007612; Thu, 30 Aug 2018 10:43:27 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id p5-v6sm4148146qkd.81.2018.08.30.10.43.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:26 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 33/35] btrfs: fix insert_reserved error handling Date: Thu, 30 Aug 2018 13:42:23 -0400 Message-Id: <20180830174225.2200-34-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 We were not handling the reserved byte accounting properly for data references. Metadata was fine, if it errored out the error paths would free the bytes_reserved count and pin the extent, but it even missed one of the error cases. So instead move this handling up into run_one_delayed_ref so we are sure that both cases are properly cleaned up in case of a transaction abort. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/extent-tree.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 132a1157982c..fd9169f80de0 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2405,6 +2405,9 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans, insert_reserved); else BUG(); + if (ret && insert_reserved) + btrfs_pin_extent(trans->fs_info, node->bytenr, + node->num_bytes, 1); return ret; } @@ -8227,21 +8230,14 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, } path = btrfs_alloc_path(); - if (!path) { - btrfs_free_and_pin_reserved_extent(fs_info, - extent_key.objectid, - fs_info->nodesize); + if (!path) return -ENOMEM; - } path->leave_spinning = 1; ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, &extent_key, size); if (ret) { btrfs_free_path(path); - btrfs_free_and_pin_reserved_extent(fs_info, - extent_key.objectid, - fs_info->nodesize); return ret; } From patchwork Thu Aug 30 17:42:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582491 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 4AEAB5A4 for ; Thu, 30 Aug 2018 17:43:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39E0E28676 for ; Thu, 30 Aug 2018 17:43:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E80D2C363; Thu, 30 Aug 2018 17:43:32 +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 D562128676 for ; Thu, 30 Aug 2018 17:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727753AbeH3Vqp (ORCPT ); Thu, 30 Aug 2018 17:46:45 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:35945 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqp (ORCPT ); Thu, 30 Aug 2018 17:46:45 -0400 Received: by mail-qt0-f193.google.com with SMTP id t5-v6so11321060qtn.3 for ; Thu, 30 Aug 2018 10:43:30 -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=Xb1Cr6yQ8rDat/54ctOxCRjwJqtEopvqWdESq9M76bo=; b=L1hIp/ShW6eUdn1bQFZ/FJYQcmU7+FOYGR+0ZPBdGACuTngX8uLB+wL6zXUVd32hWO 3MrxdQe3ZB4kjRQrH56ATZyRg7VYjdBi4+eO91R9cs8LvkbReVA99HCJwLd4xKzySSCS Sf5EwkjcID0ZNZqlS6twbucW/D2AwPZu/Bjj3L4J9T1uzqsOp3nVqge1FoqhphXMbyGH GNWjxOACJ2O7IOz+07j99EN0j+ELr9veK+QY5dcVMH4MosGKAeICTWnnqmLE8wK5Oull 5ZJ9EzMnV2x2h1Rxfn69PcFMC+vainF0yzDpWvi8c469yF09YMtQpPsCfJU25CyvyAe6 dQ2g== 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=Xb1Cr6yQ8rDat/54ctOxCRjwJqtEopvqWdESq9M76bo=; b=UIoNtVhlM7R23TqSmHT/gFBFn/8KnrzuCq222VNeThe5xFReyQJmdgheXsfojnp1H/ bvmwokzt5rgxOraE/K8JaUoZGK4JGiRSLArPEVtZ1S4cR3ERQTNExUbO/J6Yz2lHch03 YzK2xjN1Kes6ealKkTWl4ihocBDepGqjr0xqrdS080F6P79XUYMW7MohrHBwpUMVAd4V 9nGPoD25EUI5FU4UQuNzokhHDD90liOizF7YJt1FXtTTkdYJtSIFQixqn21YA1Tb7T/M HC4kf4wgJR8Hysfo06cAfm/2anCFCV0ZnMN46IrpfKqV3wtSiK4Hj7D7Jxm5wVODf9tJ Qx8A== X-Gm-Message-State: APzg51B2zpx1CqyJRnnUoHn3qxwPjPyhkRoeL4pGrC7weehdosjr3j2B xmWWpzzOmMO7PdyiVUU+9tH4uV3+pYjueQ== X-Google-Smtp-Source: ANB0VdZoF/EtovHDIIm4Xinh4wUsn7kgq7lpyXBtrqRxl8jDlHjwoU564n+zrDU8gHNZmGz5fn8ZUA== X-Received: by 2002:ac8:4691:: with SMTP id g17-v6mr13051456qto.137.1535651009473; Thu, 30 Aug 2018 10:43:29 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id 60-v6sm4294899qte.29.2018.08.30.10.43.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:28 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 34/35] btrfs: wait on ordered extents on abort cleanup Date: Thu, 30 Aug 2018 13:42:24 -0400 Message-Id: <20180830174225.2200-35-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 If we flip read-only before we initiate writeback on all dirty pages for ordered extents we've created then we'll have ordered extents left over on umount, which results in all sorts of bad things happening. Fix this by making sure we wait on ordered extents if we have to do the aborted transaction cleanup stuff. Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov --- fs/btrfs/disk-io.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 54fbdc944a3f..51b2a5bf25e5 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -4188,6 +4188,14 @@ static void btrfs_destroy_all_ordered_extents(struct btrfs_fs_info *fs_info) spin_lock(&fs_info->ordered_root_lock); } spin_unlock(&fs_info->ordered_root_lock); + + /* + * We need this here because if we've been flipped read-only we won't + * get sync() from the umount, so we need to make sure any ordered + * extents that haven't had their dirty pages IO start writeout yet + * actually get run and error out properly. + */ + btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); } static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans, From patchwork Thu Aug 30 17:42:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 10582493 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 7B60517DE for ; Thu, 30 Aug 2018 17:43:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A75728676 for ; Thu, 30 Aug 2018 17:43:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ECDC2C363; Thu, 30 Aug 2018 17:43: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.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 0449628676 for ; Thu, 30 Aug 2018 17:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727760AbeH3Vqr (ORCPT ); Thu, 30 Aug 2018 17:46:47 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:34925 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726878AbeH3Vqr (ORCPT ); Thu, 30 Aug 2018 17:46:47 -0400 Received: by mail-qt0-f195.google.com with SMTP id j7-v6so11320372qtp.2 for ; Thu, 30 Aug 2018 10:43:31 -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=ja6BEdk2d172wcHDS/gitUITWM0Dn5OfC8ykxBklKgo=; b=rGJodda0CHVJcDaVI+x8fV4pbr/nNDUCFoflJIPFlbyJiIeuF6NtYY6pQLqldKmgYV Pc6Fma0nbiJcGOWOIr0bYOtYDmwe6QHRxCAbm2SCalrDQMRYCr8Mi6Erhl+8N1MVk6Rq fQMzHxGafYcLfG3spIbGsXPx/fkmfM0b5cK3M37YGFQ4hHUEZHmwPauCCDZFO3iKNwr9 3sQyrKTtKhhvqLK3lqoJnxCW6XyoQ2jPfMhikIEwt4fSD2ZnFnr1N1wHDyv7P8CUaSAt VotLr5UftnKwOCc7dWmevLajQtRyt6WfopYDUKgSWNaF/UbvIQiZhht/GwROvWERBZYL WZug== 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=ja6BEdk2d172wcHDS/gitUITWM0Dn5OfC8ykxBklKgo=; b=o8s+ZOQsjmc/wdtuFp21IzH2KXCp4WL3Ko6ud32+IDzgQFoKZP4HO7TK3ZKzJJRWCN rn57LVLiYLy6MYXWitsdF++9Wr8iMSQR+ZjPw1WZ+t6icO0NJAXqSDRDmCKaa0SCT1cA LZ+A6iKWu/JC4ARTGZHDGUYHZ2vBJUgd2cvEf4IvWgFwpN/sn8szporGVw95YTwFyUnc OJq5RvTlX1zpyyUcvm9tGxlszEON8wqnfFBcnFxOxqS3xYx3VNEG9+KgBVcvMGRdz65E p9XpKLh2dNdFXRVAmryh8eHm5SCjwmzILdATYCuAMOdWcZQEh1+0yYSSGKEAWzSBVG13 ZZ/Q== X-Gm-Message-State: APzg51DvSBrQchXRcIMU7ZIUc/49uN+mfLf3ohAlOcwV+/TtyVacL1SL S+uPNb5DGwB5Z+GgwHavJ0/ekjfYRJVJ+w== X-Google-Smtp-Source: ANB0VdZrxRSAUmzHfQJxTJR+cgklijCb/zey7g6KiEiU+mj4x/4wfQAMl+L6tSiaC6X1uni+t9k9Zg== X-Received: by 2002:a0c:db0c:: with SMTP id d12-v6mr12491003qvk.33.1535651011268; Thu, 30 Aug 2018 10:43:31 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id e65-v6sm4109449qkf.39.2018.08.30.10.43.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Aug 2018 10:43:30 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org Subject: [PATCH 35/35] MAINTAINERS: update my email address for btrfs Date: Thu, 30 Aug 2018 13:42:25 -0400 Message-Id: <20180830174225.2200-36-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 My work email is completely useless, switch it to my personal address so I get emails on a account I actually pay attention to. Signed-off-by: Josef Bacik --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 32fbc6f732d4..7723dc958e99 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3095,7 +3095,7 @@ F: drivers/gpio/gpio-bt8xx.c BTRFS FILE SYSTEM M: Chris Mason -M: Josef Bacik +M: Josef Bacik M: David Sterba L: linux-btrfs@vger.kernel.org W: http://btrfs.wiki.kernel.org/