From patchwork Sat Mar 10 18:18:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273865 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 EEFB8601A0 for ; Sat, 10 Mar 2018 18:20:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE06B29106 for ; Sat, 10 Mar 2018 18:20:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2BD9296E5; Sat, 10 Mar 2018 18:20:52 +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 9AE7029106 for ; Sat, 10 Mar 2018 18:20:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 788CE22603B07; Sat, 10 Mar 2018 10:14:32 -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::242; helo=mail-pg0-x242.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (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 9A68722603AEC for ; Sat, 10 Mar 2018 10:14:30 -0800 (PST) Received: by mail-pg0-x242.google.com with SMTP id g8so4832459pgv.7 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=IQm7Pvi9w/aL7WITjIqDj7uXByvctnKriXjJDd9YESM+b1GaDqxYH2bPwAZcQp/sCY yv+XZeJkkRxhosee+J26+7t9slx2rwKSlCqYWNu85IVQka05z41NMXYV+lpamM24GoRv 3upnr2BQoaDftk30cMFKVxJh3SWP7pYHzNsFbVhgrg/zTOXZ1eSArFlcq8DmBdUC//0u sTvQIKLDa+MXlSrXZeEmb9wluddijXYHyxCG51YULT2W9hDqp06ldtsu996EFeJAPS3o +prADYeNE4WzF0OX3uV3fXu9ZFMFUeXrwUZpWC1or06TFrDHaIHviXwKngfXwybXCS6Q Q+Zw== X-Gm-Message-State: AElRT7EiOKjKsSSJIfmEo8gQ40my+PLywToh5+hWZnIjytPYUURoe0HO o+TE3KfJhcQGpJRX2YSo4KM+rg== X-Google-Smtp-Source: AG47ELuftCLbg+wXT//Vrel5tRAFfk4BPLNxSllFYWLasa72NIAcE/yXtmnxbpQquVSIuHcO+Xr0Dg== 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 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> 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 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;