3 * Copyright (C) 2005-2009
4 * Neil Brown <neilb@suse.de>
5 * Released under the GPL, version 2
7 * layout of device superblock
8 * and array state block
11 /* All multibyte numerical values are in little-endian order
14 /* The "superblock" describes a particular device in the filesystem.
15 * different devices have different superblocks.
18 char idtag[16]; /* LaFS-DeviceBlock */
19 char version[16]; /* number space options */
25 u64 start, size; /* in array address space (array block)*/
26 u64 devaddr[2]; /* (device byte) one at each "end" */
27 u64 stateaddr[4]; /* (device byte) 4 state blocks, two at each end */
29 u8 statebits; /* log of size of stateblock - normally 10-14 */
30 u8 blockbits; /* bits in fs block (byte)- 9 - 16 */
31 u16 width; /* devices in array - 1 to a few hundred */
32 u32 stride; /* Blocks in a stride - 1 to a very large number */
33 u32 segment_size; /* blocks in a segment (block) */
34 u32 segment_offset; /* offset of first segment (device byte) */
36 u32 usage_inum; /* inum of segment usage file */
38 } __attribute__((packed));
39 #define LAFS_DEVBLK_SIZE 1024
42 char idtag[16]; /* LaFS-State-Block */
43 char version[16]; /* number space options */
49 u32 nonlog_segment; /* segment number and */
50 u16 nonlog_dev; /* device number of active non-logged segment */
51 u16 nonlog_offset; /* offset into above segment of next non-logged
58 u64 checkpointcluster; /* (array block) */
59 u64 root_inodes[0]; /* (array block) */
60 } __attribute__((packed));
63 u32 block_num; /* (file block) */
64 u16 block_cnt; /* int */
65 u16 block_bytes; /* 0..blocksize - 0 means 'punch a hole',
66 * 1..blocksize means advance EOF to there
68 } __attribute__((packed));
70 #define DescIndex 0xffff
71 #define DescMiniOffset 0x8000
73 #define ROUND_UP(x) (((x)+3)&~3)
76 u32 block_num; /* (file block) */
77 u16 block_offset; /* (byte) */
78 u16 length; /* (bytes) + 0x8000 */
80 } __attribute__((packed));
85 u16 truncatenum_and_flag;
86 u16 group_size_words; /* 4byte words */
88 struct descriptor desc[0];
89 struct miniblock mb[0];
91 } __attribute__((packed));
94 char idtag[8]; /* LaFSHead */
98 u16 Hlength; /* header length - (bytes) */
99 u16 Clength; /* cluster length including header - (blocks) */
100 u32 checksum; /* over Hlength bytes */
104 u64 next_addr; /* (Array block) */
105 u64 this_addr; /* (array block) */
106 u64 prev_addr; /* (array block) */
107 struct group_head groups[0];
108 } __attribute__((packed));
110 #define CH_Checkpoint 1
111 #define CH_CheckpointStart 2
112 #define CH_CheckpointEnd 4
114 /* values for verify_type */
115 #define VerifyNull 0 /* if you found me, I'm valid */
116 #define VerifyNext 1 /* if next head is valid, this cluster is */
117 #define VerifyNext2 2 /* if next 2 heads are valid, this cluster is */
118 #define VerifySum 3 /* maybe some sort of MIC is in _data */
121 /* 16 bytes is constant */
122 u32 data_blocks; /* (blocks) */
123 u32 index_blocks; /* (blocks) */
125 u16 metadata_size; /* (bytes) */
130 #define File_nonlogged 1
133 /* 52 bytes plus name. */
135 u64 blocks_used; /* data+index */
140 u16 snapshot_usage_table;
142 char name[0]; /* variable size, nul padded, but
143 * not necessarily nul terminated */
145 struct inodemap_metadata {
149 u32 table_size; /* (blocks) */
151 struct file_metadata {
166 } __attribute__((packed)) file;
167 struct dir_metadata {
168 struct file_metadata h;
172 struct special_metadata {
173 struct file_metadata h;
178 struct quota_metadata {
179 u32 gracetime; /* typically '7' */
180 u32 graceunits; /* typically 24*60*60 */
183 } __attribute__((packed));
185 #define LAFS_INODE_LOG_START offsetof(struct la_inode, metadata[0].file.flags)
186 #define LAFS_INODE_LOG_END offsetof(struct la_inode, metadata[0].file.size)
187 #define LAFS_INODE_LOG_SIZE (LAFS_INODE_LOG_END - LAFS_INODE_LOG_START)
189 #define TypeInodeFile 1
190 #define TypeInodeMap 2
191 #define TypeSegmentMap 3
193 #define TypeOrphanList 5
194 #define TypeAccessTime 6
200 #define TypeSymlink 18
201 #define TypeSpecial 19 /* char or block, or pipe or socket */
204 #define LAFS_MAX_LINKS ((1UL<<31)-1)
210 } __attribute__((packed));
217 } __attribute__((packed));
218 #define IBLK_INDEX (0)
219 #define IBLK_INDIRECT (1)
220 #define IBLK_EXTENT (2)
222 #define MaxDirHash 0x7fffffffUL
224 u32 target; /* inode number */
225 u8 next[2]; /* back, fore */
226 u8 type:4, chain_info:2, longer:2;
227 /* 'longer' is 3 if fore and back the same length
228 * 0 if back (next[0]) is longer
229 * 1 if fore (next[1]) is longer
231 * 0,1: add that number to the hash of filename
232 * 2 : add one trailing byte to hash
233 * 3 : add 4 trailing bytes (little-endian) to hash
238 } __attribute__((packed));
240 #define NoBlock (0xFFFFFFFF)
246 } __attribute__((packed));
249 * Miniblock for directory updates record the operation type
250 * in the block_offset
253 #define DIROP_UNLINK 1
254 #define DIROP_REN_SOURCE 2
255 #define DIROP_REN_NEW_TARGET 3
256 #define DIROP_REN_OLD_TARGET 4
259 * The orphan file has a very simple structure with
260 * 16 byte records identifying blocks in files that
264 u32 type; /* 0 if free */
268 } __attribute__((packed));
270 /* Youth values are decayed when nextyouth gets too big */
271 static int inline decay_youth(int y)
281 /* This is only called on large youth values */
282 static int inline decay_undo(int y)