2 * Copyright (c) 2007 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * $DragonFly: src/sys/vfs/hammer/hammer_disk.h,v 1.7 2007/11/20 07:16:28 dillon Exp $
42 * The structures below represent the on-disk format for a HAMMER
43 * filesystem. Note that all fields for on-disk structures are naturally
44 * aligned. The host endian format is used - compatibility is possible
45 * if the implementation detects reversed endian and adjusts data accordingly.
47 * Most of HAMMER revolves around the concept of an object identifier. An
48 * obj_id is a 64 bit quantity which uniquely identifies a filesystem object
49 * FOR THE ENTIRE LIFE OF THE FILESYSTEM. This uniqueness allows backups
50 * and mirrors to retain varying amounts of filesystem history by removing
51 * any possibility of conflict through identifier reuse.
53 * A HAMMER filesystem may spam multiple volumes.
55 * A HAMMER filesystem uses a 16K filesystem buffer size. All filesystem
56 * I/O is done in multiples of 16K. Most buffer-sized headers such as those
57 * used by volumes, super-clusters, clusters, and basic filesystem buffers
58 * use fixed-sized A-lists which are heavily dependant on HAMMER_BUFSIZE.
60 #define HAMMER_BUFSIZE 16384
61 #define HAMMER_BUFMASK (HAMMER_BUFSIZE - 1)
64 * Hammer transction ids are 64 bit unsigned integers and are usually
65 * synchronized with the time of day in nanoseconds.
67 typedef u_int64_t hammer_tid_t;
69 #define HAMMER_MAX_TID 0xFFFFFFFFFFFFFFFFULL
72 * Most HAMMER data structures are embedded in 16K filesystem buffers.
73 * All filesystem buffers except those designated as pure-data buffers
74 * contain this 128-byte header.
76 * This structure contains an embedded A-List used to manage space within
77 * the filesystem buffer. It is not used by volume or cluster header
78 * buffers, or by pure-data buffers. The granularity is variable and
79 * depends on the type of filesystem buffer. BLKSIZE is just a minimum.
82 #define HAMMER_FSBUF_HEAD_SIZE 128
83 #define HAMMER_FSBUF_MAXBLKS 256
84 #define HAMMER_FSBUF_BLKMASK (HAMMER_FSBUF_MAXBLKS - 1)
85 #define HAMMER_FSBUF_METAELMS HAMMER_ALIST_METAELMS_256_1LYR /* 11 */
87 struct hammer_fsbuf_head {
90 u_int32_t buf_reserved07;
91 u_int32_t reserved[6];
92 struct hammer_almeta buf_almeta[HAMMER_FSBUF_METAELMS];
95 typedef struct hammer_fsbuf_head *hammer_fsbuf_head_t;
98 * Note: Pure-data buffers contain pure-data and have no buf_type.
99 * Piecemeal data buffers do have a header and use HAMMER_FSBUF_DATA.
101 #define HAMMER_FSBUF_VOLUME 0xC8414D4DC5523031ULL /* HAMMER01 */
102 #define HAMMER_FSBUF_SUPERCL 0xC8414D52C3555052ULL /* HAMRSUPR */
103 #define HAMMER_FSBUF_CLUSTER 0xC8414D52C34C5553ULL /* HAMRCLUS */
104 #define HAMMER_FSBUF_RECORDS 0xC8414D52D2454353ULL /* HAMRRECS */
105 #define HAMMER_FSBUF_BTREE 0xC8414D52C2545245ULL /* HAMRBTRE */
106 #define HAMMER_FSBUF_DATA 0xC8414D52C4415441ULL /* HAMRDATA */
108 #define HAMMER_FSBUF_VOLUME_REV 0x313052C54D4D41C8ULL /* (reverse endian) */
111 * The B-Tree structures need hammer_fsbuf_head.
113 #include "hammer_btree.h"
116 * HAMMER Volume header
118 * A HAMMER filesystem is built from any number of block devices, Each block
119 * device contains a volume header followed by however many super-clusters
120 * and clusters fit into the volume. Clusters cannot be migrated but the
121 * data they contain can, so HAMMER can use a truncated cluster for any
122 * extra space at the end of the volume.
124 * The volume containing the root cluster is designated as the master volume.
125 * The root cluster designation can be moved to any volume.
127 * The volume header takes up an entire 16K filesystem buffer and includes
128 * a one or two-layered A-list to manage the clusters making up the volume.
129 * A volume containing up to 32768 clusters (2TB) can be managed with a
130 * single-layered A-list. A two-layer A-list is capable of managing up
131 * to 16384 super-clusters with each super-cluster containing 32768 clusters
132 * (32768 TB per volume total). The number of volumes is limited to 32768
133 * but it only takes 512 to fill out a 64 bit address space so for all
134 * intents and purposes the filesystem has no limits.
136 * cluster addressing within a volume depends on whether a single or
137 * duel-layer A-list is used. If a duel-layer A-list is used a 16K
138 * super-cluster buffer is needed for every 16384 clusters in the volume.
139 * However, because the A-list's hinting is grouped in multiples of 16
140 * we group 16 super-cluster buffers together (starting just after the
141 * volume header), followed by 16384x16 clusters, and repeat.
143 * NOTE: A 32768-element single-layer and 16384-element duel-layer A-list
146 * Special field notes:
148 * vol_bot_beg - offset of boot area (mem_beg - bot_beg bytes)
149 * vol_mem_beg - offset of memory log (clu_beg - mem_beg bytes)
150 * vol_clo_beg - offset of cluster #0 in volume
152 * The memory log area allows a kernel to cache new records and data
153 * in memory without allocating space in the actual filesystem to hold
154 * the records and data. In the event that a filesystem becomes full,
155 * any records remaining in memory can be flushed to the memory log
156 * area. This allows the kernel to immediately return success.
158 #define HAMMER_VOL_MAXCLUSTERS 32768 /* 1-layer */
159 #define HAMMER_VOL_MAXSUPERCLUSTERS 16384 /* 2-layer */
160 #define HAMMER_VOL_SUPERCLUSTER_GROUP 16
161 #define HAMMER_VOL_METAELMS_1LYR HAMMER_ALIST_METAELMS_32K_1LYR
162 #define HAMMER_VOL_METAELMS_2LYR HAMMER_ALIST_METAELMS_16K_2LYR
164 #define HAMMER_BOOT_MINBYTES (32*1024)
165 #define HAMMER_BOOT_NOMBYTES (64LL*1024*1024)
166 #define HAMMER_BOOT_MAXBYTES (256LL*1024*1024)
168 #define HAMMER_MEM_MINBYTES (256*1024)
169 #define HAMMER_MEM_NOMBYTES (1LL*1024*1024*1024)
170 #define HAMMER_MEM_MAXBYTES (64LL*1024*1024*1024)
172 struct hammer_volume_ondisk {
173 struct hammer_fsbuf_head head;
174 int64_t vol_bot_beg; /* byte offset of boot area or 0 */
175 int64_t vol_mem_beg; /* byte offset of memory log or 0 */
176 int64_t vol_clo_beg; /* byte offset of first cl/supercl in volume */
177 int64_t vol_clo_end; /* byte offset of volume EOF */
178 int64_t vol_locked; /* reserved clusters are >= this offset */
180 uuid_t vol_fsid; /* identify filesystem */
181 uuid_t vol_fstype; /* identify filesystem type */
182 char vol_name[64]; /* Name of volume */
184 int32_t vol_no; /* volume number within filesystem */
185 int32_t vol_count; /* number of volumes making up FS */
187 u_int32_t vol_version; /* version control information */
188 u_int32_t vol_reserved01;
189 u_int32_t vol_flags; /* volume flags */
190 u_int32_t vol_rootvol; /* which volume is the root volume? */
192 int32_t vol_clsize; /* cluster size (same for all volumes) */
193 int32_t vol_nclusters;
194 u_int32_t vol_reserved06;
195 u_int32_t vol_reserved07;
197 int32_t vol_stat_blocksize; /* for statfs only */
198 int64_t vol_stat_bytes; /* for statfs only */
199 int64_t vol_stat_inodes; /* for statfs only */
202 * These fields are initialized and space is reserved in every
203 * volume making up a HAMMER filesytem, but only the master volume
204 * contains valid data.
206 int32_t vol0_root_clu_no; /* root cluster no (index) in rootvol */
207 hammer_tid_t vol0_root_clu_id; /* root cluster id */
208 hammer_tid_t vol0_nexttid; /* next TID */
209 u_int64_t vol0_recid; /* fs-wide record id allocator */
210 u_int64_t vol0_synchronized_rec_id; /* XXX */
215 * Meta elements for the volume header's A-list, which is either a
216 * 1-layer A-list capable of managing 32768 clusters, or a 2-layer
217 * A-list capable of managing 16384 super-clusters (each of which
218 * can handle 32768 clusters).
221 struct hammer_almeta super[HAMMER_VOL_METAELMS_2LYR];
222 struct hammer_almeta normal[HAMMER_VOL_METAELMS_1LYR];
224 u_int32_t vol0_bitmap[1024];
227 typedef struct hammer_volume_ondisk *hammer_volume_ondisk_t;
229 #define HAMMER_VOLF_VALID 0x0001 /* valid entry */
230 #define HAMMER_VOLF_OPEN 0x0002 /* volume is open */
231 #define HAMMER_VOLF_USINGSUPERCL 0x0004 /* using superclusters */
234 * HAMMER Super-cluster header
236 * A super-cluster is used to increase the maximum size of a volume.
237 * HAMMER's volume header can manage up to 32768 direct clusters or
238 * 16384 super-clusters. Each super-cluster (which is basically just
239 * a 16K filesystem buffer) can manage up to 32768 clusters. So adding
240 * a super-cluster layer allows a HAMMER volume to be sized upwards of
241 * around 32768TB instead of 2TB.
243 * Any volume initially formatted to be over 32G reserves space for the layer
244 * but the layer is only enabled if the volume exceeds 2TB.
246 #define HAMMER_SUPERCL_METAELMS HAMMER_ALIST_METAELMS_32K_1LYR
247 #define HAMMER_SCL_MAXCLUSTERS HAMMER_VOL_MAXCLUSTERS
249 struct hammer_supercl_ondisk {
250 struct hammer_fsbuf_head head;
251 uuid_t vol_fsid; /* identify filesystem - sanity check */
252 uuid_t vol_fstype; /* identify filesystem type - sanity check */
253 int32_t reserved[1024];
255 struct hammer_almeta scl_meta[HAMMER_SUPERCL_METAELMS];
258 typedef struct hammer_supercl_ondisk *hammer_supercl_ondisk_t;
261 * HAMMER Cluster header
263 * A cluster is limited to 64MB and is made up of 4096 16K filesystem
264 * buffers. The cluster header contains four A-lists to manage these
267 * master_alist - This is a non-layered A-list which manages pure-data
268 * allocations and allocations on behalf of other A-lists.
270 * btree_alist - This is a layered A-list which manages filesystem buffers
271 * containing B-Tree nodes.
273 * record_alist - This is a layered A-list which manages filesystem buffers
274 * containing records.
276 * mdata_alist - This is a layered A-list which manages filesystem buffers
277 * containing piecemeal record data.
279 * General storage management works like this: All the A-lists except the
280 * master start in an all-allocated state. Now lets say you wish to allocate
281 * a B-Tree node out the btree_alist. If the allocation fails you allocate
282 * a pure data block out of master_alist and then free that block in
283 * btree_alist, thereby assigning more space to the btree_alist, and then
284 * retry your allocation out of the btree_alist. In the reverse direction,
285 * filesystem buffers can be garbage collected back to master_alist simply
286 * by doing whole-buffer allocations in btree_alist and then freeing the
287 * space in master_alist. The whole-buffer-allocation approach to garbage
288 * collection works because A-list allocations are always power-of-2 sized
291 #define HAMMER_CLU_MAXBUFFERS 4096
292 #define HAMMER_CLU_MASTER_METAELMS HAMMER_ALIST_METAELMS_4K_1LYR
293 #define HAMMER_CLU_SLAVE_METAELMS HAMMER_ALIST_METAELMS_4K_2LYR
294 #define HAMMER_CLU_MAXBYTES (HAMMER_CLU_MAXBUFFERS * HAMMER_BUFSIZE)
296 struct hammer_cluster_ondisk {
297 struct hammer_fsbuf_head head;
298 uuid_t vol_fsid; /* identify filesystem - sanity check */
299 uuid_t vol_fstype; /* identify filesystem type - sanity check */
301 hammer_tid_t clu_id; /* unique cluster self identification */
302 hammer_tid_t clu_gen; /* generation number */
303 int32_t vol_no; /* cluster contained in volume (sanity) */
304 u_int32_t clu_flags; /* cluster flags */
306 int32_t clu_start; /* start of data (byte offset) */
307 int32_t clu_limit; /* end of data (byte offset) */
308 int32_t clu_no; /* cluster index in volume (sanity) */
309 u_int32_t clu_reserved03;
311 u_int32_t clu_reserved04;
312 u_int32_t clu_reserved05;
313 u_int32_t clu_reserved06;
314 u_int32_t clu_reserved07;
316 int32_t idx_data; /* data append point (element no) */
317 int32_t idx_index; /* index append point (element no) */
318 int32_t idx_record; /* record prepend point (element no) */
319 u_int32_t idx_reserved03;
322 * Specify the range of information stored in this cluster as two
323 * btree elements. These elements match the left and right
324 * boundary elements in the internal B-Tree node of the parent
325 * cluster that points to the root of our cluster. Because these
326 * are boundary elements, the right boundary is range-NONinclusive.
328 struct hammer_base_elm clu_btree_beg;
329 struct hammer_base_elm clu_btree_end;
332 * The cluster's B-Tree root can change as a side effect of insertion
333 * and deletion operations so store an offset instead of embedding
334 * the root node. The parent_offset is stale if the generation number
337 * Parent linkages are explicit.
339 int32_t clu_btree_root;
340 int32_t clu_btree_parent_vol_no;
341 int32_t clu_btree_parent_clu_no;
342 int32_t clu_btree_parent_offset;
343 hammer_tid_t clu_btree_parent_clu_gen;
345 u_int64_t synchronized_rec_id;
347 struct hammer_almeta clu_master_meta[HAMMER_CLU_MASTER_METAELMS];
348 struct hammer_almeta clu_btree_meta[HAMMER_CLU_SLAVE_METAELMS];
349 struct hammer_almeta clu_record_meta[HAMMER_CLU_SLAVE_METAELMS];
350 struct hammer_almeta clu_mdata_meta[HAMMER_CLU_SLAVE_METAELMS];
353 typedef struct hammer_cluster_ondisk *hammer_cluster_ondisk_t;
356 * HAMMER records are 96 byte entities encoded into 16K filesystem buffers.
357 * Each record has a 64 byte header and a 32 byte extension. 170 records
358 * fit into each buffer. Storage is managed by the buffer's A-List.
360 * Each record may have an explicit data reference to a block of data up
361 * to 2^31-1 bytes in size within the current cluster. Note that multiple
362 * records may share the same or overlapping data references.
366 * All HAMMER records have a common 64-byte base and a 32-byte extension.
368 * Many HAMMER record types reference out-of-band data within the cluster.
369 * This data can also be stored in-band in the record itself if it is small
370 * enough. Either way, (data_offset, data_len) points to it.
372 * Key comparison order: obj_id, rec_type, key, create_tid
374 struct hammer_base_record {
376 * 40 byte base element info - same base as used in B-Tree internal
377 * and leaf node element arrays.
379 * Fields: obj_id, key, create_tid, delete_tid, rec_type, obj_type,
382 struct hammer_base_elm base; /* 00 base element info */
384 int32_t data_len; /* 28 size of data (remainder zero-fill) */
385 u_int32_t data_crc; /* 2C data sanity check */
386 u_int64_t rec_id; /* 30 record id (iterator for recovery) */
387 int32_t data_offset; /* 38 cluster-relative data reference or 0 */
388 u_int32_t reserved07; /* 3C */
393 * Record types are fairly straightforward. The B-Tree includes the record
394 * type in its index sort.
396 * In particular please note that it is possible to create a pseudo-
397 * filesystem within a HAMMER filesystem by creating a special object
398 * type within a directory. Pseudo-filesystems are used as replication
399 * targets and even though they are built within a HAMMER filesystem they
400 * get their own obj_id space (and thus can serve as a replication target)
401 * and look like a mount point to the system.
403 * Inter-cluster records are special-cased in the B-Tree. These records
404 * are referenced from a B-Tree INTERNAL node, NOT A LEAF. This means
405 * that the element in the B-Tree node is actually a boundary element whos
406 * base element fields, including rec_type, reflect the boundary, NOT
407 * the inter-cluster record type.
409 * HAMMER_RECTYPE_CLUSTER - only set in the actual inter-cluster record,
410 * not set in the left or right boundary elements around the inter-cluster
411 * reference of an internal node in the B-Tree (because doing so would
412 * interfere with the boundary tests).
414 #define HAMMER_RECTYPE_UNKNOWN 0
415 #define HAMMER_RECTYPE_LOWEST 1 /* lowest record type avail */
416 #define HAMMER_RECTYPE_INODE 1 /* inode in obj_id space */
417 #define HAMMER_RECTYPE_PSEUDO_INODE 2 /* pseudo filesysem */
418 #define HAMMER_RECTYPE_CLUSTER 3 /* inter-cluster reference */
419 #define HAMMER_RECTYPE_DATA 0x10
420 #define HAMMER_RECTYPE_DIRENTRY 0x11
421 #define HAMMER_RECTYPE_DB 0x12
422 #define HAMMER_RECTYPE_EXT 0x13 /* ext attributes */
424 #define HAMMER_OBJTYPE_UNKNOWN 0 /* (never exists on-disk) */
425 #define HAMMER_OBJTYPE_DIRECTORY 1
426 #define HAMMER_OBJTYPE_REGFILE 2
427 #define HAMMER_OBJTYPE_DBFILE 3
428 #define HAMMER_OBJTYPE_FIFO 4
429 #define HAMMER_OBJTYPE_CDEV 5
430 #define HAMMER_OBJTYPE_BDEV 6
431 #define HAMMER_OBJTYPE_SOFTLINK 7
432 #define HAMMER_OBJTYPE_PSEUDOFS 8 /* pseudo filesystem obj */
435 * Generic full-sized record
437 struct hammer_generic_record {
438 struct hammer_base_record base;
443 * A HAMMER inode record.
445 * This forms the basis for a filesystem object. obj_id is the inode number,
446 * key1 represents the pseudo filesystem id for security partitioning
447 * (preventing cross-links and/or restricting a NFS export and specifying the
448 * security policy), and key2 represents the data retention policy id.
450 * Inode numbers are 64 bit quantities which uniquely identify a filesystem
451 * object for the ENTIRE life of the filesystem, even after the object has
452 * been deleted. For all intents and purposes inode numbers are simply
453 * allocated by incrementing a sequence space.
455 * There is an important distinction between the data stored in the inode
456 * record and the record's data reference. The record references a
457 * hammer_inode_data structure but the filesystem object size and hard link
458 * count is stored in the inode record itself. This allows multiple inodes
459 * to share the same hammer_inode_data structure. This is possible because
460 * any modifications will lay out new data. The HAMMER implementation need
461 * not use the data-sharing ability when laying down new records.
463 * A HAMMER inode is subject to the same historical storage requirements
464 * as any other record. In particular any change in filesystem or hard link
465 * count will lay down a new inode record when the filesystem is synced to
466 * disk. This can lead to a lot of junk records which get cleaned up by
467 * the data retention policy.
469 * The ino_atime and ino_mtime fields are a special case. Modifications to
470 * these fields do NOT lay down a new record by default, though the values
471 * are effectively frozen for snapshots which access historical versions
472 * of the inode record due to other operations. This means that atime will
473 * not necessarily be accurate in snapshots, backups, or mirrors. mtime
474 * will be accurate in backups and mirrors since it can be regenerated from
475 * the mirroring stream.
477 * Because nlinks is historically retained the hardlink count will be
478 * accurate when accessing a HAMMER filesystem snapshot.
480 struct hammer_inode_record {
481 struct hammer_base_record base;
482 u_int64_t ino_atime; /* last access time (not historical) */
483 u_int64_t ino_mtime; /* last modified time (not historical) */
484 u_int64_t ino_size; /* filesystem object size */
485 u_int64_t ino_nlinks; /* hard links */
489 * Data records specify the entire contents of a regular file object,
490 * including attributes. Small amounts of data can theoretically be
491 * embedded in the record itself but the use of this ability verses using
492 * an out-of-band data reference depends on the implementation.
494 struct hammer_data_record {
495 struct hammer_base_record base;
500 * A directory entry specifies the HAMMER filesystem object id, a copy of
501 * the file type, and file name (either embedded or as out-of-band data).
502 * If the file name is short enough to fit into den_name[] (including a
503 * terminating nul) then it will be embedded in the record, otherwise it
504 * is stored out-of-band. The base record's data reference always points
505 * to the nul-terminated filename regardless.
507 * Directory entries are indexed with a 128 bit namekey rather then an
508 * offset. A portion of the namekey is an iterator or randomizer to deal
511 * Note that base.base.obj_type holds the filesystem object type of obj_id,
512 * e.g. a den_type equivalent.
515 struct hammer_entry_record {
516 struct hammer_base_record base;
517 u_int64_t obj_id; /* object being referenced */
518 u_int64_t reserved01;
519 char den_name[16]; /* short file names fit in record */
523 * Hammer rollup record
525 union hammer_record_ondisk {
526 struct hammer_base_record base;
527 struct hammer_generic_record generic;
528 struct hammer_inode_record inode;
529 struct hammer_data_record data;
530 struct hammer_entry_record entry;
533 typedef union hammer_record_ondisk *hammer_record_ondisk_t;
536 * Filesystem buffer for records
538 #define HAMMER_RECORD_NODES \
539 ((HAMMER_BUFSIZE - sizeof(struct hammer_fsbuf_head)) / \
540 sizeof(union hammer_record_ondisk))
542 struct hammer_fsbuf_recs {
543 struct hammer_fsbuf_head head;
545 union hammer_record_ondisk recs[HAMMER_RECORD_NODES];
549 * Filesystem buffer for piecemeal data. Note that this does not apply
550 * to dedicated pure-data buffers as such buffers do not have a header.
553 #define HAMMER_DATA_SIZE (HAMMER_BUFSIZE - sizeof(struct hammer_fsbuf_head))
554 #define HAMMER_DATA_BLKSIZE 64
555 #define HAMMER_DATA_BLKMASK (HAMMER_DATA_BLKSIZE-1)
556 #define HAMMER_DATA_NODES (HAMMER_DATA_SIZE / HAMMER_DATA_BLKSIZE)
558 struct hammer_fsbuf_data {
559 struct hammer_fsbuf_head head;
560 u_int8_t data[HAMMER_DATA_NODES][HAMMER_DATA_BLKSIZE];
564 * Filesystem buffer rollup
566 union hammer_fsbuf_ondisk {
567 struct hammer_fsbuf_head head;
568 struct hammer_fsbuf_btree btree;
569 struct hammer_fsbuf_recs record;
570 struct hammer_fsbuf_data data;
573 typedef union hammer_fsbuf_ondisk *hammer_fsbuf_ondisk_t;
576 * HAMMER UNIX Attribute data
578 * The data reference in a HAMMER inode record points to this structure. Any
579 * modifications to the contents of this structure will result in a record
580 * replacement operation.
582 * state_sum allows a filesystem object to be validated to a degree by
583 * generating a checksum of all of its pieces (in no particular order) and
584 * checking it against this field.
586 * short_data_off allows a small amount of data to be embedded in the
587 * hammer_inode_data structure. HAMMER typically uses this to represent
588 * up to 64 bytes of data, or to hold symlinks. Remember that allocations
589 * are in powers of 2 so 64, 192, 448, or 960 bytes of embedded data is
590 * support (64+64, 64+192, 64+448 64+960).
592 * parent_obj_id is only valid for directories (which cannot be hard-linked),
593 * and specifies the parent directory obj_id. This field will also be set
594 * for non-directory inodes as a recovery aid, but can wind up specifying
595 * stale information. However, since object id's are not reused, the worse
596 * that happens is that the recovery code is unable to use it.
598 struct hammer_inode_data {
599 u_int16_t version; /* inode data version */
600 u_int16_t mode; /* basic unix permissions */
601 u_int32_t uflags; /* chflags */
602 u_int16_t short_data_off; /* degenerate data case */
603 u_int16_t short_data_len;
606 u_int64_t parent_obj_id;/* parent directory obj_id */
609 /* XXX device, softlink extension */
612 #define HAMMER_INODE_DATA_VERSION 1
615 * Rollup various structures embedded as record data
617 union hammer_data_ondisk {
618 struct hammer_inode_data inode;