Received: by 10.223.185.111 with SMTP id b44csp1655644wrg; Sat, 10 Mar 2018 10:44:41 -0800 (PST) X-Google-Smtp-Source: AG47ELvcJt3/oSLsOV94Ge9fQNaWBlAebVkYi/yfq7NtoqZoeaIBPpC1vHH8TUThdaO77eOTQBgH X-Received: by 10.101.73.197 with SMTP id t5mr2300596pgs.426.1520707481368; Sat, 10 Mar 2018 10:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520707481; cv=none; d=google.com; s=arc-20160816; b=Eb+fjo/JGcZnwF+eiC26BSyfyVMcOw3CuxM4s5xWMU7d6X1S7iegxMXz/mLMe4JrnF TM8exVxXv+zU1kOKJrB6/3Po1fvvOtY7N6BNSo+is6WkDJPtYW6HedT0iOPaP+JwDKFl 86keRGBSmRHyORRHp+NltWecq2oTKi6btavaFW1xe+v5PqMLMKACZrFOh1X2rdd9xGfj vOBr45iyA6QLLA4JAjNTR41FMZfycWG+43GFWdo2SKhabLBkfRc8PBfTJqe+47vMXexm wrRacYaUSkHwJ4UeCsEBCykKEy0syxyRhG2+mQBBfrhU53FJ7h5GMtWxFQFvJIZIj2vl Tlyw== 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=rsYUnCxab6ayRwIqYwVffC3qYabr4CNTLBRiPUQ+L6M=; b=Soozr9YhK8/j0A+faRq8vIRVP19o9e1Xf1QiM7yOStis0zb3abKKXAl38qCk2ugbZQ nNVGxCvMvZji86JoLs96yqa9y34sNIaOo01lbC0nm47oRECccyVCKZLRnYMYxrVzs2WK yyBLLtWAKTdRPvctZRRMSZf67aavzOLsYxA8M1Fp0m/TRIGnWkCX6J0E9cyzX1jswhOb iO7IEFmyWKIql8zaYqTcLMS55XmdTqARCGeQrAoglgymP/J89h3XmEX2YZtSs2lxDVGJ e8ywPt3IcDdNpXsIA9CpFp0g9+pVn5W5TSvwayDdXcnCRZsUpEOoVVrEQ4WBPBxSGW3l x0iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=Inm5Tqho; 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 k194si2621183pgc.662.2018.03.10.10.44.27; Sat, 10 Mar 2018 10:44:41 -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=Inm5Tqho; 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 S932265AbeCJSU2 (ORCPT + 99 others); Sat, 10 Mar 2018 13:20:28 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:32994 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932217AbeCJSUY (ORCPT ); Sat, 10 Mar 2018 13:20:24 -0500 Received: by mail-pg0-f68.google.com with SMTP id g12so4843993pgs.0 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=PsE71EKA8yGRGeg7fUc+QnXOTbKqXlJ/4a08WiEr6KNCY5CW3KCRGNlfasc1kPNDob i7zIzohGgJrjf88Y9U3KBuMh/Lu4SNXhno2c5MfU0GLbhHDJjmzXOp5sGHlHLGf9egC4 fVzAaxy/IsfL+vv9eWP9B6RQ9ZSworkm+h/izykHS5d2KtGn2NvwAcFMrXh5zXKvkSq6 AkM9dkHdOMkr+9nGVUjKGhJ8j19S1EGSgOI8k3w7eXHvEp8SKmCENoLZ9mHWYCOXgmOe F+Gy9PYwOC9NIOH5puik9WX+P5/wZ4pzzOA3nW7nOYLrZEGoNFy9vAgutvyQ+zcFocQx SYSw== X-Gm-Message-State: AElRT7Futp5dKcMD/yMexrg3bKa0Li2QMdPvVzFVUEdYg3zNTN0/bB7O CzmjQkIwV5ibGrNLPAwzK7oz7Q== 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 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 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; +} + -- 2.7.4