Received: by 10.223.185.111 with SMTP id b44csp1657033wrg; Sat, 10 Mar 2018 10:47:06 -0800 (PST) X-Google-Smtp-Source: AG47ELvbw830ZSyFjJwB0X7tA1+fSLPGjxcDoAg/wZBsvRYoJbAtO7tWxw1hPp6F7JdW/T8QlQyT X-Received: by 10.98.72.10 with SMTP id v10mr2715660pfa.148.1520707626681; Sat, 10 Mar 2018 10:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520707626; cv=none; d=google.com; s=arc-20160816; b=MG4QNiSZcTa4DO5n/ldVAK8We/PfDJiY12hOAfZXdAdmRl8AqjT3JccT0SUmhyVgS0 /TC+hO5qwltLPAQPmjuzPJaNDOzFCBH3ITsd8mvN6d2tgJ7ylTR3HTcbkmQI/lUHoltb X5Tid+SNJjlrESV0pDkZoyQyIVU3PlxlZswPLO3nMvjMOmLgxtwDJ2XLxEFjNMBSWZ0f AYXWN7mVrO5WU1vPbt1xiSWlna2dgz20LrHbNCvObkaCz/4rhwGepMlsss5G5c0VKhyj 2zv2laV0Otmt4WjDx8GP7LzDph62srJgtlunHNDBzzRGE+JOWrW2CGCeGK7nK5lkMqG9 BhRg== 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=V0Gf9BG7l0ALCKyZSvo6HQoDMH8kkZtTR2bY665oyJQ=; b=nqWQepb361PqDyfHqoOJR7Jh0ApKWuUiBKKYoMtydIjk5Kdztr76bk1qci5iHLjjIW IIaxwN+L6EknRUqxCmsRdMYyJ6kXuQ7mFgdyJi/HGQT+QUpNjrxx07QhzKESRTg/IGTk i9VRzdHxg82kebFtdcJDLzzu/RjHMHz2rCVXKNC5qsVxOGH8RKttVanSOt/DCuF7cSNw 4DjhEHhpATrR1JZECxNRZ9rHYJRwbWBJ5hBpgRLq5n//qgu8AFxXqyCJ9Y5qDoT5NbIO SYMXa630dU0uGVS1zaeLY4ZkfeFFwl71LysRionpODDXyNhQaAY9Nfqt6pltuabQdd2J LNxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eng.ucsd.edu header.s=google header.b=B/mQ4t8u; 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 i10si2639289pgs.375.2018.03.10.10.46.52; Sat, 10 Mar 2018 10:47:06 -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=B/mQ4t8u; 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 S932372AbeCJSp5 (ORCPT + 99 others); Sat, 10 Mar 2018 13:45:57 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:34494 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932110AbeCJSUU (ORCPT ); Sat, 10 Mar 2018 13:20:20 -0500 Received: by mail-pg0-f68.google.com with SMTP id m19so4837147pgn.1 for ; Sat, 10 Mar 2018 10:20:19 -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=V0Gf9BG7l0ALCKyZSvo6HQoDMH8kkZtTR2bY665oyJQ=; b=B/mQ4t8uiGbpj2t0bEfbzx9b2BnZzgMgZnv3kADA/vGJkWQyS+hj91y55LDr9LkKuA 5GbyP5w3oJVPcwFjR8/YjtGFF234lEfbMDXHvSV+PFDle1WIPzMgqvu86eZucE9PTMJG c7l8WZ/CSYdW4phq7xxStOg0w0v3vgY98WNpQ= 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=V0Gf9BG7l0ALCKyZSvo6HQoDMH8kkZtTR2bY665oyJQ=; b=ZkcM3veDTtrumcvWK2e7SXsRUeNWCOBcMFWtXzTDqAyGyYSybPw3mywZBzLAVihkaD /dnyamJDjsH/91RPLFNdJEh2JP/ihfXxtWaVNi8L5fXvUXch6R1WSi7mhXWNCGspfgUX 7hvIfvRLkfj0WFN3BQ2Dse153gYbGOxZQLzbj4ktndDH62/AbnVwpShSOOULxqo5gqUe RiM5ZfCGUSpT8GR3+vjF8PHdwLNwKHvYRy3WLfyDnBwSEgL3U1vM9si2CCTJWtjXuWMc XT/ZaU39UP2ZA8cswHYcOXUMWnaA+WFYozM1D6RSAyFAJenZYl470IeBz/5oGklHQVQY IO4A== X-Gm-Message-State: AElRT7GfRhJMyUZ/UFghze6/LYzsD7u8FJJjWoiUHVsZC0bVGf8cc+0q 5pbXKsFRjhdIfBz4OmJDp5WWDg== X-Received: by 10.98.254.6 with SMTP id z6mr2646507pfh.155.1520706018772; Sat, 10 Mar 2018 10:20:18 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:20:18 -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 03/83] Add super.h. Date: Sat, 10 Mar 2018 10:17:44 -0800 Message-Id: <1520705944-6723-4-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 This header file defines NOVA persistent and volatile superblock data structures. It also defines NOVA block layout: Page 0: Superblock Page 1: Reserved inodes Page 2 - 15: Reserved Page 16 - 31: Inode table pointers Page 32 - 47: Journal address pointers Page 48 - 63: Reserved Pages n-2: Replicate reserved inodes Pages n-1: Replicate superblock Other pages are for normal inodes, logs and data. Signed-off-by: Andiry Xu --- fs/nova/super.h | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 fs/nova/super.h diff --git a/fs/nova/super.h b/fs/nova/super.h new file mode 100644 index 0000000..cb53908 --- /dev/null +++ b/fs/nova/super.h @@ -0,0 +1,149 @@ +#ifndef __SUPER_H +#define __SUPER_H +/* + * Structure of the NOVA super block in PMEM + * + * The fields are partitioned into static and dynamic fields. The static fields + * never change after file system creation. This was primarily done because + * nova_get_block() returns NULL if the block offset is 0 (helps in catching + * bugs). So if we modify any field using journaling (for consistency), we + * will have to modify s_sum which is at offset 0. So journaling code fails. + * This (static+dynamic fields) is a temporary solution and can be avoided + * once the file system becomes stable and nova_get_block() returns correct + * pointers even for offset 0. + */ +struct nova_super_block { + /* static fields. they never change after file system creation. + * checksum only validates up to s_start_dynamic field below + */ + __le32 s_sum; /* checksum of this sb */ + __le32 s_magic; /* magic signature */ + __le32 s_padding32; + __le32 s_blocksize; /* blocksize in bytes */ + __le64 s_size; /* total size of fs in bytes */ + char s_volume_name[16]; /* volume name */ + + /* all the dynamic fields should go here */ + __le64 s_epoch_id; /* Epoch ID */ + + /* s_mtime and s_wtime should be together and their order should not be + * changed. we use an 8 byte write to update both of them atomically + */ + __le32 s_mtime; /* mount time */ + __le32 s_wtime; /* write time */ +} __attribute((__packed__)); + +#define NOVA_SB_SIZE 512 /* must be power of two */ + +/* ======================= Reserved blocks ========================= */ + +/* + * Page 0 contains super blocks; + * Page 1 contains reserved inodes; + * Page 2 - 15 are reserved. + * Page 16 - 31 contain pointers to inode tables. + * Page 32 - 47 contain pointers to journal pages. + */ +#define HEAD_RESERVED_BLOCKS 64 +#define NUM_JOURNAL_PAGES 16 + +#define SUPER_BLOCK_START 0 // Superblock +#define RESERVE_INODE_START 1 // Reserved inodes +#define INODE_TABLE_START 16 // inode table pointers +#define JOURNAL_START 32 // journal pointer table + +/* For replica super block and replica reserved inodes */ +#define TAIL_RESERVED_BLOCKS 2 + +/* ======================= Reserved inodes ========================= */ + +/* We have space for 31 reserved inodes */ +#define NOVA_ROOT_INO (1) +#define NOVA_INODETABLE_INO (2) /* Fake inode associated with inode + * stroage. We need this because our + * allocator requires inode to be + * associated with each allocation. + * The data actually lives in linked + * lists in INODE_TABLE_START. */ +#define NOVA_BLOCKNODE_INO (3) /* Storage for allocator state */ +#define NOVA_LITEJOURNAL_INO (4) /* Storage for lightweight journals */ +#define NOVA_INODELIST_INO (5) /* Storage for Inode free list */ + + +/* Normal inode starts at 32 */ +#define NOVA_NORMAL_INODE_START (32) + + + +/* + * NOVA super-block data in DRAM + */ +struct nova_sb_info { + struct super_block *sb; /* VFS super block */ + struct nova_super_block *nova_sb; /* DRAM copy of SB */ + struct block_device *s_bdev; + struct dax_device *s_dax_dev; + + /* + * base physical and virtual address of NOVA (which is also + * the pointer to the super block) + */ + phys_addr_t phys_addr; + void *virt_addr; + void *replica_reserved_inodes_addr; + void *replica_sb_addr; + + unsigned long num_blocks; + + /* Mount options */ + unsigned long bpi; + unsigned long blocksize; + unsigned long initsize; + unsigned long s_mount_opt; + kuid_t uid; /* Mount uid for root directory */ + kgid_t gid; /* Mount gid for root directory */ + umode_t mode; /* Mount mode for root directory */ + atomic_t next_generation; + /* inode tracking */ + unsigned long s_inodes_used_count; + unsigned long head_reserved_blocks; + unsigned long tail_reserved_blocks; + + struct mutex s_lock; /* protects the SB's buffer-head */ + + int cpus; + + /* Current epoch. volatile guarantees visibility */ + volatile u64 s_epoch_id; + + /* ZEROED page for cache page initialized */ + void *zeroed_page; +}; + +static inline struct nova_sb_info *NOVA_SB(struct super_block *sb) +{ + return sb->s_fs_info; +} + +static inline struct nova_super_block +*nova_get_redund_super(struct super_block *sb) +{ + struct nova_sb_info *sbi = NOVA_SB(sb); + + return (struct nova_super_block *)(sbi->replica_sb_addr); +} + + +/* If this is part of a read-modify-write of the super block, + * nova_memunlock_super() before calling! + */ +static inline struct nova_super_block *nova_get_super(struct super_block *sb) +{ + struct nova_sb_info *sbi = NOVA_SB(sb); + + return (struct nova_super_block *)sbi->virt_addr; +} + +extern void nova_error_mng(struct super_block *sb, const char *fmt, ...); + +#endif -- 2.7.4