From patchwork Sat Mar 10 18:17:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273813 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 1447C605F3 for ; Sat, 10 Mar 2018 18:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 010CB29106 for ; Sat, 10 Mar 2018 18:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E89DC28BAE; Sat, 10 Mar 2018 18:20:31 +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 E80F2299E0 for ; Sat, 10 Mar 2018 18:20:29 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 31F352258AEF2; Sat, 10 Mar 2018 10:14:06 -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::243; helo=mail-pg0-x243.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) (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 92D2A2258AEE5 for ; Sat, 10 Mar 2018 10:14:05 -0800 (PST) Received: by mail-pg0-x243.google.com with SMTP id m19so4837191pgn.1 for ; Sat, 10 Mar 2018 10:20:24 -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=rsYUnCxab6ayRwIqYwVffC3qYabr4CNTLBRiPUQ+L6M=; b=Inm5Tqho3l+8QVOZJVpkmL+SE0WSVIBU7w4dc3TP3gcT+0w3gXB7/z10iTiMEpCqLv 8x3GTX6vhLYh8728crPgYKLnht7PYl6wHGt1dARr3plcR0dwSpLP9e6lbt8uIsUwXAZe mwg3tqoCLz/rLtZP0pGYcA6jERHqebg1vLjpI= 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=rsYUnCxab6ayRwIqYwVffC3qYabr4CNTLBRiPUQ+L6M=; b=XSeJ/auG1wXT9QzySfwGKJA/FO1PNimzwD0zfNUpSZ37NbTZNJgX+BAm01ZP2GGURn t+q+fvbTBuxhb3Y3wOhfmSOqbXSJLUcf9GdklA54/we7Tom/NSmivz9X39zcfpvEj01p BH6YFpFKuvA4pOKx5JKgTmgGr6keNKL6B4reDdxkP1pFBjdUFR7lSIjSB3s0DiR8XBdQ eUg9FXMX9QXRxZGlBL1OjqLh2yHL7CFiVZRfWsAr3e0kfIx9q9N+36qK/PK6nZTr0MOc fM2U3wAwu4DqhG4LXu8daKTjGKWuhtMc2OthJBwn66186+eqRAELe+rAwhUfe38LAnFI VsxA== X-Gm-Message-State: AElRT7G333JTEHeAjSm2XaFIcDp/K+kML34+VIBPcWv7LM4NWBrQ3QSW fmRk3jZaq7x4XUjkyiI61i+IuA== X-Google-Smtp-Source: AG47ELv4bTPLYwlmEo7IH3tMaYE9q/UrGkRq8GNBt2iOl+eHL6UyJJIZBEu2+UrOwM0Io7HqEVzlww== X-Received: by 10.101.86.198 with SMTP id w6mr2208808pgs.434.1520706023850; Sat, 10 Mar 2018 10:20:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:23 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 07/83] Initialize inode_info and rebuild inode information in nova_iget(). Date: Sat, 10 Mar 2018 10:17:48 -0800 Message-Id: <1520705944-6723-8-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 Incomplete nova_rebuild_inode() implemenation. nova_rebuild_inode() will go through the inode log and rebuild radix tree and metadata. Leave for later patches. Signed-off-by: Andiry Xu --- fs/nova/bbuild.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nova/bbuild.h | 7 +++++++ fs/nova/inode.c | 6 ++++++ fs/nova/nova.h | 10 ++++++++++ fs/nova/rebuild.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 124 insertions(+) create mode 100644 fs/nova/bbuild.c create mode 100644 fs/nova/bbuild.h create mode 100644 fs/nova/rebuild.c diff --git a/fs/nova/bbuild.c b/fs/nova/bbuild.c new file mode 100644 index 0000000..8bc0545 --- /dev/null +++ b/fs/nova/bbuild.c @@ -0,0 +1,53 @@ +/* + * NOVA Recovery routines. + * + * Copyright 2015-2016 Regents of the University of California, + * UCSD Non-Volatile Systems Lab, Andiry Xu + * Copyright 2012-2013 Intel Corporation + * Copyright 2009-2011 Marco Stornelli + * Copyright 2003 Sony Corporation + * Copyright 2003 Matsushita Electric Industrial Co., Ltd. + * 2003-2004 (c) MontaVista Software, Inc. , Steve Longerbeam + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include "nova.h" +#include "super.h" +#include "inode.h" + +void nova_init_header(struct super_block *sb, + struct nova_inode_info_header *sih, u16 i_mode) +{ + sih->log_pages = 0; + sih->i_size = 0; + sih->ino = 0; + sih->i_blocks = 0; + sih->pi_addr = 0; + INIT_RADIX_TREE(&sih->tree, GFP_ATOMIC); + sih->i_mode = i_mode; + sih->i_flags = 0; + sih->valid_entries = 0; + sih->num_entries = 0; + sih->last_setattr = 0; + sih->last_link_change = 0; + sih->last_dentry = 0; + sih->trans_id = 0; + sih->log_head = 0; + sih->log_tail = 0; + sih->i_blk_type = NOVA_DEFAULT_BLOCK_TYPE; + init_rwsem(&sih->i_sem); +} + diff --git a/fs/nova/bbuild.h b/fs/nova/bbuild.h new file mode 100644 index 0000000..162a832 --- /dev/null +++ b/fs/nova/bbuild.h @@ -0,0 +1,7 @@ +#ifndef __BBUILD_H +#define __BBUILD_H + +void nova_init_header(struct super_block *sb, + struct nova_inode_info_header *sih, u16 i_mode); + +#endif diff --git a/fs/nova/inode.c b/fs/nova/inode.c index bfdc5dc..f7d6410 100644 --- a/fs/nova/inode.c +++ b/fs/nova/inode.c @@ -158,6 +158,12 @@ struct inode *nova_iget(struct super_block *sb, unsigned long ino) goto fail; } + err = nova_rebuild_inode(sb, si, ino, pi_addr, 1); + if (err) { + nova_dbg("%s: failed to rebuild inode %lu\n", __func__, ino); + goto fail; + } + err = nova_read_inode(sb, inode, pi_addr); if (unlikely(err)) { nova_dbg("%s: failed to read inode %lu\n", __func__, ino); diff --git a/fs/nova/nova.h b/fs/nova/nova.h index 5eb696c..ded9fe8 100644 --- a/fs/nova/nova.h +++ b/fs/nova/nova.h @@ -296,4 +296,14 @@ static inline u64 nova_get_epoch_id(struct super_block *sb) } #include "inode.h" +#include "bbuild.h" + +/* ====================================================== */ +/* ============== Function prototypes ================= */ +/* ====================================================== */ + +/* rebuild.c */ +int nova_rebuild_inode(struct super_block *sb, struct nova_inode_info *si, + u64 ino, u64 pi_addr, int rebuild_dir); + #endif /* __NOVA_H */ diff --git a/fs/nova/rebuild.c b/fs/nova/rebuild.c new file mode 100644 index 0000000..0595851 --- /dev/null +++ b/fs/nova/rebuild.c @@ -0,0 +1,48 @@ +/* + * BRIEF DESCRIPTION + * + * Inode rebuild methods. + * + * Copyright 2015-2016 Regents of the University of California, + * UCSD Non-Volatile Systems Lab, Andiry Xu + * Copyright 2012-2013 Intel Corporation + * Copyright 2009-2011 Marco Stornelli + * Copyright 2003 Sony Corporation + * Copyright 2003 Matsushita Electric Industrial Co., Ltd. + * 2003-2004 (c) MontaVista Software, Inc. , Steve Longerbeam + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include "nova.h" +#include "inode.h" + +/* initialize nova inode header and other DRAM data structures */ +int nova_rebuild_inode(struct super_block *sb, struct nova_inode_info *si, + u64 ino, u64 pi_addr, int rebuild_dir) +{ + struct nova_inode_info_header *sih = &si->header; + struct nova_inode *pi; + + pi = (struct nova_inode *)nova_get_block(sb, pi_addr); + // We need this valid in case we need to evict the inode. + + nova_init_header(sb, sih, __le16_to_cpu(pi->i_mode)); + sih->pi_addr = pi_addr; + + if (pi->deleted == 1) { + nova_dbgv("%s: inode %llu has been deleted.\n", __func__, ino); + return -ESTALE; + } + + nova_dbgv("%s: inode %llu, addr 0x%llx, valid %d, head 0x%llx, tail 0x%llx\n", + __func__, ino, pi_addr, pi->valid, + pi->log_head, pi->log_tail); + + sih->ino = ino; + + /* Traverse the log */ + return 0; +} +