From patchwork Tue Jun 20 16:06:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edmund Nadolski X-Patchwork-Id: 9799893 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 C920460329 for ; Tue, 20 Jun 2017 16:06:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9A57284ED for ; Tue, 20 Jun 2017 16:06:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADF36284BF; Tue, 20 Jun 2017 16:06:14 +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 313E728589 for ; Tue, 20 Jun 2017 16:06:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751639AbdFTQGH (ORCPT ); Tue, 20 Jun 2017 12:06:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:60444 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751122AbdFTQGG (ORCPT ); Tue, 20 Jun 2017 12:06:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 524FDAAC5 for ; Tue, 20 Jun 2017 16:06:05 +0000 (UTC) From: Edmund Nadolski To: enadolski@suse.com, linux-btrfs@vger.kernel.org Subject: [PATCH 09/13] btrfs: add a node counter to each of the rbtrees Date: Tue, 20 Jun 2017 10:06:49 -0600 Message-Id: <20170620160653.19907-10-enadolski@suse.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170620160653.19907-1-enadolski@suse.com> References: <20170620160653.19907-1-enadolski@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 This patch adds counters to each of the rbtrees so that we can tell how large they are growing for a given workload. These counters will be exported by tracepoints in the next patch. Signed-off-by: Jeff Mahoney --- fs/btrfs/backref.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index daae7b6..4018393 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -141,9 +141,10 @@ struct prelim_ref { struct preftree { struct rb_root root; + unsigned int count; }; -#define PREFTREE_INIT { .root = RB_ROOT } +#define PREFTREE_INIT { .root = RB_ROOT, .count = 0 } struct preftrees { struct preftree direct; /* BTRFS_SHARED_[DATA|BLOCK]_REF_KEY */ @@ -252,6 +253,7 @@ static void prelim_ref_insert(struct preftree *preftree, } } + preftree->count++; rb_link_node(&newref->rbnode, parent, p); rb_insert_color(&newref->rbnode, root); } @@ -269,6 +271,7 @@ static void prelim_release(struct preftree *preftree) release_pref(ref); preftree->root = RB_ROOT; + preftree->count = 0; } /* @@ -604,6 +607,7 @@ static int resolve_indirect_refs(struct btrfs_fs_info *fs_info, } rb_erase(&ref->rbnode, &preftrees->indirect.root); + preftrees->indirect.count--; if (ref->count == 0) { release_pref(ref);