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;