Received: by 10.223.185.111 with SMTP id b44csp1652467wrg; Sat, 10 Mar 2018 10:39:29 -0800 (PST) X-Google-Smtp-Source: AG47ELtPNexI98mksqNNE+oULzXON9FQrnXiw/j9PP7P4Df9bODi3M9pNAz8i+pqt77g4xlC03cE X-Received: by 10.101.88.76 with SMTP id s12mr2181658pgr.385.1520707169284; Sat, 10 Mar 2018 10:39:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520707169; cv=none; d=google.com; s=arc-20160816; b=Eb/vutgIwSr5niW8so7hCs9h/irX1Z/6Usk/zestcnATvKkWvzxOlfa+5SwWICA4c5 sg2CVDZoX26lGUGWy51OzGmavXdPm3i/x6yrNj/F5owYGfkVRm07NAzUYzSp9RoGU6qd k00TqktNvgMvMhl7QE8QcB1/dHMRpni3q2MeKVlGT+c1M0QvSUp57S4L8xaH5hckM3EO 4DzIfHL9t6ldZ8FU0r+cI7vQ3jKY1vnuXJrquNkgkR92GtopiqB114iAroqpE0NrN+zE Pv2qpm4+g6qjGv99NCo1HEuZt9Shr3Gmckpxfy0MkuhEEJPdbkdBY32mdUNAk2jd5CCA sqqw== 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=Lf8vq2V/gLgFJS/SPMwk5CqJYL12uOwRSuqkZ4H+EDg=; b=nppUw2q5Q9SxKQW9wgAI+NJLhznNFgHUnw5ppLMgHGdARz05h9xLO968jKPL8Jf12r 7w61et6/qPSUZBPuYIgRTbVUBXcnGhJNCsjHzS6VVp4l1Row6UESV4Af+IC/emUp2sjw AT5ZPXnX98nf65zsU8rR2Npvjd23d4/l6gzoEwFx8x9k+xnHXdNXwIvHm1cjO61mJDpB BvTCgVgwpg0bjGoNlD45w9u3/3JJkd1d5U6abLe0Yh3JCe/taD77zzR9xCTuO1d7jb0s xKpv0/4JnmBzKaAwun//hXe6AI9M4FhqjY2tc+LlIg5IWEOMJzpPgPp6Y/EvRVybHAO4 q2LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=PuR1iaSW; 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 r9si3025020pfh.311.2018.03.10.10.39.15; Sat, 10 Mar 2018 10:39:29 -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=PuR1iaSW; 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 S932414AbeCJSUu (ORCPT + 99 others); Sat, 10 Mar 2018 13:20:50 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:46212 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932399AbeCJSUq (ORCPT ); Sat, 10 Mar 2018 13:20:46 -0500 Received: by mail-pl0-f65.google.com with SMTP id y8-v6so7003303pll.13 for ; Sat, 10 Mar 2018 10:20:45 -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=Lf8vq2V/gLgFJS/SPMwk5CqJYL12uOwRSuqkZ4H+EDg=; b=PuR1iaSWsBofplW0XBocEgz6uYy2HtMhUvdq2y4S+cQw/1xxMzLN6trkOnGQgUYcHL gCCBPTP2fJ2njfVqBzzkrA3o6PVOtEJcp3CYs4I6l3sa6/cLYzKowwvy8XTDLFAbJMpz D+AuSTDul5yFLLDCKS3y/YwdAz9mkSeCFrz4c= 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=Lf8vq2V/gLgFJS/SPMwk5CqJYL12uOwRSuqkZ4H+EDg=; b=Vi5ZkbqG62S4qZaA1kD0QxoAk1r5F86lDbydB4pQsEcTWNBTwinJB0aq21T6sJuKw7 c2SlxG1Qxw17SZ+Ce+8b7F000ydJ7XBeqhc/raeHvVMuopv0VBLuiGs/Iyup5W7+HJUs KtnqjunTvfbVMoLcJZC1xXIJ9W6e+DDLniuuIkv/bJN81s3B8hHcaWrcOqs6GMaG54c/ sowe8MV8yzlBdccsnw6MRmqHWsvIPTJN4tSgqmlCGwTeOgeGS7tAFZPiMJTZRyGlVHMC XwWqq+mxFT21rcVry+WbB9uBMWKbfznFNPehy1INqQf5QZKIepej7QiiFKAVy5XcKf/i lucw== X-Gm-Message-State: AElRT7GYiS0gXn0RhNDKGm3AtoVFTF64cyBD2BEeO2Wdgnj7xICRXptG u2N8VCNa/Wa/Dhh/oXZvIX1LTA== X-Received: by 2002:a17:902:6ac2:: with SMTP id i2-v6mr2693177plt.368.1520706045363; Sat, 10 Mar 2018 10:20:45 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:44 -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 24/83] Initialize and allocate inode table. Date: Sat, 10 Mar 2018 10:18:05 -0800 Message-Id: <1520705944-6723-25-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 Inode table is a singly linked list of 2MB pages. Each CPU has one inode table with initial size 2MB. The inode table addresses are stored in the INODE_TABLE_START of the pmem range. Signed-off-by: Andiry Xu --- fs/nova/inode.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nova/inode.h | 26 ++++++++++++++++++++++++++ fs/nova/super.c | 3 +++ 3 files changed, 84 insertions(+) diff --git a/fs/nova/inode.c b/fs/nova/inode.c index f7d6410..42816ff 100644 --- a/fs/nova/inode.c +++ b/fs/nova/inode.c @@ -29,6 +29,61 @@ unsigned int blk_type_to_shift[NOVA_BLOCK_TYPE_MAX] = {12, 21, 30}; uint32_t blk_type_to_size[NOVA_BLOCK_TYPE_MAX] = {0x1000, 0x200000, 0x40000000}; +static int nova_alloc_inode_table(struct super_block *sb, + struct nova_inode_info_header *sih) +{ + struct nova_sb_info *sbi = NOVA_SB(sb); + struct inode_table *inode_table; + unsigned long blocknr; + u64 block; + int allocated; + int i; + + for (i = 0; i < sbi->cpus; i++) { + inode_table = nova_get_inode_table(sb, i); + if (!inode_table) + return -EINVAL; + + allocated = nova_new_log_blocks(sb, sih, &blocknr, 1, + ALLOC_INIT_ZERO, i, ALLOC_FROM_HEAD); + + nova_dbgv("%s: allocate log @ 0x%lx\n", __func__, + blocknr); + if (allocated != 1 || blocknr == 0) + return -ENOSPC; + + block = nova_get_block_off(sb, blocknr, NOVA_BLOCK_TYPE_2M); + inode_table->log_head = block; + nova_flush_buffer(inode_table, CACHELINE_SIZE, 0); + } + + return 0; +} + +int nova_init_inode_table(struct super_block *sb) +{ + struct nova_inode *pi = nova_get_inode_by_ino(sb, NOVA_INODETABLE_INO); + struct nova_inode_info_header sih; + int ret = 0; + + pi->i_mode = 0; + pi->i_uid = 0; + pi->i_gid = 0; + pi->i_links_count = cpu_to_le16(1); + pi->i_flags = 0; + pi->nova_ino = NOVA_INODETABLE_INO; + + pi->i_blk_type = NOVA_BLOCK_TYPE_2M; + + sih.ino = NOVA_INODETABLE_INO; + sih.i_blk_type = NOVA_BLOCK_TYPE_2M; + + ret = nova_alloc_inode_table(sb, &sih); + + PERSISTENT_BARRIER(); + return ret; +} + void nova_set_inode_flags(struct inode *inode, struct nova_inode *pi, unsigned int flags) { diff --git a/fs/nova/inode.h b/fs/nova/inode.h index 0594ef3..a88f0a2 100644 --- a/fs/nova/inode.h +++ b/fs/nova/inode.h @@ -60,6 +60,13 @@ struct nova_inode { } __attribute((__packed__)); /* + * Inode table. It's a linked list of pages. + */ +struct inode_table { + __le64 log_head; +}; + +/* * NOVA-specific inode state kept in DRAM */ struct nova_inode_info_header { @@ -136,6 +143,22 @@ static inline void nova_update_tail(struct nova_inode *pi, u64 new_tail) NOVA_END_TIMING(update_tail_t, update_time); } +static inline +struct inode_table *nova_get_inode_table(struct super_block *sb, int cpu) +{ + struct nova_sb_info *sbi = NOVA_SB(sb); + int table_start; + + if (cpu >= sbi->cpus) + return NULL; + + table_start = INODE_TABLE_START; + + return (struct inode_table *)((char *)nova_get_block(sb, + NOVA_DEF_BLOCK_SIZE_4K * table_start) + + cpu * CACHELINE_SIZE); +} + static inline unsigned int nova_inode_blk_shift(struct nova_inode_info_header *sih) { @@ -197,7 +220,10 @@ static inline int nova_persist_inode(struct nova_inode *pi) return 0; } + +int nova_init_inode_table(struct super_block *sb); int nova_get_inode_address(struct super_block *sb, u64 ino, u64 *pi_addr, int extendable); struct inode *nova_iget(struct super_block *sb, unsigned long ino); + #endif diff --git a/fs/nova/super.c b/fs/nova/super.c index 7ee3f66..32fe29b 100644 --- a/fs/nova/super.c +++ b/fs/nova/super.c @@ -378,6 +378,9 @@ static struct nova_inode *nova_init(struct super_block *sb, nova_init_blockmap(sb, 0); + if (nova_init_inode_table(sb) < 0) + return ERR_PTR(-EINVAL); + sbi->nova_sb->s_size = cpu_to_le64(size); sbi->nova_sb->s_blocksize = cpu_to_le32(blocksize); sbi->nova_sb->s_magic = cpu_to_le32(NOVA_SUPER_MAGIC); -- 2.7.4