From patchwork Mon Sep 11 21:12:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9948125 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 455EB6024A for ; Mon, 11 Sep 2017 21:12:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D9F728D62 for ; Mon, 11 Sep 2017 21:12:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 228BE28D66; Mon, 11 Sep 2017 21:12:48 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 9773328D62 for ; Mon, 11 Sep 2017 21:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbdIKVMo (ORCPT ); Mon, 11 Sep 2017 17:12:44 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:33010 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbdIKVMm (ORCPT ); Mon, 11 Sep 2017 17:12:42 -0400 Received: by mail-qt0-f195.google.com with SMTP id b1so3962069qtc.0 for ; Mon, 11 Sep 2017 14:12:41 -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=xQaIgyjMHjd3I6Lq3fV4w8dI+w1IdEI9aas25kVNtJo=; b=HhPcDYf6vA1JQoGSO0ZaG3UIEbjK3RzTv4DqUeeXmMJgd64/xjv2mnQnf9xFYuoAIk ijmv2k+K2nHXcqrE+0KoQU5eQUKQmBGaAuxFz6rZAJjzwQIivEuzAvxGLePJUhGyOF2K eteaVdgS/a8QsaUd9IMjLWUmvYIU3PgWJ449hAfZOzwZYiOT+e1f2itKn0BKKdN/vISX 0cIPKUwQ3w4Q0/jrOCI2bC93XSSJA3jRja2qt0kdNftFg/6XqdbTh51IntOcHSQzUxuu tgEZZNDRR02A9Fv56p+7vrK7RtJYouRWdnYt4ErNjBvXPRkoSCghxe4E3y4pqzyTVaNh CnDg== 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=xQaIgyjMHjd3I6Lq3fV4w8dI+w1IdEI9aas25kVNtJo=; b=Mpz1e/7F5lEPZ31m1HiaAkUV6OSBZErVS3y4K1PWsq96Y6YRsdo+6MAZHEzclQEllq 3bctnTIckSjqWBG4GpxvhLEh9RiFNZfQMiaIymq6t+9m0rOZmDI2frPHdlw3eY+kYBeK zeBVKsq3HwtnRQttbvQ0tXuKcKBS2EddVTsXldwMFwEEX+eMDI3hJMMPbtONpGODkCKT wsuRoMcsUxZ0R+rabiTGcO3dHtMySsC+SIaE0tCm7ux80cj6kbhgbdKWIx2kABLiaVVa ZfKmg8wUFlJKjPer0WS5vob/Ob8asyzS3SkN/U1+Wjz5rqWK4OMfyQ0S0EM3NcCYu6p4 e62A== X-Gm-Message-State: AHPjjUiwCNzL5XE9WftU82zyTChIlRMi0mFfu1IB8rQv/6c8Vx8QJDWS bSAugE4rIaszC1g0 X-Google-Smtp-Source: AOwi7QCJVpp2aunfkeuUEMGx1w36nDjT833b1ud1mkEBlPvW5QEIm0XPfDR1hen/6MOU1z9gT/IF1A== X-Received: by 10.200.19.73 with SMTP id f9mr8768078qtj.158.1505164361396; Mon, 11 Sep 2017 14:12:41 -0700 (PDT) Received: from localhost ([2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id v17sm6876970qtv.62.2017.09.11.14.12.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Sep 2017 14:12:40 -0700 (PDT) From: josef@toxicpanda.com X-Google-Original-From: jbacik@fb.com To: kernel-team@fb.com, linux-btrfs@vger.kernel.org Cc: Josef Bacik Subject: [PATCH 01/10] btrfs: add a helper to return a head ref Date: Mon, 11 Sep 2017 17:12:27 -0400 Message-Id: <1505164356-13474-2-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505164356-13474-1-git-send-email-jbacik@fb.com> References: <1505164356-13474-1-git-send-email-jbacik@fb.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 Simplify the error handling in __btrfs_run_delayed_refs by breaking out the code used to return a head back to the delayed_refs tree for processing into a helper function. Signed-off-by: Josef Bacik --- fs/btrfs/extent-tree.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index b68fb8c..636aac0 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2508,6 +2508,17 @@ select_delayed_ref(struct btrfs_delayed_ref_head *head) return ref; } +static void +unselect_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_refs, + struct btrfs_delayed_ref_head *head) +{ + spin_lock(&delayed_refs->lock); + head->processing = 0; + delayed_refs->num_heads_ready++; + spin_unlock(&delayed_refs->lock); + btrfs_delayed_ref_unlock(head); +} + /* * Returns 0 on success or if called with an already aborted transaction. * Returns -ENOMEM or -EIO on failure and will abort the transaction. @@ -2581,11 +2592,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, if (ref && ref->seq && btrfs_check_delayed_seq(fs_info, delayed_refs, ref->seq)) { spin_unlock(&locked_ref->lock); - spin_lock(&delayed_refs->lock); - locked_ref->processing = 0; - delayed_refs->num_heads_ready++; - spin_unlock(&delayed_refs->lock); - btrfs_delayed_ref_unlock(locked_ref); + unselect_delayed_ref_head(delayed_refs, locked_ref); locked_ref = NULL; cond_resched(); count++; @@ -2631,14 +2638,11 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, */ if (must_insert_reserved) locked_ref->must_insert_reserved = 1; - spin_lock(&delayed_refs->lock); - locked_ref->processing = 0; - delayed_refs->num_heads_ready++; - spin_unlock(&delayed_refs->lock); + unselect_delayed_ref_head(delayed_refs, + locked_ref); btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret); - btrfs_delayed_ref_unlock(locked_ref); return ret; } continue; @@ -2696,11 +2700,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, btrfs_free_delayed_extent_op(extent_op); if (ret) { - spin_lock(&delayed_refs->lock); - locked_ref->processing = 0; - delayed_refs->num_heads_ready++; - spin_unlock(&delayed_refs->lock); - btrfs_delayed_ref_unlock(locked_ref); + unselect_delayed_ref_head(delayed_refs, locked_ref); btrfs_put_delayed_ref(ref); btrfs_debug(fs_info, "run_one_delayed_ref returned %d", ret);