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