16e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 26e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * nilfs2_ondisk.h - NILFS2 on-disk structures 36e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 46e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. 56e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 66e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * This program is free software; you can redistribute it and/or modify 76e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * it under the terms of the GNU Lesser General Public License as published 86e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * by the Free Software Foundation; either version 2.1 of the License, or 96e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * (at your option) any later version. 106e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 116e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 126e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * linux/include/linux/ext2_fs.h 136e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 146e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Copyright (C) 1992, 1993, 1994, 1995 156e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Remy Card (card@masi.ibp.fr) 166e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Laboratoire MASI - Institut Blaise Pascal 176e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Universite Pierre et Marie Curie (Paris VI) 186e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 196e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * from 206e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 216e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * linux/include/linux/minix_fs.h 226e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 236e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Copyright (C) 1991, 1992 Linus Torvalds 246e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 256e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 266e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#ifndef _LINUX_NILFS2_ONDISK_H 276e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define _LINUX_NILFS2_ONDISK_H 286e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 296e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#include <linux/types.h> 306e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#include <linux/magic.h> 316e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 326e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 336e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_INODE_BMAP_SIZE 7 346e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 356e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 366e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_inode - structure of an inode on disk 376e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_blocks: blocks count 386e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_size: size in bytes 396e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_ctime: creation time (seconds) 406e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_mtime: modification time (seconds) 416e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_ctime_nsec: creation time (nano seconds) 426e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_mtime_nsec: modification time (nano seconds) 436e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_uid: user id 446e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_gid: group id 456e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_mode: file mode 466e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_links_count: links count 476e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_flags: file flags 486e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_bmap: block mapping 496e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_xattr: extended attributes 506e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_generation: file generation (for NFS) 516e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @i_pad: padding 526e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 536e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_inode { 546e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 i_blocks; 556e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 i_size; 566e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 i_ctime; 576e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 i_mtime; 586e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 i_ctime_nsec; 596e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 i_mtime_nsec; 606e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 i_uid; 616e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 i_gid; 626e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 i_mode; 636e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 i_links_count; 646e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 i_flags; 656e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 i_bmap[NILFS_INODE_BMAP_SIZE]; 666e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define i_device_code i_bmap[0] 676e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 i_xattr; 686e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 i_generation; 696e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 i_pad; 706e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 716e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 726e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MIN_INODE_SIZE 128 736e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 746e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 756e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_super_root - structure of super root 766e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sr_sum: check sum 776e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sr_bytes: byte count of the structure 786e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sr_flags: flags (reserved) 796e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sr_nongc_ctime: write time of the last segment not for cleaner operation 806e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sr_dat: DAT file inode 816e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sr_cpfile: checkpoint file inode 826e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sr_sufile: segment usage file inode 836e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 846e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_super_root { 856e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 sr_sum; 866e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 sr_bytes; 876e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 sr_flags; 886e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 sr_nongc_ctime; 896e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris struct nilfs_inode sr_dat; 906e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris struct nilfs_inode sr_cpfile; 916e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris struct nilfs_inode sr_sufile; 926e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 936e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 946e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SR_MDT_OFFSET(inode_size, i) \ 956e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris ((unsigned long)&((struct nilfs_super_root *)0)->sr_dat + \ 966e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris (inode_size) * (i)) 976e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SR_DAT_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 0) 986e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SR_CPFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 1) 996e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SR_SUFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 2) 1006e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SR_BYTES(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 3) 1016e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1026e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 1036e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Maximal mount counts 1046e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1056e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_DFL_MAX_MNT_COUNT 50 /* 50 mounts */ 1066e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1076e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 1086e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * File system states (sbp->s_state, nilfs->ns_mount_state) 1096e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1106e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_VALID_FS 0x0001 /* Unmounted cleanly */ 1116e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_ERROR_FS 0x0002 /* Errors detected */ 1126e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_RESIZE_FS 0x0004 /* Resize required */ 1136e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1146e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 1156e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Mount flags (sbi->s_mount_opt) 1166e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1176e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MOUNT_ERROR_MODE 0x0070 /* Error mode mask */ 1186e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ 1196e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ 1206e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ 1216e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MOUNT_BARRIER 0x1000 /* Use block barriers */ 1226e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MOUNT_STRICT_ORDER 0x2000 /* 1236e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Apply strict in-order 1246e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * semantics also for data 1256e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1266e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MOUNT_NORECOVERY 0x4000 /* 1276e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Disable write access during 1286e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * mount-time recovery 1296e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1306e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MOUNT_DISCARD 0x8000 /* Issue DISCARD requests */ 1316e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1326e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1336e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 1346e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_super_block - structure of super block on disk 1356e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1366e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_super_block { 1376e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*00*/ __le32 s_rev_level; /* Revision level */ 1386e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_minor_rev_level; /* minor revision level */ 1396e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_magic; /* Magic signature */ 1406e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1416e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_bytes; /* 1426e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Bytes count of CRC calculation 1436e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * for this structure. s_reserved 1446e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * is excluded. 1456e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1466e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_flags; /* flags */ 1476e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 s_crc_seed; /* Seed value of CRC calculation */ 1486e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*10*/ __le32 s_sum; /* Check sum of super block */ 1496e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1506e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 s_log_block_size; /* 1516e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Block size represented as follows 1526e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * blocksize = 1536e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 1 << (s_log_block_size + 10) 1546e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1556e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_nsegments; /* Number of segments in filesystem */ 1566e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*20*/ __le64 s_dev_size; /* block device size in bytes */ 1576e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_first_data_block; /* 1st seg disk block number */ 1586e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*30*/ __le32 s_blocks_per_segment; /* number of blocks per full segment */ 1596e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 s_r_segments_percentage; /* Reserved segments percentage */ 1606e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1616e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_last_cno; /* Last checkpoint number */ 1626e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*40*/ __le64 s_last_pseg; /* disk block addr pseg written last */ 1636e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_last_seq; /* seq. number of seg written last */ 1646e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*50*/ __le64 s_free_blocks_count; /* Free blocks count */ 1656e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1666e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_ctime; /* 1676e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Creation time (execution time of 1686e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * newfs) 1696e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1706e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*60*/ __le64 s_mtime; /* Mount time */ 1716e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_wtime; /* Write time */ 1726e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*70*/ __le16 s_mnt_count; /* Mount count */ 1736e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_max_mnt_count; /* Maximal mount count */ 1746e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_state; /* File system state */ 1756e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_errors; /* Behaviour when detecting errors */ 1766e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_lastcheck; /* time of last check */ 1776e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1786e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*80*/ __le32 s_checkinterval; /* max. time between checks */ 1796e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 s_creator_os; /* OS */ 1806e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_def_resuid; /* Default uid for reserved blocks */ 1816e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_def_resgid; /* Default gid for reserved blocks */ 1826e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 s_first_ino; /* First non-reserved inode */ 1836e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1846e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*90*/ __le16 s_inode_size; /* Size of an inode */ 1856e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_dat_entry_size; /* Size of a dat entry */ 1866e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_checkpoint_size; /* Size of a checkpoint */ 1876e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 s_segment_usage_size; /* Size of a segment usage */ 1886e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1896e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*98*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */ 1906e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*A8*/ char s_volume_name[80]; /* volume name */ 1916e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 1926e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*F8*/ __le32 s_c_interval; /* Commit interval of segment */ 1936e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 s_c_block_max; /* 1946e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Threshold of data amount for 1956e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * the segment construction 1966e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 1976e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/*100*/ __le64 s_feature_compat; /* Compatible feature set */ 1986e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_feature_compat_ro; /* Read-only compatible feature set */ 1996e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 s_feature_incompat; /* Incompatible feature set */ 2006e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u32 s_reserved[186]; /* padding to the end of the block */ 2016e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 2026e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2036e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2046e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Codes for operating systems 2056e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2066e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_OS_LINUX 0 2076e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* Codes from 1 to 4 are reserved to keep compatibility with ext2 creator-OS */ 2086e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2096e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2106e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Revision levels 2116e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2126e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_CURRENT_REV 2 /* current major revision */ 2136e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MINOR_REV 0 /* minor revision */ 2146e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MIN_SUPP_REV 2 /* minimum supported revision */ 2156e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2166e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2176e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Feature set definitions 2186e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 2196e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * If there is a bit set in the incompatible feature set that the kernel 2206e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * doesn't know about, it should refuse to mount the filesystem. 2216e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2226e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT 0x00000001ULL 2236e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2246e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_FEATURE_COMPAT_SUPP 0ULL 2256e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_FEATURE_COMPAT_RO_SUPP NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT 2266e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_FEATURE_INCOMPAT_SUPP 0ULL 2276e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2286e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2296e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Bytes count of super_block for CRC-calculation 2306e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2316e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SB_BYTES \ 2326e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris ((long)&((struct nilfs_super_block *)0)->s_reserved) 2336e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2346e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2356e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Special inode number 2366e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2376e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_ROOT_INO 2 /* Root file inode */ 2386e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_DAT_INO 3 /* DAT file */ 2396e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_CPFILE_INO 4 /* checkpoint file */ 2406e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SUFILE_INO 5 /* segment usage file */ 2416e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_IFILE_INO 6 /* ifile */ 2426e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_ATIME_INO 7 /* Atime file (reserved) */ 2436e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_XATTR_INO 8 /* Xattribute file (reserved) */ 2446e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SKETCH_INO 10 /* Sketch file */ 2456e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_USER_INO 11 /* Fisrt user's file inode number */ 2466e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2476e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SB_OFFSET_BYTES 1024 /* byte offset of nilfs superblock */ 2486e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2496e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SEG_MIN_BLOCKS 16 /* 2506e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Minimum number of blocks in 2516e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * a full segment 2526e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2536e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_PSEG_MIN_BLOCKS 2 /* 2546e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Minimum number of blocks in 2556e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * a partial segment 2566e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2576e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MIN_NRSVSEGS 8 /* 2586e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Minimum number of reserved 2596e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * segments 2606e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2616e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2626e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2636e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * We call DAT, cpfile, and sufile root metadata files. Inodes of 2646e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * these files are written in super root block instead of ifile, and 2656e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * garbage collector doesn't keep any past versions of these files. 2666e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2676e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_ROOT_METADATA_FILE(ino) \ 2686e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris ((ino) >= NILFS_DAT_INO && (ino) <= NILFS_SUFILE_INO) 2696e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2706e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2716e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * bytes offset of secondary super block 2726e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2736e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12) 2746e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2756e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2766e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Maximal count of links to a file 2776e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2786e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_LINK_MAX 32000 2796e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2806e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2816e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Structure of a directory entry 2826e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * (Same as ext2) 2836e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2846e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2856e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_NAME_LEN 255 2866e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2876e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2886e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Block size limitations 2896e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2906e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MIN_BLOCK_SIZE 1024 2916e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MAX_BLOCK_SIZE 65536 2926e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 2936e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 2946e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * The new version of the directory entry. Since V0 structures are 2956e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * stored in intel byte order, and the name_len field could never be 2966e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * bigger than 255 chars, it's safe to reclaim the extra byte for the 2976e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * file_type field. 2986e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 2996e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_dir_entry { 3006e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 inode; /* Inode number */ 3016e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 rec_len; /* Directory entry length */ 3026e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u8 name_len; /* Name length */ 3036e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u8 file_type; /* Dir entry type (file, dir, etc) */ 3046e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris char name[NILFS_NAME_LEN]; /* File name */ 3056e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris char pad; 3066e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 3076e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 3086e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 3096e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * NILFS directory file types. Only the low 3 bits are used. The 3106e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * other bits are reserved for now. 3116e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 3126e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisenum { 3136e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_UNKNOWN, 3146e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_REG_FILE, 3156e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_DIR, 3166e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_CHRDEV, 3176e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_BLKDEV, 3186e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_FIFO, 3196e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_SOCK, 3206e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_SYMLINK, 3216e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_FT_MAX 3226e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 3236e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 3246e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 3256e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * NILFS_DIR_PAD defines the directory entries boundaries 3266e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * 3276e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * NOTE: It must be a multiple of 8 3286e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 3296e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_DIR_PAD 8 3306e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1) 3316e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \ 3326e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris ~NILFS_DIR_ROUND) 3336e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MAX_REC_LEN ((1 << 16) - 1) 3346e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 3356e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 3366e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_finfo - file information 3376e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @fi_ino: inode number 3386e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @fi_cno: checkpoint number 3396e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @fi_nblocks: number of blocks (including intermediate blocks) 3406e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @fi_ndatablk: number of file data blocks 3416e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 3426e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_finfo { 3436e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 fi_ino; 3446e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 fi_cno; 3456e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 fi_nblocks; 3466e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 fi_ndatablk; 3476e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 3486e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 3496e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 3506e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_binfo_v - information on a data block (except DAT) 3516e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bi_vblocknr: virtual block number 3526e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bi_blkoff: block offset 3536e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 3546e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_binfo_v { 3556e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 bi_vblocknr; 3566e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 bi_blkoff; 3576e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 3586e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 3596e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 3606e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_binfo_dat - information on a DAT node block 3616e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bi_blkoff: block offset 3626e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bi_level: level 3636e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bi_pad: padding 3646e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 3656e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_binfo_dat { 3666e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 bi_blkoff; 3676e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u8 bi_level; 3686e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u8 bi_pad[7]; 3696e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 3706e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 3716e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 3726e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * union nilfs_binfo: block information 3736e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bi_v: nilfs_binfo_v structure 3746e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bi_dat: nilfs_binfo_dat structure 3756e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 3766e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisunion nilfs_binfo { 3776e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris struct nilfs_binfo_v bi_v; 3786e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris struct nilfs_binfo_dat bi_dat; 3796e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 3806e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 3816e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 3826e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_segment_summary - segment summary header 3836e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_datasum: checksum of data 3846e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_sumsum: checksum of segment summary 3856e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_magic: magic number 3866e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_bytes: size of this structure in bytes 3876e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_flags: flags 3886e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_seq: sequence number 3896e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_create: creation timestamp 3906e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_next: next segment 3916e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_nblocks: number of blocks 3926e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_nfinfo: number of finfo structures 3936e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_sumbytes: total size of segment summary in bytes 3946e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_pad: padding 3956e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ss_cno: checkpoint number 3966e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 3976e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_segment_summary { 3986e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 ss_datasum; 3996e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 ss_sumsum; 4006e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 ss_magic; 4016e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 ss_bytes; 4026e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 ss_flags; 4036e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 ss_seq; 4046e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 ss_create; 4056e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 ss_next; 4066e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 ss_nblocks; 4076e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 ss_nfinfo; 4086e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 ss_sumbytes; 4096e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 ss_pad; 4106e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 ss_cno; 4116e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris /* array of finfo structures */ 4126e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 4136e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4146e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SEGSUM_MAGIC 0x1eaffa11 /* segment summary magic number */ 4156e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4166e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* 4176e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Segment summary flags 4186e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 4196e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SS_LOGBGN 0x0001 /* begins a logical segment */ 4206e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SS_LOGEND 0x0002 /* ends a logical segment */ 4216e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SS_SR 0x0004 /* has super root */ 4226e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SS_SYNDT 0x0008 /* includes data only updates */ 4236e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SS_GC 0x0010 /* segment written for cleaner operation */ 4246e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4256e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 4266e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_btree_node - header of B-tree node block 4276e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bn_flags: flags 4286e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bn_level: level 4296e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bn_nchildren: number of children 4306e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @bn_pad: padding 4316e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 4326e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_btree_node { 4336e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u8 bn_flags; 4346e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u8 bn_level; 4356e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le16 bn_nchildren; 4366e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 bn_pad; 4376e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 4386e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4396e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* flags */ 4406e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_BTREE_NODE_ROOT 0x01 4416e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4426e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* level */ 4436e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_BTREE_LEVEL_DATA 0 4446e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_BTREE_LEVEL_NODE_MIN (NILFS_BTREE_LEVEL_DATA + 1) 4456e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_BTREE_LEVEL_MAX 14 /* Max level (exclusive) */ 4466e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4476e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 4486e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_direct_node - header of built-in bmap array 4496e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @dn_flags: flags 4506e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @dn_pad: padding 4516e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 4526e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_direct_node { 4536e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u8 dn_flags; 4546e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __u8 pad[7]; 4556e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 4566e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4576e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 4586e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_palloc_group_desc - block group descriptor 4596e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @pg_nfrees: number of free entries in block group 4606e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 4616e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_palloc_group_desc { 4626e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 pg_nfrees; 4636e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 4646e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4656e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 4666e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_dat_entry - disk address translation entry 4676e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @de_blocknr: block number 4686e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @de_start: start checkpoint number 4696e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @de_end: end checkpoint number 4706e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @de_rsv: reserved for future use 4716e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 4726e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_dat_entry { 4736e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 de_blocknr; 4746e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 de_start; 4756e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 de_end; 4766e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 de_rsv; 4776e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 4786e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4796e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MIN_DAT_ENTRY_SIZE 32 4806e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4816e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 4826e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_snapshot_list - snapshot list 4836e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ssl_next: next checkpoint number on snapshot list 4846e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ssl_prev: previous checkpoint number on snapshot list 4856e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 4866e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_snapshot_list { 4876e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 ssl_next; 4886e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 ssl_prev; 4896e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 4906e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 4916e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 4926e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_checkpoint - checkpoint structure 4936e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_flags: flags 4946e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_checkpoints_count: checkpoints count in a block 4956e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_snapshot_list: snapshot list 4966e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_cno: checkpoint number 4976e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_create: creation timestamp 4986e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_nblk_inc: number of blocks incremented by this checkpoint 4996e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_inodes_count: inodes count 5006e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_blocks_count: blocks count 5016e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @cp_ifile_inode: inode of ifile 5026e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 5036e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_checkpoint { 5046e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 cp_flags; 5056e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 cp_checkpoints_count; 5066e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris struct nilfs_snapshot_list cp_snapshot_list; 5076e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 cp_cno; 5086e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 cp_create; 5096e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 cp_nblk_inc; 5106e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 cp_inodes_count; 5116e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 cp_blocks_count; 5126e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5136e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris /* 5146e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * Do not change the byte offset of ifile inode. 5156e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * To keep the compatibility of the disk format, 5166e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * additional fields should be added behind cp_ifile_inode. 5176e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 5186e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris struct nilfs_inode cp_ifile_inode; 5196e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 5206e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5216e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MIN_CHECKPOINT_SIZE (64 + NILFS_MIN_INODE_SIZE) 5226e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5236e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* checkpoint flags */ 5246e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisenum { 5256e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_CHECKPOINT_SNAPSHOT, 5266e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_CHECKPOINT_INVALID, 5276e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_CHECKPOINT_SKETCH, 5286e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_CHECKPOINT_MINOR, 5296e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 5306e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5316e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_CHECKPOINT_FNS(flag, name) \ 5326e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstatic inline void \ 5336e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisnilfs_checkpoint_set_##name(struct nilfs_checkpoint *cp) \ 5346e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris{ \ 5356e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) | \ 5366e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris (1UL << NILFS_CHECKPOINT_##flag)); \ 5376e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris} \ 5386e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstatic inline void \ 5396e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisnilfs_checkpoint_clear_##name(struct nilfs_checkpoint *cp) \ 5406e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris{ \ 5416e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) & \ 5426e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris ~(1UL << NILFS_CHECKPOINT_##flag)); \ 5436e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris} \ 5446e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstatic inline int \ 5456e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisnilfs_checkpoint_##name(const struct nilfs_checkpoint *cp) \ 5466e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris{ \ 5476e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris return !!(le32_to_cpu(cp->cp_flags) & \ 5486e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris (1UL << NILFS_CHECKPOINT_##flag)); \ 5496e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris} 5506e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5516e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher FerrisNILFS_CHECKPOINT_FNS(SNAPSHOT, snapshot) 5526e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher FerrisNILFS_CHECKPOINT_FNS(INVALID, invalid) 5536e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher FerrisNILFS_CHECKPOINT_FNS(MINOR, minor) 5546e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5556e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 5566e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_cpfile_header - checkpoint file header 5576e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ch_ncheckpoints: number of checkpoints 5586e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ch_nsnapshots: number of snapshots 5596e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @ch_snapshot_list: snapshot list 5606e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 5616e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_cpfile_header { 5626e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 ch_ncheckpoints; 5636e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 ch_nsnapshots; 5646e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris struct nilfs_snapshot_list ch_snapshot_list; 5656e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 5666e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5676e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET \ 5686e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris ((sizeof(struct nilfs_cpfile_header) + \ 5696e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris sizeof(struct nilfs_checkpoint) - 1) / \ 5706e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris sizeof(struct nilfs_checkpoint)) 5716e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5726e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 5736e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_segment_usage - segment usage 5746e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @su_lastmod: last modified timestamp 5756e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @su_nblocks: number of blocks in segment 5766e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @su_flags: flags 5776e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 5786e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_segment_usage { 5796e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 su_lastmod; 5806e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 su_nblocks; 5816e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le32 su_flags; 5826e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 5836e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5846e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_MIN_SEGMENT_USAGE_SIZE 16 5856e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5866e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/* segment usage flag */ 5876e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisenum { 5886e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_SEGMENT_USAGE_ACTIVE, 5896e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_SEGMENT_USAGE_DIRTY, 5906e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris NILFS_SEGMENT_USAGE_ERROR, 5916e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 5926e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 5936e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SEGMENT_USAGE_FNS(flag, name) \ 5946e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstatic inline void \ 5956e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisnilfs_segment_usage_set_##name(struct nilfs_segment_usage *su) \ 5966e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris{ \ 5976e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris su->su_flags = cpu_to_le32(le32_to_cpu(su->su_flags) | \ 5986e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris (1UL << NILFS_SEGMENT_USAGE_##flag));\ 5996e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris} \ 6006e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstatic inline void \ 6016e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisnilfs_segment_usage_clear_##name(struct nilfs_segment_usage *su) \ 6026e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris{ \ 6036e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris su->su_flags = \ 6046e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris cpu_to_le32(le32_to_cpu(su->su_flags) & \ 6056e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris ~(1UL << NILFS_SEGMENT_USAGE_##flag)); \ 6066e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris} \ 6076e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstatic inline int \ 6086e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisnilfs_segment_usage_##name(const struct nilfs_segment_usage *su) \ 6096e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris{ \ 6106e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris return !!(le32_to_cpu(su->su_flags) & \ 6116e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris (1UL << NILFS_SEGMENT_USAGE_##flag)); \ 6126e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris} 6136e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 6146e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher FerrisNILFS_SEGMENT_USAGE_FNS(ACTIVE, active) 6156e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher FerrisNILFS_SEGMENT_USAGE_FNS(DIRTY, dirty) 6166e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher FerrisNILFS_SEGMENT_USAGE_FNS(ERROR, error) 6176e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 6186e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstatic inline void 6196e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisnilfs_segment_usage_set_clean(struct nilfs_segment_usage *su) 6206e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris{ 6216e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris su->su_lastmod = cpu_to_le64(0); 6226e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris su->su_nblocks = cpu_to_le32(0); 6236e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris su->su_flags = cpu_to_le32(0); 6246e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris} 6256e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 6266e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstatic inline int 6276e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisnilfs_segment_usage_clean(const struct nilfs_segment_usage *su) 6286e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris{ 6296e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris return !le32_to_cpu(su->su_flags); 6306e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris} 6316e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 6326e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris/** 6336e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * struct nilfs_sufile_header - segment usage file header 6346e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sh_ncleansegs: number of clean segments 6356e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sh_ndirtysegs: number of dirty segments 6366e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris * @sh_last_alloc: last allocated segment number 6376e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris */ 6386e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferrisstruct nilfs_sufile_header { 6396e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 sh_ncleansegs; 6406e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 sh_ndirtysegs; 6416e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris __le64 sh_last_alloc; 6426e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris /* ... */ 6436e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris}; 6446e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 6456e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET \ 6466e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris ((sizeof(struct nilfs_sufile_header) + \ 6476e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris sizeof(struct nilfs_segment_usage) - 1) / \ 6486e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris sizeof(struct nilfs_segment_usage)) 6496e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris 6506e3550f2a1c3909fb75be068f7ae9009f7e8622aChristopher Ferris#endif /* _LINUX_NILFS2_ONDISK_H */ 651