From patchwork Sat Mar 10 18:18:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273875 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 DAA4E602BD for ; Sat, 10 Mar 2018 18:20:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CABC228BAE for ; Sat, 10 Mar 2018 18:20:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF70529735; Sat, 10 Mar 2018 18:20:58 +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 6A09E28BAE for ; Sat, 10 Mar 2018 18:20:58 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2E77222603AEC; Sat, 10 Mar 2018 10:14:37 -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:c05::241; helo=mail-pg0-x241.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (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 1954622603AF4 for ; Sat, 10 Mar 2018 10:14:34 -0800 (PST) Received: by mail-pg0-x241.google.com with SMTP id x2so695762pgo.9 for ; Sat, 10 Mar 2018 10:20:52 -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=SNMr480tmOPPppm2CGirdConXeEMeLCpWbW9EPTdQ08=; b=PxAtzYz8VNcHpvN2kAeHatmhi/t09kH/LjRjARy/UE1+35agsW30KXbMc4nd2bAJfa cNYC0TKxCPgtfB6GdA433LkpBeDhzAk+siIVaKIwV16jGZ2vBE8G7HA9PUsklW7oD+ex yWJyXgzdQzEgoLHJGtuurWYRcXbxufsZRmx9s= 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=SNMr480tmOPPppm2CGirdConXeEMeLCpWbW9EPTdQ08=; b=L+7HTGsSvp1GXIR0RYHmKubKqhQmKoai7pKe18JGVQEKUG5B+OE0cMKC4TVYGlcx/2 ozczqknheSr7lJmemjW0V7XpqTSQ1VZinAw3612ipttOo8D+NYLIMsCZ/V8g87eQn2FN Od6JNvTcWjNK/i6mu3WcJMdLoUZecpDb7Id/1F4+5SUrkS12q+ByYAg2WekGVmXC515S GX0YdtBEIy4JHwZWJrAG8CgPbKmve9iO9xgJ3LpuRGe55IPbDy0i6cC32jeNvtmsxOL/ oJU78bbrU1yTcLJbJEN0rOm9cjSWD2FMtDLPEoDERevXRPqkjuqpvjK9gfEAd3IBjwYb n1bw== X-Gm-Message-State: AElRT7GvvyBirMhHcKEVVSpO4IzNGu1LXISNsrI1jQOFPvrCrgI1t0jg pS5eKE1NtErGojsSdtA/UANefA== X-Google-Smtp-Source: AG47ELsuAu7CNftMQr1Q+LKTqKOLt60OYaQ3O3bJpQNUIaYGkt53L+VSyIll5cvpQhbF+PuzEN7y5Q== X-Received: by 10.167.131.29 with SMTP id t29mr2704419pfm.116.1520706052563; Sat, 10 Mar 2018 10:20:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:52 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 30/83] New NOVA inode allocation. Date: Sat, 10 Mar 2018 10:18:11 -0800 Message-Id: <1520705944-6723-31-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 Allocate the new inode in a round-robin way. Extend the inode table if needed. Signed-off-by: Andiry Xu --- fs/nova/inode.c | 40 ++++++++++++++++++++++++++++++++++++++++ fs/nova/inode.h | 1 + 2 files changed, 41 insertions(+) diff --git a/fs/nova/inode.c b/fs/nova/inode.c index 29d172a..e4b8960 100644 --- a/fs/nova/inode.c +++ b/fs/nova/inode.c @@ -489,6 +489,46 @@ int nova_free_inuse_inode(struct super_block *sb, unsigned long ino) return ret; } +/* Returns 0 on failure */ +u64 nova_new_nova_inode(struct super_block *sb, u64 *pi_addr) +{ + struct nova_sb_info *sbi = NOVA_SB(sb); + struct inode_map *inode_map; + unsigned long free_ino = 0; + int map_id; + u64 ino = 0; + int ret; + timing_t new_inode_time; + + NOVA_START_TIMING(new_nova_inode_t, new_inode_time); + map_id = sbi->map_id; + sbi->map_id = (sbi->map_id + 1) % sbi->cpus; + + inode_map = &sbi->inode_maps[map_id]; + + mutex_lock(&inode_map->inode_table_mutex); + ret = nova_alloc_unused_inode(sb, map_id, &free_ino); + if (ret) { + nova_dbg("%s: alloc inode number failed %d\n", __func__, ret); + mutex_unlock(&inode_map->inode_table_mutex); + return 0; + } + + ret = nova_get_inode_address(sb, free_ino, pi_addr, 1); + if (ret) { + nova_dbg("%s: get inode address failed %d\n", __func__, ret); + mutex_unlock(&inode_map->inode_table_mutex); + return 0; + } + + mutex_unlock(&inode_map->inode_table_mutex); + + ino = free_ino; + + NOVA_END_TIMING(new_nova_inode_t, new_inode_time); + return ino; +} + int nova_write_inode(struct inode *inode, struct writeback_control *wbc) { /* write_inode should never be called because we always keep our inodes diff --git a/fs/nova/inode.h b/fs/nova/inode.h index f9f5c14..fc1876c 100644 --- a/fs/nova/inode.h +++ b/fs/nova/inode.h @@ -229,6 +229,7 @@ int nova_get_inode_address(struct super_block *sb, u64 ino, struct inode *nova_iget(struct super_block *sb, unsigned long ino); inline int nova_insert_inodetree(struct nova_sb_info *sbi, struct nova_range_node *new_node, int cpu); +u64 nova_new_nova_inode(struct super_block *sb, u64 *pi_addr); extern int nova_write_inode(struct inode *inode, struct writeback_control *wbc); extern void nova_dirty_inode(struct inode *inode, int flags);