Received: by 10.223.185.111 with SMTP id b44csp1654970wrg; Sat, 10 Mar 2018 10:43:34 -0800 (PST) X-Google-Smtp-Source: AG47ELsOxnOe2rn5fIsBA8fkS4iM1ZdoQdYQ5g6AnYEqdfIMg/hCCYL7uwcLlY40kTaupq1Uduo4 X-Received: by 2002:a17:902:7c03:: with SMTP id x3-v6mr2805039pll.94.1520707414655; Sat, 10 Mar 2018 10:43:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520707414; cv=none; d=google.com; s=arc-20160816; b=Yb6b3Y7gHcpVoLNXAl+r+8zCzRRuIb0AkR9UAGbnYGEsJsiIkkVphCpVUBrSUX6kwS krq/uvSOyaYs9axL/9n2/3zoPEghfVvNyWBcSQLpxgnwh2w9mIP/q1UPcIv+VWd9fymn Mn58q5Avq4HBVnFHuzeFBCec/jEqz6iweZr3iji6/cvHM8mcnjYke3kQnUb1UyoKPyef qNWR9SypZkySUesXGcJFu5ZiJFivPs1vbT3Ij7I8DnJW12t7b8ANd+hdijK0AoDJLG5x 7c5F5VDzWp+fAI1ZAoOi+Die8t2XnK806beVmVWAiO7JyiginBGW21KnD9R+W3PChMUK fuyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=N4I4FDphrvsBFYH/U3rzATsJ+y9akC5r0wxDpglx8ek=; b=UYXq9o+srDe/jZU6x2daPWtggrlzJPEovx+vJPc7xd7dr4PcljXYJo7z1FUX8VygbA Y2W+Su0sb9HD3X/Z6WZ/jVDPhjpPvlHvfYZ5xawdqcRhNtqazC+61lTfDv+hpPbgKjWe BXOnxjc62HUNyRDoGI8nnc6yNWm8ehK74TggD7PTm1reA8zl2R9y5vfDZui9PzWdsXnC QBA7bmZUog8kIvIN+QcrwgXhWlDpusV8UCuKKsc5IBSrLItdbF7KHaFOfMH8Qd/h5pHr SSgmg3d2zLkSLFEP1xPADBWt3pBFXQxwSKsdtTUw7GT8G/YPVoySeJpW1yQkbflkoeBF jBPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=OyXxnHu8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 18si3032734pfj.366.2018.03.10.10.43.20; Sat, 10 Mar 2018 10:43:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=OyXxnHu8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932491AbeCJSmb (ORCPT + 99 others); Sat, 10 Mar 2018 13:42:31 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:39883 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932269AbeCJSUd (ORCPT ); Sat, 10 Mar 2018 13:20:33 -0500 Received: by mail-pl0-f68.google.com with SMTP id s13-v6so7022829plq.6 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=hWQpl8aATAtjwt9Hvf2ljbI44rS11P1kXUoYZBFnqJs3EEdtojwzX1H6X9xoR/JX68 2miBnypYmoh0Yy4SfrtD9Et/4Olvzby/ZY2uJA/x9zg8q8eIpiNni75iNVupJvCkCVOT xCqs5eArJ+Zemygz+7cCfqfL8aD+b9Su10TBJ5ks1k7721VTlnXMiubPercbccodUv2j MTjG8qXhq/v2HbhmVWp2RFWGuzw8qa04F9NSZ9B5myCy8kVuORaTqTpwwvAJCt+p4oQe HwoSbfwZghKEjnYWh4y2O3A+aSL62hxSfIjIfgTab5BdGVxgY2kfeEptUJBgPQetrRI4 bopw== X-Gm-Message-State: AElRT7H+w669LEqrgSHUsyEijANvlXk45EhBFhnRxlyXDnuBFOHnwBnS IQVdWSbu4gQi4ObMWez8detHEA== 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 Cc: dan.j.williams@intel.com, andy.rudoff@intel.com, coughlan@redhat.com, swanson@cs.ucsd.edu, david@fromorbit.com, jack@suse.com, swhiteho@redhat.com, miklos@szeredi.hu, andiry.xu@gmail.com, Andiry Xu 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.7.4