Received: by 10.223.185.111 with SMTP id b44csp1652534wrg; Sat, 10 Mar 2018 10:39:36 -0800 (PST) X-Google-Smtp-Source: AG47ELskF4kKamIx8UzK+lqVVQ3LPuqSQ/K38L76kyoE18jOJXluydAWfzOEKL+RNoP2FGCw7kiL X-Received: by 10.101.97.139 with SMTP id c11mr2265356pgv.431.1520707176306; Sat, 10 Mar 2018 10:39:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520707176; cv=none; d=google.com; s=arc-20160816; b=DH2kz27zkrw8/6wBxSjmJ0zREMA/bCfFsW9X9faq/YF8cE4MlskwL4PC9NJ+xotfFf BObDaohgxDCoOdpIUKmMa+pYGGYBRQcDGwEJgfcYTTm1L90ELrul+CvWnsIEwJDS7trj QS2i7c2wbEk62WprXGFtePw0x4pOXq2brU6FY6NkGWTmpfO+17q5zqV6+D9cNsmXiwfg 8SKAAb84cDopoqESHs4eceD9azX4g31bMs2/SCjUCXoR9N5RY2tk4NqlyVun2lNlymuz Pw945zgRCNt5uhbmQLaLcATgmTsMBdhnhmH2ZuVhAu4lNdP6juMHvEirpCHVqk/fEC/d X1wQ== 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=Ll5e42Ci76gpjblQZyBEn0lhu0yfvHi+mP2g8HaLNuI=; b=qeTvYGLp/PdcYAp7ticqkLj2tzZdn7lGdLvqCRe8Vj+MyKWoulMvXRIyyPd44wD2nD WnOTtj1WZYW85foRXUfgZ6YAc0IwmZWEOCyDYM6Vu0kn6CgbCnv6f8OQs9aSNhiM9Phw 9AKajYi7Ck9JRAoYNTPNznuxB86ornExmXoa/gA3Ank56cGhKeRFcCrs0XfIWGEyqY6X adTTnH41WocW4pU/VkXOzXL8KzcYsURftU/OU6oqDwTi6iM0hUIxglQY0ygRAu6GfDx7 ln9jZxvpYAGp8LhLTK7ODDUXov/EDTtVQ5YUkb+LsYNOQspd96NKOCmRNoUkHpGCV8SU BDkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=Ze9YNXnc; 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 s20-v6si3079352plp.340.2018.03.10.10.39.21; Sat, 10 Mar 2018 10:39:36 -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=Ze9YNXnc; 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 S932406AbeCJSic (ORCPT + 99 others); Sat, 10 Mar 2018 13:38:32 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:43993 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751247AbeCJSUt (ORCPT ); Sat, 10 Mar 2018 13:20:49 -0500 Received: by mail-pg0-f66.google.com with SMTP id e9so4830762pgs.10 for ; Sat, 10 Mar 2018 10:20:49 -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=Ll5e42Ci76gpjblQZyBEn0lhu0yfvHi+mP2g8HaLNuI=; b=Ze9YNXncX6I/G9mZTKCB8ReJOiZpqTL0LHh9GbSx8htVS4Dh1VwppynH2PlNnwt5m9 sqNQ2jD4e2VllwyadTwHNXkQsE1NE4bWpT54mxHAyM5LIu7tfIT5YLagh9l/1zC5hegO KM8GdYkOJZrG5z7Htz2DH9G3k1b8/4WTGi25Y= 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=Ll5e42Ci76gpjblQZyBEn0lhu0yfvHi+mP2g8HaLNuI=; b=AIWdp4YB9JvJTnDRqaeULDdaCERwWx4G/PKB349+VmO2Ew8UjX6jHxgGK1X/x/9Bjs 2lloJXJo0ryoDumRNRjwJF8E6hO4rVCV43QVaenHOrxLNmtDE9hDNgFIrlpOEMv0HuvT NQWK/xgwrmCs98a0U/DSSxBKU0sjfPougjs04lbNsNgz2shHdiI5P3z/JwTRjvEQHdQd JC9SuB1mxnOrUsXimFTlNcqU7miahFLRcaCilp6AbWG9DiQChF2hTpQ7ydx6Me3tc+jo oW8E0ARbn/wEVPkz4N//OutCyjewbb2UMRgSoZr7ytZFKhugLA+VX3NrknnLX9j4uYWf caAA== X-Gm-Message-State: AElRT7FQnJ9PSmP+f6/tj1yzCdb0v77RbXk2Qfi4WVE8J+9gRgPCR6tF r2Ystokw/XYwmJc+xw0ofI1YWA== X-Received: by 10.98.131.4 with SMTP id h4mr2660852pfe.156.1520706049055; Sat, 10 Mar 2018 10:20:49 -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.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:48 -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 27/83] Save the inode inuse list to pmem upon umount Date: Sat, 10 Mar 2018 10:18:08 -0800 Message-Id: <1520705944-6723-28-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 Signed-off-by: Andiry Xu --- fs/nova/bbuild.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ fs/nova/bbuild.h | 1 + fs/nova/super.c | 1 + 3 files changed, 50 insertions(+) diff --git a/fs/nova/bbuild.c b/fs/nova/bbuild.c index 12a2f11..66053cb 100644 --- a/fs/nova/bbuild.c +++ b/fs/nova/bbuild.c @@ -116,6 +116,54 @@ static u64 nova_save_free_list_blocknodes(struct super_block *sb, int cpu, return temp_tail; } +void nova_save_inode_list_to_log(struct super_block *sb) +{ + struct nova_inode *pi = nova_get_inode_by_ino(sb, NOVA_INODELIST_INO); + struct nova_inode_info_header sih; + struct nova_sb_info *sbi = NOVA_SB(sb); + unsigned long num_blocks; + unsigned long num_nodes = 0; + struct inode_map *inode_map; + unsigned long i; + u64 temp_tail; + u64 new_block; + int allocated; + + sih.ino = NOVA_INODELIST_INO; + sih.i_blk_type = NOVA_DEFAULT_BLOCK_TYPE; + sih.i_blocks = 0; + + for (i = 0; i < sbi->cpus; i++) { + inode_map = &sbi->inode_maps[i]; + num_nodes += inode_map->num_range_node_inode; + } + + num_blocks = num_nodes / RANGENODE_PER_PAGE; + if (num_nodes % RANGENODE_PER_PAGE) + num_blocks++; + + allocated = nova_allocate_inode_log_pages(sb, &sih, num_blocks, + &new_block, ANY_CPU, 0); + if (allocated != num_blocks) { + nova_dbg("Error saving inode list: %d\n", allocated); + return; + } + + temp_tail = new_block; + for (i = 0; i < sbi->cpus; i++) { + inode_map = &sbi->inode_maps[i]; + temp_tail = nova_save_range_nodes_to_log(sb, + &inode_map->inode_inuse_tree, temp_tail, i); + } + + pi->log_head = new_block; + nova_update_tail(pi, temp_tail); + nova_flush_buffer(&pi->log_head, CACHELINE_SIZE, 0); + + nova_dbg("%s: %lu inode nodes, pi head 0x%llx, tail 0x%llx\n", + __func__, num_nodes, pi->log_head, pi->log_tail); +} + void nova_save_blocknode_mappings_to_log(struct super_block *sb) { struct nova_inode *pi = nova_get_inode_by_ino(sb, NOVA_BLOCKNODE_INO); diff --git a/fs/nova/bbuild.h b/fs/nova/bbuild.h index 59cc379..5d2b5f0 100644 --- a/fs/nova/bbuild.h +++ b/fs/nova/bbuild.h @@ -3,6 +3,7 @@ void nova_init_header(struct super_block *sb, struct nova_inode_info_header *sih, u16 i_mode); +void nova_save_inode_list_to_log(struct super_block *sb); void nova_save_blocknode_mappings_to_log(struct super_block *sb); #endif diff --git a/fs/nova/super.c b/fs/nova/super.c index 9b60873..69e4afc 100644 --- a/fs/nova/super.c +++ b/fs/nova/super.c @@ -734,6 +734,7 @@ static void nova_put_super(struct super_block *sb) int i; if (sbi->virt_addr) { + nova_save_inode_list_to_log(sb); /* Save everything before blocknode mapping! */ nova_save_blocknode_mappings_to_log(sb); sbi->virt_addr = NULL; -- 2.7.4