From patchwork Thu Oct 11 19:54: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: 10637339 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 2E90D157A for ; Thu, 11 Oct 2018 19:55:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D4F42C09B for ; Thu, 11 Oct 2018 19:55:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 118FC2C0A2; Thu, 11 Oct 2018 19:55: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 B53242C09F for ; Thu, 11 Oct 2018 19:55:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727082AbeJLDYK (ORCPT ); Thu, 11 Oct 2018 23:24:10 -0400 Received: from mail-qt1-f173.google.com ([209.85.160.173]:43337 "EHLO mail-qt1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726831AbeJLDYJ (ORCPT ); Thu, 11 Oct 2018 23:24:09 -0400 Received: by mail-qt1-f173.google.com with SMTP id q41-v6so11336205qtq.10 for ; Thu, 11 Oct 2018 12:55:23 -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=X+PT81/Zp3zcYtUcLLi8M0fbP5w87s6IcVZs1kVoVUA=; b=JpFhFPSbLvkIgXUEZk5rcRryuq6R7zg44GGSlm0d3AafpFaqZ3HfNtb+GJ7HdNrp04 fhfznbSEXItaJK47iFYL3cD5MtAfmkrsN9jl91O8w1flkOOR6JYwihXBrSd0kEXwjW+S pg3wqUB03YtPbw6ntjL5Ozp0vBlqsw+0dI1rnDg17tSSGq8GlNV/un2YHDZ+XeLaV7TN jVLPCzk9cr4bDm3HCayhfN0wU+5W140bBOkaAlXC8Hd+SfYt6630vJCS7xtefrcuU/bF qO3YZIQDJyAlWgeZf8c1vbS8Kt08fGqz021UapLJ5ZlglmZlns+qFYdJbbRqx/l8IFbz Mogg== 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=X+PT81/Zp3zcYtUcLLi8M0fbP5w87s6IcVZs1kVoVUA=; b=IdcmLCBCGNv+yJits2XsiZcwjbt5N3af16eZuXzyat39Jzx3bItfooam39cfkzCzp+ eoD9RPMMOCFYihTtaBOJSqA89H5grLrgJkJFpAYbUGcYbx5xRe+Jf+UNmXr2wYuNTjT3 QiDSVhMaSF2Aemgk8qLyvccnu+s0fO4WOPucXl3GXCberl3tP71yJsY6YZVkPFmRPKn8 FSptDt+YUjObABog6nYVQ+HzXU0wUL0sJkDc2OlKug4lckT2CIwvcYKyJkZrwx9thTz/ 2aVzkDJ5PialYdRKhspYFZwZnFCacou4H7Lnaj4NmZ44RKVCSX+VRoC+Zl3LnSugY//q TbiQ== X-Gm-Message-State: ABuFfoiQgAMHISKYJfwIDkd0dKYE7PwBNQ85PG64yAcAI109TBJBZK9o tdni3zl/wu7fzDD7pYmbXcdBWg== X-Google-Smtp-Source: ACcGV62Ki5yRZA3PI3vpbkwmuZvVUCIXcXZ0rfDHsGXfTlU9WyXCmApMIwuLKrxRo8B5SFquXEznJw== X-Received: by 2002:ac8:ec3:: with SMTP id w3-v6mr3024168qti.138.1539287723036; Thu, 11 Oct 2018 12:55:23 -0700 (PDT) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id e2-v6sm10869159qkm.55.2018.10.11.12.55.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 Oct 2018 12:55:22 -0700 (PDT) From: Josef Bacik To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Subject: [PATCH 26/42] btrfs: make btrfs_destroy_delayed_refs use btrfs_delayed_ref_lock Date: Thu, 11 Oct 2018 15:54:15 -0400 Message-Id: <20181011195431.3441-27-josef@toxicpanda.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181011195431.3441-1-josef@toxicpanda.com> References: <20181011195431.3441-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. Reviewed-by: Nikolay Borisov Signed-off-by: Josef Bacik --- 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 39bd158466cd..121ab180a78a 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,