From patchwork Sat Mar 10 18:17:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273835 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 10F91601A0 for ; Sat, 10 Mar 2018 18:20:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F349428BAE for ; Sat, 10 Mar 2018 18:20:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E82CC296E5; Sat, 10 Mar 2018 18:20:36 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9C30428BAE for ; Sat, 10 Mar 2018 18:20:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BED482258AF13; Sat, 10 Mar 2018 10:14:16 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 813502258AEF8 for ; Sat, 10 Mar 2018 10:14:14 -0800 (PST) Received: by mail-pl0-x244.google.com with SMTP id m22-v6so7032124pls.5 for ; Sat, 10 Mar 2018 10:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eng.ucsd.edu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=N4I4FDphrvsBFYH/U3rzATsJ+y9akC5r0wxDpglx8ek=; b=OyXxnHu8/4PNXS22n08pEx1k97qAKOUvXbKEcIvffbVW+0W/xhOeeCJsiePinVXsUj +1VuzoaHYje8E53j8BRx6z47w/8SK4rBQzsf2dQJf7y37dhjxjrGNsZX8ara60z6w4/t c3tTr1thsagNTYZ73SPtmoT14oAlto9o2L+1E= 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=N4I4FDphrvsBFYH/U3rzATsJ+y9akC5r0wxDpglx8ek=; b=mJ5NVY14jatWQ60ulNorHL6c3i6a8TLy1rkAzcMyIsj3QSB3F2+/0AfVhWMgWbZkGr Ui2Q5B78DuHx9aI39cOysv17jVymU+Hd5KlFwnrs8W2zIbQwKjJ/uLZENccFGPM+MyK0 dWcQbvUtxjoKiHNJkC0mBUBTLYkwv+CsIJ6MtCvn5NoeW3j61EThlST1+egBng1XrVWB pqSD1Vh7kI8hHw1OdJlgywW24DroF9LoMyUNssnGj6JQbn7vqyo+yqEeTl4RZ45uFmXS ID4lTc0Bh8jnYZpkIYL0ImjTAeXOiWWPUfSruhC9dZN8uA/63l8whVJB5e3yv0dVHqcX gg7Q== X-Gm-Message-State: AElRT7FBQ85WKGcDXhe+/WMg592kMZYJ7DGlc29kuPZdp3CQh0TC307X +A2DgrV9Qs5JKrgq3Qyf61nAvQ== X-Google-Smtp-Source: AG47ELsx5P1VO16Fj5Sny1ZkiHnPZQeFqNDbaHJWUAmCyGaOfKQjyb8hDlMXMf0ISjwgQlnVWGKKTQ== X-Received: by 2002:a17:902:2006:: with SMTP id n6-v6mr2734413pla.149.1520706032921; Sat, 10 Mar 2018 10:20:32 -0800 (PST) Received: from brienza-desktop.8.8.4.4 (andxu.ucsd.edu. [132.239.17.134]) by smtp.gmail.com with ESMTPSA id h80sm9210167pfj.181.2018.03.10.10.20.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:32 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 14/83] Add range node kmem cache. Date: Sat, 10 Mar 2018 10:17:55 -0800 Message-Id: <1520705944-6723-15-git-send-email-jix024@eng.ucsd.edu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> References: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: coughlan@redhat.com, miklos@szeredi.hu, Andiry Xu , david@fromorbit.com, jack@suse.com, swanson@cs.ucsd.edu, swhiteho@redhat.com, andiry.xu@gmail.com MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Andiry Xu Range node specifies a range of [start, end]. and is managed by a red-black tree. NOVA uses range node to manage NVM allocator and inodes being used. Signed-off-by: Andiry Xu --- fs/nova/nova.h | 8 ++++++++ fs/nova/super.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- fs/nova/super.h | 2 ++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/fs/nova/nova.h b/fs/nova/nova.h index ba7ffca..e0e85fb 100644 --- a/fs/nova/nova.h +++ b/fs/nova/nova.h @@ -301,6 +301,14 @@ static inline u64 nova_get_epoch_id(struct super_block *sb) } #include "inode.h" + +/* A node in the RB tree representing a range of pages */ +struct nova_range_node { + struct rb_node node; + unsigned long range_low; + unsigned long range_high; +}; + #include "bbuild.h" /* ====================================================== */ diff --git a/fs/nova/super.c b/fs/nova/super.c index f41cc04..aec1cd3 100644 --- a/fs/nova/super.c +++ b/fs/nova/super.c @@ -52,6 +52,7 @@ MODULE_PARM_DESC(nova_dbgmask, "Control debugging output"); static struct super_operations nova_sops; static struct kmem_cache *nova_inode_cachep; +static struct kmem_cache *nova_range_node_cachep; /* FIXME: should the following variable be one per NOVA instance? */ @@ -686,6 +687,20 @@ static void nova_put_super(struct super_block *sb) sb->s_fs_info = NULL; } +inline void nova_free_range_node(struct nova_range_node *node) +{ + kmem_cache_free(nova_range_node_cachep, node); +} + +inline struct nova_range_node *nova_alloc_range_node(struct super_block *sb) +{ + struct nova_range_node *p; + + p = (struct nova_range_node *) + kmem_cache_zalloc(nova_range_node_cachep, GFP_NOFS); + return p; +} + static struct inode *nova_alloc_inode(struct super_block *sb) { struct nova_inode_info *vi; @@ -719,6 +734,17 @@ static void init_once(void *foo) inode_init_once(&vi->vfs_inode); } +static int __init init_rangenode_cache(void) +{ + nova_range_node_cachep = kmem_cache_create("nova_range_node_cache", + sizeof(struct nova_range_node), + 0, (SLAB_RECLAIM_ACCOUNT | + SLAB_MEM_SPREAD), NULL); + if (nova_range_node_cachep == NULL) + return -ENOMEM; + return 0; +} + static int __init init_inodecache(void) { nova_inode_cachep = kmem_cache_create("nova_inode_cache", @@ -740,6 +766,11 @@ static void destroy_inodecache(void) kmem_cache_destroy(nova_inode_cachep); } +static void destroy_rangenode_cache(void) +{ + kmem_cache_destroy(nova_range_node_cachep); +} + /* * the super block writes are all done "on the fly", so the @@ -781,20 +812,27 @@ static int __init init_nova_fs(void) nova_info("Arch new instructions support: CLWB %s\n", support_clwb ? "YES" : "NO"); - rc = init_inodecache(); + rc = init_rangenode_cache(); if (rc) goto out; - rc = register_filesystem(&nova_fs_type); + rc = init_inodecache(); if (rc) goto out1; + rc = register_filesystem(&nova_fs_type); + if (rc) + goto out2; + out: NOVA_END_TIMING(init_t, init_time); return rc; -out1: +out2: destroy_inodecache(); + +out1: + destroy_rangenode_cache(); goto out; } @@ -802,6 +840,7 @@ static void __exit exit_nova_fs(void) { unregister_filesystem(&nova_fs_type); destroy_inodecache(); + destroy_rangenode_cache(); } MODULE_AUTHOR("Andiry Xu "); diff --git a/fs/nova/super.h b/fs/nova/super.h index cb53908..b478080 100644 --- a/fs/nova/super.h +++ b/fs/nova/super.h @@ -145,5 +145,7 @@ static inline struct nova_super_block *nova_get_super(struct super_block *sb) } extern void nova_error_mng(struct super_block *sb, const char *fmt, ...); +extern struct nova_range_node *nova_alloc_range_node(struct super_block *sb); +extern void nova_free_range_node(struct nova_range_node *node); #endif