Received: by 10.223.185.111 with SMTP id b44csp1652499wrg; Sat, 10 Mar 2018 10:39:32 -0800 (PST) X-Google-Smtp-Source: AG47ELsp98cDZEisJuxUlqn/KAcSGyArLoYr3L3XjKsBWT6JIa6zNtQJvjMQjp/AShyESGq7v2Dd X-Received: by 10.99.54.74 with SMTP id d71mr2209941pga.86.1520707172068; Sat, 10 Mar 2018 10:39:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520707172; cv=none; d=google.com; s=arc-20160816; b=Wzr8ln4jnPMeQ2IMTT5IsZXO2vMP/jluUpOY2sueJX6F7x+lUxeLBdBUIeMjFxrw+P TxjOhwZaDJNTOVMZFpnLnGuQJrMVRHmGfiKytkE7LIkogsqBf8YYKNRk1Wvdmu+3vsQU FSFD2IGfpnRB39KoUxRMRqaY5IHr9QZZ3fT3umUFMLqHGQj+M0RNExGbDBh3GmEySQDo oqRWKyACXFlXdC3rncSknnrNZFgmf+zZS4f6n1C5O4flQJy2UTqBRu07/+D2xH5mpm4I hHBa8w1SXhodm4sy5vevDqWvrOH7v4LROMPVOIm8ZT2c1eW6wwFeIxSCIG+mK3MA6nXL Nwcw== 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=ANvV4FGsSahsH/F08alqlQHRFiyb2r1ho/EiFwaMnwg=; b=bfhh2Irehu5J5CyZzy+WWaA6dNEktEUB9b4rsV+6bOLt7DM4jf7RKzEpr4JrIIUCVA 65arhuTYecFWKHH6TD1RZk66Dr7+6fPvmb22uDUKCWASs/fcUDtdcKJ32oq+M/JeP6Yd 2E2W1awwHMj6lV6/vbXXArd+dgEs/bfP1cmciCPBBz9qj4UnIx3dhVLImCQzF2ZZySuH 1JRKTe1TK/1RcDMkcH6Ub3BqwH51h0ya/Gqi9qnz2dcDfoOVDJSrm8LuH1uwwGL7SBcA wyYeQWb9np+x1wUoqVpsLQEkQIxMN/dh+u7U89HidiLei6Gkk+z69xjV12YfOMvcsioh ziMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=NjFJXa2J; 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 q11si2604495pgv.138.2018.03.10.10.39.17; Sat, 10 Mar 2018 10:39:32 -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=NjFJXa2J; 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 S932440AbeCJSUw (ORCPT + 99 others); Sat, 10 Mar 2018 13:20:52 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:35548 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932374AbeCJSUr (ORCPT ); Sat, 10 Mar 2018 13:20:47 -0500 Received: by mail-pl0-f66.google.com with SMTP id w22-v6so7025662pll.2 for ; Sat, 10 Mar 2018 10:20:47 -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=ANvV4FGsSahsH/F08alqlQHRFiyb2r1ho/EiFwaMnwg=; b=NjFJXa2J7Z8HUteylVEaRtJgEsA7iR7bp8BhjAqcHZ9pXk/SeorcD5oThPPs6luKw6 ZBMd8OVUssuUBohN6vPe32SeXQ91/TPFMYTCGlMAjzswNQaWiKtKbL0CzBrXdbqPNlNH gHNKZW1tUA/VDB7a4co1m9W6VwgNx6IZQLwbc= 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=ANvV4FGsSahsH/F08alqlQHRFiyb2r1ho/EiFwaMnwg=; b=mVHTZ2iHrir3JD2j0O7aEMs5hxEP+6UgcJJWvE17DMVDeACK87LlZeOd+6k5BDXzob Gcg9BEiEMIVyo2IAddjrFlIzs/tKbZkNBPUpihE9qIa49bHGcTvD/8Dn1iTgIQeqJybX fGPNpLlulxQFEv5p3XsxX6R161bkgupZGNr8auTELErAUP/Fm1BjwHVGIMZSbo+FfahG pfp2FJDN768nJfHPZHbCm+ZLqi4lGF8due7tDK6VuZzfwgzQXx3dQeEhw/lh14fols6M odYAjtdC9uWzNmB9Zh8jMqUW9k34S0BqS8gqHkhcY5cN9MgU/cSBgo2Q9pX+lLl+gfDt 6T4w== X-Gm-Message-State: AElRT7G94v+65GSU4BZOfB9wpRtv6p9SSD6Dm81uN97mJ5zd0ZKod8ow CQMcKMtP6ZYGTAyYcnOu0WCG7A== X-Received: by 2002:a17:902:365:: with SMTP id 92-v6mr2794916pld.127.1520706046686; Sat, 10 Mar 2018 10:20:46 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:46 -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 25/83] Support get normal inode address and inode table extentsion. Date: Sat, 10 Mar 2018 10:18:06 -0800 Message-Id: <1520705944-6723-26-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 Inodes are assigned to per-CPU inode tables in a round-robin way: If there are four cores, then CPU 0's inode table contains inode 0, inode 4, inode 8, ... CPU 1's inode table contains inode 1, inode 5, inode 9, ... CPU 2's inode table contains inode 2, inode 6, inode 10, ... CPU 3's inode table contains inode 3, inode 7, inode 11, ... So given an inode number, the inode table and inode position can be easily calculated. If NOVA runs out of 2MB inode table size, it will allocate a new 2MB log page and links it to the tail of the previous inode table. Signed-off-by: Andiry Xu --- fs/nova/inode.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/fs/nova/inode.c b/fs/nova/inode.c index 42816ff..4e2842d 100644 --- a/fs/nova/inode.c +++ b/fs/nova/inode.c @@ -167,18 +167,81 @@ static int nova_read_inode(struct super_block *sb, struct inode *inode, return ret; } -/* Get the address in PMEM of an inode by inode number. Allocate additional +/* + * Get the address in PMEM of an inode by inode number. Allocate additional * block to store additional inodes if necessary. */ int nova_get_inode_address(struct super_block *sb, u64 ino, u64 *pi_addr, int extendable) { + struct nova_sb_info *sbi = NOVA_SB(sb); + struct nova_inode_info_header sih; + struct inode_table *inode_table; + unsigned int data_bits; + unsigned int num_inodes_bits; + u64 curr; + unsigned int superpage_count; + u64 internal_ino; + int cpuid; + int extended = 0; + unsigned int index; + unsigned int i = 0; + unsigned long blocknr; + unsigned long curr_addr; + int allocated; + if (ino < NOVA_NORMAL_INODE_START) { *pi_addr = nova_get_reserved_inode_addr(sb, ino); return 0; } - *pi_addr = 0; + sih.ino = NOVA_INODETABLE_INO; + sih.i_blk_type = NOVA_BLOCK_TYPE_2M; + data_bits = blk_type_to_shift[sih.i_blk_type]; + num_inodes_bits = data_bits - NOVA_INODE_BITS; + + cpuid = ino % sbi->cpus; + internal_ino = ino / sbi->cpus; + + inode_table = nova_get_inode_table(sb, cpuid); + superpage_count = internal_ino >> num_inodes_bits; + index = internal_ino & ((1 << num_inodes_bits) - 1); + + curr = inode_table->log_head; + if (curr == 0) + return -EINVAL; + + for (i = 0; i < superpage_count; i++) { + if (curr == 0) + return -EINVAL; + + curr_addr = (unsigned long)nova_get_block(sb, curr); + /* Next page pointer in the last 8 bytes of the superpage */ + curr_addr += nova_inode_blk_size(&sih) - 8; + curr = *(u64 *)(curr_addr); + + if (curr == 0) { + if (extendable == 0) + return -EINVAL; + + extended = 1; + + allocated = nova_new_log_blocks(sb, &sih, &blocknr, + 1, ALLOC_INIT_ZERO, cpuid, ALLOC_FROM_HEAD); + + if (allocated != 1) + return allocated; + + curr = nova_get_block_off(sb, blocknr, + NOVA_BLOCK_TYPE_2M); + *(u64 *)(curr_addr) = curr; + nova_flush_buffer((void *)curr_addr, + NOVA_INODE_SIZE, 1); + } + } + + *pi_addr = curr + index * NOVA_INODE_SIZE; + return 0; } -- 2.7.4