From patchwork Tue Jul 25 20:51:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Mahoney X-Patchwork-Id: 9863537 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 D06D2600F5 for ; Tue, 25 Jul 2017 20:51:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD4F8286F7 for ; Tue, 25 Jul 2017 20:51:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B26C728701; Tue, 25 Jul 2017 20:51:34 +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.9 required=2.0 tests=BAYES_00,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 4556A286F7 for ; Tue, 25 Jul 2017 20:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752695AbdGYUvb (ORCPT ); Tue, 25 Jul 2017 16:51:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:44902 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752813AbdGYUvC (ORCPT ); Tue, 25 Jul 2017 16:51:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F374FAEC1 for ; Tue, 25 Jul 2017 20:51:00 +0000 (UTC) Received: by starscream.home.jeffm.io (Postfix, from userid 1000) id 418498149E; Tue, 25 Jul 2017 16:51:40 -0400 (EDT) From: jeffm@suse.com To: linux-btrfs@vger.kernel.org Cc: Jeff Mahoney Subject: [PATCH 5/7] btrfs-progs: backref: add list_first_pref helper Date: Tue, 25 Jul 2017 16:51:36 -0400 Message-Id: <20170725205138.28376-5-jeffm@suse.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170725205138.28376-1-jeffm@suse.com> References: <20170725205138.28376-1-jeffm@suse.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: Jeff Mahoney --- backref.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/backref.c b/backref.c index ac1b506..be3376a 100644 --- a/backref.c +++ b/backref.c @@ -130,6 +130,11 @@ struct __prelim_ref { u64 wanted_disk_byte; }; +static struct __prelim_ref *list_first_pref(struct list_head *head) +{ + return list_first_entry(head, struct __prelim_ref, list); +} + struct pref_state { struct list_head pending; }; @@ -804,8 +809,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, __merge_refs(&prefstate, 2); while (!list_empty(&prefstate.pending)) { - ref = list_first_entry(&prefstate.pending, - struct __prelim_ref, list); + ref = list_first_pref(&prefstate.pending); WARN_ON(ref->count < 0); if (roots && ref->count && ref->root_id && ref->parent == 0) { /* no parent == root of tree */ @@ -857,8 +861,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, out: btrfs_free_path(path); while (!list_empty(&prefstate.pending)) { - ref = list_first_entry(&prefstate.pending, - struct __prelim_ref, list); + ref = list_first_pref(&prefstate.pending); list_del(&ref->list); kfree(ref); }