From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5996BC71122 for ; Fri, 12 Oct 2018 19:33:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 229B42087D for ; Fri, 12 Oct 2018 19:33:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="ob7X3CVr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 229B42087D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=toxicpanda.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-btrfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbeJMDHH (ORCPT ); Fri, 12 Oct 2018 23:07:07 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:45225 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725935AbeJMDHG (ORCPT ); Fri, 12 Oct 2018 23:07:06 -0400 Received: by mail-qt1-f194.google.com with SMTP id e10-v6so15040573qtq.12 for ; Fri, 12 Oct 2018 12:33:06 -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=rHTVMCxRLsTEVUkODyGqkPIz399o/p3gyRkwe0nkz4U=; b=ob7X3CVr+I302weDMTaQgmJLUgRtHBIfMlTtZgKoZGEBc/mtbCvO5wXH8aVC/mOhou 4SQE9f7Shi643gRhSGkRGSUpjcfloULuUifaiVBR4stkjjEo0yXVySr0Lpx/yGeJivxl x/EWNAYIreb+6MHTL1HlGjozGnF5gLYfWm0MpeKTdALYqpt2BxBuV3Wnqcjzkz0dHfCp CV6WCNuYyDzfzcC7KoGSR0PtS7aCZb6lDWtqV6gKyreLTV5Ejnlu7XLKLd4QVK8GdMFo mUd3JhKo3q6hJnU1fCrTV+Cp6w3IzzJJmIUPsNahr5fRo9K7oaU6CL/9P9IeKbu2Kgdg 7phA== 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=rHTVMCxRLsTEVUkODyGqkPIz399o/p3gyRkwe0nkz4U=; b=lIw9ZgY+w2ZjtiptJw70U9RpwpiHqX4CBr7axxpXaq6fGOHH9qzXFCPIlJMwu0J8TN bIJtVPD1cT9LekOrJgHnP5tR215QeCgeZ47G288OXF7L9zn0st15cAcbqwsVcXMNJcKp /GW0L3A+3HbZiO+wFHil9rCunquygZiC5aRFAaP4OI4876j2jdS71PPtGgkcGIC+wjDo 809Vxw7Z5BJhMWZdwGiGMAmgHRkihrpfiz8gGnKR0ktI764rSSYwzCGTxsLvTPUS2zbk 9EYd4S5aF6Nt8DNu2xSjLEBVsBO536MgiufeIe7DgCZxRsg/6mFgdYZ4oVDSTGGCb4ai fxBg== X-Gm-Message-State: ABuFfojyqpzSUKSdszKcPhQHuLboUIKQjCnd1UVmXwm5YAVJN0wzMisk kjoAzB1kSW1IX/7EtFeLDPUcYexk3Z8= X-Google-Smtp-Source: ACcGV61Uv9kzHPLirg/qySYd5n/a/HGekK9t0T4TQnFhJ1Re9OiKc0aVIbs0UeIi8kKlXI9L2aB3Ag== X-Received: by 2002:a0c:d4e5:: with SMTP id y34mr7396065qvh.106.1539372785293; Fri, 12 Oct 2018 12:33:05 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id c36-v6sm2002877qta.56.2018.10.12.12.33.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Oct 2018 12:33:04 -0700 (PDT) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Cc: Josef Bacik Subject: [PATCH 03/42] btrfs: cleanup extent_op handling Date: Fri, 12 Oct 2018 15:32:17 -0400 Message-Id: <20181012193256.13735-4-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181012193256.13735-1-josef@toxicpanda.com> References: <20181012193256.13735-1-josef@toxicpanda.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Josef Bacik The cleanup_extent_op function actually would run the extent_op if it needed running, which made the name sort of a misnomer. Change it to run_and_cleanup_extent_op, and move the actual cleanup work to cleanup_extent_op so it can be used by check_ref_cleanup() in order to unify the extent op handling. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index a44d55e36e11..98f36dfeccb0 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2442,19 +2442,33 @@ static void unselect_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_ref btrfs_delayed_ref_unlock(head); } -static int cleanup_extent_op(struct btrfs_trans_handle *trans, - struct btrfs_delayed_ref_head *head) +static struct btrfs_delayed_extent_op * +cleanup_extent_op(struct btrfs_trans_handle *trans, + struct btrfs_delayed_ref_head *head) { struct btrfs_delayed_extent_op *extent_op = head->extent_op; - int ret; if (!extent_op) - return 0; - head->extent_op = NULL; + return NULL; + if (head->must_insert_reserved) { + head->extent_op = NULL; btrfs_free_delayed_extent_op(extent_op); - return 0; + return NULL; } + return extent_op; +} + +static int run_and_cleanup_extent_op(struct btrfs_trans_handle *trans, + struct btrfs_delayed_ref_head *head) +{ + struct btrfs_delayed_extent_op *extent_op = + cleanup_extent_op(trans, head); + int ret; + + if (!extent_op) + return 0; + head->extent_op = NULL; spin_unlock(&head->lock); ret = run_delayed_extent_op(trans, head, extent_op); btrfs_free_delayed_extent_op(extent_op); @@ -2506,7 +2520,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, delayed_refs = &trans->transaction->delayed_refs; - ret = cleanup_extent_op(trans, head); + ret = run_and_cleanup_extent_op(trans, head); if (ret < 0) { unselect_delayed_ref_head(delayed_refs, head); btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret); @@ -6977,12 +6991,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) != NULL) + goto out; /* * waiting for the lock here would deadlock. If someone else has it -- 2.14.3