Received: by 10.213.65.16 with SMTP id m16csp48323imf; Sun, 11 Mar 2018 14:32:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELvJGziwXOs+0nOC+mlqXezhWM0QftTLZxxu8qldSNP20AsZggl+agSKiEoEkFFFZmffEbcT X-Received: by 10.98.100.69 with SMTP id y66mr5796579pfb.111.1520803959187; Sun, 11 Mar 2018 14:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520803959; cv=none; d=google.com; s=arc-20160816; b=AM1MrXarwJhZD6RJq47jayhi/MT3BHD28wHTZeP6hot22BXlnNzUEcuSvTuJgErUoA ZW31InSM6DCuQFME0hEtRtM2THUWKTG2ULAwgOkr+nIjmyroxNIbdMj3pDo5A5pwNlOR +GF1zorbiOt/DO3fHo+7ZBbUf9N332/N7qPAxo5alkBfdViaaUDL3f+TgiGFpfNEi1aY TY5ZXSRWcrFyo82p2f5yJsf+7DqWsjgODNd2LDonDvgEKBqKdZg1acNMiJXM9sjqbhju 2SWBiJ61zKILVAdQ1OU6jAH7p3gS4IKjD1LrxOBli9rsvwTggbghDKcb/4MzpsmZ0wcZ gVXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=gUGtgh9fNy6oPp7RTqKUHnHef/+527GFZriWU4Y534E=; b=MJ+zlEeIfZ6NaXX1VOto6N9cvfIwW5O3tl5Kn1rvySpXmpzJSVaU+DB8BBEi5d/8Z0 tc8/OkoRLDltnz3jDHP7zTUj/Dl/9XoyLDsJjnOsQS7DhBa3UufpbjBUmnQiYT0VIKxD 93i3Htk8SX7FFR9wwvSJ7CIB9W/bK2KlJRx0AP0jfhwQ1qpIEEBtqoVlpOeCfCKNbEz8 jB7CrSc+JFMTmkvTKqakcab5AeQhZxlB5KVgfDkXXeq4KE2gC49FVmQom5m2JrAtdJQs tCj0/zMwboDJq839hDgbIvgaxpBxjwL8fI/fvjahVQ84yEyRup0qDSrkWmzEAc0OPuNd piyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=Q8/0k3y7; 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 l3-v6si4874884pld.519.2018.03.11.14.32.25; Sun, 11 Mar 2018 14:32:39 -0700 (PDT) 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=Q8/0k3y7; 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 S932479AbeCKVbS (ORCPT + 99 others); Sun, 11 Mar 2018 17:31:18 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:37557 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932453AbeCKVbQ (ORCPT ); Sun, 11 Mar 2018 17:31:16 -0400 Received: by mail-io0-f196.google.com with SMTP id d71so9163170iog.4 for ; Sun, 11 Mar 2018 14:31:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eng.ucsd.edu; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=gUGtgh9fNy6oPp7RTqKUHnHef/+527GFZriWU4Y534E=; b=Q8/0k3y7lartD3ylppkCOlbdypAzPcoPii8Eb3kH1ovTnKJMoqRz1GR0mc3RQv/SGQ 1AS8xAPm+CHJ+wbihIW1O0dHzFFM/uE7Nvll7B5vG4fN1jxH1ldizGFHZRzzFOBF+3JR nzrmC/l+yo0U7ux/uXs/P4BkKT68owb0eYAmw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=gUGtgh9fNy6oPp7RTqKUHnHef/+527GFZriWU4Y534E=; b=ddJvHFgZuw2eUIqCKqDRScySSMSNSFSkkPudbZF6I3fjA2UZnvaMpdU7+R3zPxDexY LF1HWPeeAOdZqW9jRTDld5gCjmsQOb0vsYQmDqqdOo6m1VJHY5XY9lDpDen4ViEhu3fz IVgMwIr6BvSf2fH+Ks378PbkPmBm9fQFtTKWJ4TUXKgWa68dtfOgJFO81MweL8l4j03j HNoRk1kxflGeGtIaVclpryNya/3wB4OfPtW+mizcHqktJc0w6zpsWEVI9Qg6XN2H2NiZ ly0BWVUQMbabh2F5lUX5/RGaP9Os7ZP+4pkqzAhtHVGbKY/B5p44SmefwU3RURDqxmIw 6c3w== X-Gm-Message-State: AElRT7GZYXsa47lCk79GyWQsEippwP2Zgn8UHHoGoLmdECnsjmN4SB9f mCiYq2hpVORva30A/DdPaz+oI2XuM64kbN0nkJhCIQ== X-Received: by 10.107.55.133 with SMTP id e127mr6246375ioa.138.1520803875922; Sun, 11 Mar 2018 14:31:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.195.72 with HTTP; Sun, 11 Mar 2018 14:31:15 -0700 (PDT) In-Reply-To: <73dae166-2e71-7fc9-7985-89cc44b38bf6@gmail.com> References: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> <1520705944-6723-15-git-send-email-jix024@eng.ucsd.edu> <73dae166-2e71-7fc9-7985-89cc44b38bf6@gmail.com> From: Andiry Xu Date: Sun, 11 Mar 2018 14:31:15 -0700 Message-ID: Subject: Re: [RFC v2 14/83] Add range node kmem cache. To: Nikolay Borisov Cc: Linux FS Devel , linux-kernel@vger.kernel.org, "linux-nvdimm@lists.01.org" , Dan Williams , "Rudoff, Andy" , coughlan@redhat.com, Steven Swanson , Dave Chinner , jack@suse.com, swhiteho@redhat.com, miklos@szeredi.hu, Jian Xu , Andiry Xu Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 11, 2018 at 4:55 AM, Nikolay Borisov wrote: > > > On 10.03.2018 20:17, Andiry Xu wrote: >> 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 *) > nit: needless cast Thanks. Will fix. Andiry >> + 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 >>