1 /* 2 * Copyright (c) 2007 The DragonFly Project. All rights reserved. 3 * 4 * This code is derived from software contributed to The DragonFly Project 5 * by Matthew Dillon <dillon@backplane.com> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 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 16 * distribution. 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. 20 * 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 32 * SUCH DAMAGE. 33 * 34 * $DragonFly: src/sys/vfs/hammer/hammer_disk.h,v 1.2 2007/10/16 18:16:42 dillon Exp $ 35 */ 36 37 #ifndef _SYS_UUID_H_ 38 #include <sys/uuid.h> 39 #endif 40 41 /* 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. 46 * 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. 52 * 53 * A HAMMER filesystem may spam multiple volumes. 54 * 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. 59 */ 60 #define HAMMER_BUFSIZE 16384 61 #define HAMMER_BUFMASK (HAMMER_BUFSIZE - 1) 62 63 /* 64 * Hammer transction ids are 64 bit unsigned integers and are usually 65 * synchronized with the time of day in nanoseconds. 66 */ 67 typedef u_int64_t hammer_tid_t; 68 69 /* 70 * Most HAMMER data structures are embedded in 16K filesystem buffers. 71 * All filesystem buffers except those designated as pure-data buffers 72 * contain this 128-byte header. 73 * 74 * This structure contains an embedded A-List used to manage space within 75 * the filesystem buffer. It is not used by volume or cluster header 76 * buffers, or by pure-data buffers. The granularity is variable and 77 * depends on the type of filesystem buffer. BLKSIZE is just a minimum. 78 */ 79 80 #define HAMMER_FSBUF_HEAD_SIZE 128 81 #define HAMMER_FSBUF_MAXBLKS 256 82 #define HAMMER_FSBUF_BLKMASK (HAMMER_FSBUF_MAXBLKS - 1) 83 #define HAMMER_FSBUF_METAELMS HAMMER_ALIST_METAELMS_256_1LYR /* 11 */ 84 85 struct hammer_fsbuf_head { 86 u_int64_t buf_type; 87 u_int32_t buf_crc; 88 u_int32_t buf_reserved07; 89 u_int32_t reserved[6]; 90 struct hammer_almeta buf_almeta[HAMMER_FSBUF_METAELMS]; 91 }; 92 93 typedef struct hammer_fsbuf_head *hammer_fsbuf_head_t; 94 95 /* 96 * Note: Pure-data buffers contain pure-data and have no buf_type. 97 * Piecemeal data buffers do have a header and use HAMMER_FSBUF_DATA. 98 */ 99 #define HAMMER_FSBUF_VOLUME 0xC8414D4DC5523031ULL /* HAMMER01 */ 100 #define HAMMER_FSBUF_SUPERCL 0xC8414D52C3555052ULL /* HAMRSUPR */ 101 #define HAMMER_FSBUF_CLUSTER 0xC8414D52C34C5553ULL /* HAMRCLUS */ 102 #define HAMMER_FSBUF_RECORDS 0xC8414D52D2454353ULL /* HAMRRECS */ 103 #define HAMMER_FSBUF_BTREE 0xC8414D52C2545245ULL /* HAMRBTRE */ 104 #define HAMMER_FSBUF_DATA 0xC8414D52C4415441ULL /* HAMRDATA */ 105 106 #define HAMMER_FSBUF_VOLUME_REV 0x313052C54D4D41C8ULL /* (reverse endian) */ 107 108 /* 109 * The B-Tree structures need hammer_fsbuf_head. 110 */ 111 #include "hammer_btree.h" 112 113 /* 114 * HAMMER Volume header 115 * 116 * A HAMMER filesystem is built from any number of block devices, Each block 117 * device contains a volume header followed by however many super-clusters 118 * and clusters fit into the volume. Clusters cannot be migrated but the 119 * data they contain can, so HAMMER can use a truncated cluster for any 120 * extra space at the end of the volume. 121 * 122 * The volume containing the root cluster is designated as the master volume. 123 * The root cluster designation can be moved to any volume. 124 * 125 * The volume header takes up an entire 16K filesystem buffer and includes 126 * a one or two-layered A-list to manage the clusters making up the volume. 127 * A volume containing up to 32768 clusters (2TB) can be managed with a 128 * single-layered A-list. A two-layer A-list is capable of managing up 129 * to 16384 super-clusters with each super-cluster containing 32768 clusters 130 * (32768 TB per volume total). The number of volumes is limited to 32768 131 * but it only takes 512 to fill out a 64 bit address space so for all 132 * intents and purposes the filesystem has no limits. 133 * 134 * cluster addressing within a volume depends on whether a single or 135 * duel-layer A-list is used. If a duel-layer A-list is used a 16K 136 * super-cluster buffer is needed for every 16384 clusters in the volume. 137 * However, because the A-list's hinting is grouped in multiples of 16 138 * we group 16 super-cluster buffers together (starting just after the 139 * volume header), followed by 16384x16 clusters, and repeat. 140 * 141 * NOTE: A 32768-element single-layer and 16384-element duel-layer A-list 142 * is the same size. 143 */ 144 #define HAMMER_VOL_MAXCLUSTERS 32768 /* 1-layer */ 145 #define HAMMER_VOL_MAXSUPERCLUSTERS 16384 /* 2-layer */ 146 #define HAMMER_VOL_SUPERCLUSTER_GROUP 16 147 #define HAMMER_VOL_METAELMS_1LYR HAMMER_ALIST_METAELMS_32K_1LYR 148 #define HAMMER_VOL_METAELMS_2LYR HAMMER_ALIST_METAELMS_16K_2LYR 149 150 struct hammer_volume_ondisk { 151 struct hammer_fsbuf_head head; 152 int64_t vol_beg; /* byte offset of first cl/supercl in volume */ 153 int64_t vol_end; /* byte offset of volume EOF */ 154 int64_t vol_locked; /* reserved clusters are >= this offset */ 155 156 uuid_t vol_fsid; /* identify filesystem */ 157 uuid_t vol_fstype; /* identify filesystem type */ 158 char vol_name[64]; /* Name of volume */ 159 160 int32_t vol_no; /* volume number within filesystem */ 161 int32_t vol_count; /* number of volumes making up FS */ 162 163 u_int32_t vol_version; /* version control information */ 164 u_int32_t vol_reserved01; 165 u_int32_t vol_flags; /* volume flags */ 166 u_int32_t vol_rootvol; /* which volume is the root volume? */ 167 168 int32_t vol_clsize; /* cluster size (same for all volumes) */ 169 int32_t vol_nclusters; 170 u_int32_t vol_reserved06; 171 u_int32_t vol_reserved07; 172 173 /* 174 * These fields are initialized and space is reserved in every 175 * volume making up a HAMMER filesytem, but only the master volume 176 * contains valid data. 177 */ 178 int32_t vol0_rootcluster; /* root cluster no (index) in rootvol */ 179 u_int32_t vol0_reserved02; 180 u_int32_t vol0_reserved03; 181 hammer_tid_t vol0_nexttid; /* next TID */ 182 u_int64_t vol0_recid; /* fs-wide record id allocator */ 183 184 char reserved[1024]; 185 186 /* 187 * Meta elements for the volume header's A-list, which is either a 188 * 1-layer A-list capable of managing 32768 clusters, or a 2-layer 189 * A-list capable of managing 16384 super-clusters (each of which 190 * can handle 32768 clusters). 191 */ 192 union { 193 struct hammer_almeta super[HAMMER_VOL_METAELMS_2LYR]; 194 struct hammer_almeta normal[HAMMER_VOL_METAELMS_1LYR]; 195 } vol_almeta; 196 u_int32_t vol0_bitmap[1024]; 197 }; 198 199 #define HAMMER_VOLF_VALID 0x0001 /* valid entry */ 200 #define HAMMER_VOLF_OPEN 0x0002 /* volume is open */ 201 #define HAMMER_VOLF_SUPERCL_ENABLE 0x0004 /* enable supercluster layer */ 202 #define HAMMER_VOLF_SUPERCL_RESERVE 0x0008 /* supercluster layout */ 203 204 /* 205 * HAMMER Super-cluster header 206 * 207 * A super-cluster is used to increase the maximum size of a volume. 208 * HAMMER's volume header can manage up to 32768 direct clusters or 209 * 16384 super-clusters. Each super-cluster (which is basically just 210 * a 16K filesystem buffer) can manage up to 32768 clusters. So adding 211 * a super-cluster layer allows a HAMMER volume to be sized upwards of 212 * around 32768TB instead of 2TB. 213 * 214 * Any volume initially formatted to be over 32G reserves space for the layer 215 * but the layer is only enabled if the volume exceeds 2TB. 216 */ 217 #define HAMMER_SUPERCL_METAELMS HAMMER_ALIST_METAELMS_32K_1LYR 218 #define HAMMER_SCL_MAXCLUSTERS HAMMER_VOL_MAXCLUSTERS 219 220 struct hammer_supercl_ondisk { 221 struct hammer_fsbuf_head head; 222 uuid_t vol_fsid; /* identify filesystem - sanity check */ 223 uuid_t vol_fstype; /* identify filesystem type - sanity check */ 224 int32_t reserved[1024]; 225 226 struct hammer_almeta scl_meta[HAMMER_SUPERCL_METAELMS]; 227 }; 228 229 /* 230 * HAMMER Cluster header 231 * 232 * A cluster is limited to 64MB and is made up of 4096 16K filesystem 233 * buffers. The cluster header contains four A-lists to manage these 234 * buffers. 235 * 236 * master_alist - This is a non-layered A-list which manages pure-data 237 * allocations and allocations on behalf of other A-lists. 238 * 239 * btree_alist - This is a layered A-list which manages filesystem buffers 240 * containing B-Tree nodes. 241 * 242 * record_alist - This is a layered A-list which manages filesystem buffers 243 * containing records. 244 * 245 * mdata_alist - This is a layered A-list which manages filesystem buffers 246 * containing piecemeal record data. 247 * 248 * General storage management works like this: All the A-lists except the 249 * master start in an all-allocated state. Now lets say you wish to allocate 250 * a B-Tree node out the btree_alist. If the allocation fails you allocate 251 * a pure data block out of master_alist and then free that block in 252 * btree_alist, thereby assigning more space to the btree_alist, and then 253 * retry your allocation out of the btree_alist. In the reverse direction, 254 * filesystem buffers can be garbage collected back to master_alist simply 255 * by doing whole-buffer allocations in btree_alist and then freeing the 256 * space in master_alist. The whole-buffer-allocation approach to garbage 257 * collection works because A-list allocations are always power-of-2 sized 258 * and aligned. 259 */ 260 #define HAMMER_CLU_MAXBUFFERS 4096 261 #define HAMMER_CLU_MASTER_METAELMS HAMMER_ALIST_METAELMS_4K_1LYR 262 #define HAMMER_CLU_SLAVE_METAELMS HAMMER_ALIST_METAELMS_4K_2LYR 263 #define HAMMER_CLU_MAXBYTES (HAMMER_CLU_MAXBUFFERS * HAMMER_BUFSIZE) 264 265 struct hammer_cluster_ondisk { 266 struct hammer_fsbuf_head head; 267 uuid_t vol_fsid; /* identify filesystem - sanity check */ 268 uuid_t vol_fstype; /* identify filesystem type - sanity check */ 269 270 u_int64_t clu_gen; /* identify generation number of cluster */ 271 u_int64_t clu_unused01; 272 273 hammer_tid_t clu_id; /* unique cluster self identification */ 274 int32_t vol_no; /* cluster contained in volume (sanity) */ 275 u_int32_t clu_flags; /* cluster flags */ 276 277 int32_t clu_start; /* start of data (byte offset) */ 278 int32_t clu_limit; /* end of data (byte offset) */ 279 int32_t clu_no; /* cluster index in volume (sanity) */ 280 u_int32_t clu_reserved03; 281 282 u_int32_t clu_reserved04; 283 u_int32_t clu_reserved05; 284 u_int32_t clu_reserved06; 285 u_int32_t clu_reserved07; 286 287 int32_t idx_data; /* data append point (element no) */ 288 int32_t idx_index; /* index append point (element no) */ 289 int32_t idx_record; /* record prepend point (element no) */ 290 u_int32_t idx_reserved03; 291 292 /* 293 * Specify the range of information stored in this cluster as two 294 * btree elements. These elements exist as separate records that 295 * point to us in the parent cluster's B-Tree. 296 * 297 * Note that clu_btree_end is range-inclusive, not range-exclusive. 298 * i.e. 0-1023 instead of 0,1024. 299 */ 300 struct hammer_base_elm clu_btree_beg; 301 struct hammer_base_elm clu_btree_end; 302 303 /* 304 * The cluster's B-Tree root can change as a side effect of insertion 305 * and deletion operations so store an offset instead of embedding 306 * the root node. 307 */ 308 int32_t clu_btree_root; 309 int32_t clu_btree_parent_vol_no; 310 int32_t clu_btree_parent_clu_no; 311 hammer_tid_t clu_btree_parent_clu_id; 312 313 u_int64_t synchronized_rec_id; 314 315 struct hammer_almeta clu_master_meta[HAMMER_CLU_MASTER_METAELMS]; 316 struct hammer_almeta clu_btree_meta[HAMMER_CLU_SLAVE_METAELMS]; 317 struct hammer_almeta clu_record_meta[HAMMER_CLU_SLAVE_METAELMS]; 318 struct hammer_almeta clu_mdata_meta[HAMMER_CLU_SLAVE_METAELMS]; 319 }; 320 321 /* 322 * HAMMER records are 96 byte entities encoded into 16K filesystem buffers. 323 * Each record has a 64 byte header and a 32 byte extension. 170 records 324 * fit into each buffer. Storage is managed by the buffer's A-List. 325 * 326 * Each record may have an explicit data reference to a block of data up 327 * to 2^31-1 bytes in size within the current cluster. Note that multiple 328 * records may share the same or overlapping data references. 329 */ 330 331 /* 332 * All HAMMER records have a common 64-byte base and a 32-byte extension. 333 * 334 * Many HAMMER record types reference out-of-band data within the cluster. 335 * This data can also be stored in-band in the record itself if it is small 336 * enough. Either way, (data_offset, data_len) points to it. 337 * 338 * Key comparison order: obj_id, rec_type, key, create_tid 339 */ 340 struct hammer_base_record { 341 int64_t obj_id; /* 00 object record is associated with */ 342 int64_t key; /* 08 indexing key (offset or namekey) */ 343 344 hammer_tid_t create_tid;/* 10 transaction id for record creation */ 345 hammer_tid_t delete_tid;/* 18 transaction id for record update/delete */ 346 347 u_int16_t rec_type; /* 20 type of record */ 348 u_int16_t obj_type; /* 22 type of object (if inode) */ 349 u_int32_t data_offset; /* 24 intra-cluster data reference */ 350 /* An offset of 0 indicates zero-fill */ 351 int32_t data_len; /* 28 size of data (remainder zero-fill) */ 352 u_int32_t data_crc; /* 2C data sanity check */ 353 u_int64_t rec_id; /* 30 record id (iterator for recovery) */ 354 u_int64_t reserved07; /* 38 */ 355 /* 40 */ 356 }; 357 358 /* 359 * Record types are fairly straightforward. The B-Tree includes the record 360 * type in its index sort. 361 * 362 * In particular please note that it is possible to create a pseudo- 363 * filesystem within a HAMMER filesystem by creating a special object 364 * type within a directory. Pseudo-filesystems are used as replication 365 * targets and even though they are built within a HAMMER filesystem they 366 * get their own obj_id space (and thus can serve as a replication target) 367 * and look like a mount point to the system. 368 */ 369 #define HAMMER_RECTYPE_UNKNOWN 0 370 #define HAMMER_RECTYPE_INODE 1 /* inode in obj_id space */ 371 #define HAMMER_RECTYPE_PSEUDO_INODE 2 /* pseudo filesysem */ 372 #define HAMMER_RECTYPE_DATA_CREATE 0x10 373 #define HAMMER_RECTYPE_DATA_ZEROFILL 0x11 374 #define HAMMER_RECTYPE_DATA_DELETE 0x12 375 #define HAMMER_RECTYPE_DATA_UPDATE 0x13 376 #define HAMMER_RECTYPE_DIR_CREATE 0x20 377 #define HAMMER_RECTYPE_DIR_DELETE 0x22 378 #define HAMMER_RECTYPE_DIR_UPDATE 0x23 379 #define HAMMER_RECTYPE_DB_CREATE 0x30 380 #define HAMMER_RECTYPE_DB_DELETE 0x32 381 #define HAMMER_RECTYPE_DB_UPDATE 0x33 382 #define HAMMER_RECTYPE_EXT_CREATE 0x40 /* ext attributes */ 383 #define HAMMER_RECTYPE_EXT_DELETE 0x42 384 #define HAMMER_RECTYPE_EXT_UPDATE 0x43 385 386 #define HAMMER_OBJTYPE_DIRECTORY 1 387 #define HAMMER_OBJTYPE_REGFILE 2 388 #define HAMMER_OBJTYPE_DBFILE 3 389 #define HAMMER_OBJTYPE_FIFO 4 390 #define HAMMER_OBJTYPE_CDEV 5 391 #define HAMMER_OBJTYPE_BDEV 6 392 #define HAMMER_OBJTYPE_SOFTLINK 7 393 #define HAMMER_OBJTYPE_PSEUDOFS 8 /* pseudo filesystem obj */ 394 395 #define HAMMER_OBJTYPE_CLUSTER_BEG 0x10 396 #define HAMMER_OBJTYPE_CLUSTER_END 0x11 397 398 /* 399 * Generic full-sized record 400 */ 401 struct hammer_generic_record { 402 struct hammer_base_record base; 403 char filler[32]; 404 }; 405 406 /* 407 * A HAMMER inode record. 408 * 409 * This forms the basis for a filesystem object. obj_id is the inode number, 410 * key1 represents the pseudo filesystem id for security partitioning 411 * (preventing cross-links and/or restricting a NFS export and specifying the 412 * security policy), and key2 represents the data retention policy id. 413 * 414 * Inode numbers are 64 bit quantities which uniquely identify a filesystem 415 * object for the ENTIRE life of the filesystem, even after the object has 416 * been deleted. For all intents and purposes inode numbers are simply 417 * allocated by incrementing a sequence space. 418 * 419 * There is an important distinction between the data stored in the inode 420 * record and the record's data reference. The record references a 421 * hammer_inode_data structure but the filesystem object size and hard link 422 * count is stored in the inode record itself. This allows multiple inodes 423 * to share the same hammer_inode_data structure. This is possible because 424 * any modifications will lay out new data. The HAMMER implementation need 425 * not use the data-sharing ability when laying down new records. 426 * 427 * A HAMMER inode is subject to the same historical storage requirements 428 * as any other record. In particular any change in filesystem or hard link 429 * count will lay down a new inode record when the filesystem is synced to 430 * disk. This can lead to a lot of junk records which get cleaned up by 431 * the data retention policy. 432 * 433 * The ino_atime and ino_mtime fields are a special case. Modifications to 434 * these fields do NOT lay down a new record by default, though the values 435 * are effectively frozen for snapshots which access historical versions 436 * of the inode record due to other operations. This means that atime will 437 * not necessarily be accurate in snapshots, backups, or mirrors. mtime 438 * will be accurate in backups and mirrors since it can be regenerated from 439 * the mirroring stream. 440 * 441 * Because nlinks is historically retained the hardlink count will be 442 * accurate when accessing a HAMMER filesystem snapshot. 443 */ 444 struct hammer_inode_record { 445 struct hammer_base_record base; 446 u_int64_t ino_atime; /* last access time (not historical) */ 447 u_int64_t ino_mtime; /* last modified time (not historical) */ 448 u_int64_t ino_size; /* filesystem object size */ 449 u_int64_t ino_nlinks; /* hard links */ 450 }; 451 452 /* 453 * Data records specify the entire contents of a regular file object, 454 * including attributes. Small amounts of data can theoretically be 455 * embedded in the record itself but the use of this ability verses using 456 * an out-of-band data reference depends on the implementation. 457 */ 458 struct hammer_data_record { 459 struct hammer_base_record base; 460 char filler[32]; 461 }; 462 463 /* 464 * A directory entry specifies the HAMMER filesystem object id, a copy of 465 * the file type, and file name (either embedded or as out-of-band data). 466 * If the file name is short enough to fit into den_name[] (including a 467 * terminating nul) then it will be embedded in the record, otherwise it 468 * is stored out-of-band. The base record's data reference always points 469 * to the nul-terminated filename regardless. 470 * 471 * Directory entries are indexed with a 128 bit namekey rather then an 472 * offset. A portion of the namekey is an iterator or randomizer to deal 473 * with collisions. 474 */ 475 struct hammer_entry_record { 476 struct hammer_base_record base; 477 u_int64_t obj_id; /* object being referenced */ 478 u_int64_t reserved01; 479 u_int8_t den_type; /* cached file type */ 480 char den_name[15]; /* short file names fit in record */ 481 }; 482 483 /* 484 * Hammer rollup record 485 */ 486 union hammer_record_ondisk { 487 struct hammer_base_record base; 488 struct hammer_generic_record generic; 489 struct hammer_inode_record inode; 490 struct hammer_data_record data; 491 struct hammer_entry_record entry; 492 }; 493 494 typedef union hammer_record_ondisk *hammer_record_ondisk_t; 495 496 /* 497 * Filesystem buffer for records 498 */ 499 #define HAMMER_RECORD_NODES \ 500 ((HAMMER_BUFSIZE - sizeof(struct hammer_fsbuf_head)) / \ 501 sizeof(union hammer_record_ondisk)) 502 503 struct hammer_fsbuf_recs { 504 struct hammer_fsbuf_head head; 505 char unused[32]; 506 union hammer_record_ondisk recs[HAMMER_RECORD_NODES]; 507 }; 508 509 /* 510 * Filesystem buffer for piecemeal data. Note that this does not apply 511 * to dedicated pure-data buffers as such buffers do not have a header. 512 */ 513 514 #define HAMMER_DATA_SIZE (HAMMER_BUFSIZE - sizeof(struct hammer_fsbuf_head)) 515 #define HAMMER_DATA_BLKSIZE 64 516 #define HAMMER_DATA_BLKMASK (HAMMER_DATA_BLKSIZE-1) 517 #define HAMMER_DATA_NODES (HAMMER_DATA_SIZE / HAMMER_DATA_BLKSIZE) 518 519 struct hammer_fsbuf_data { 520 struct hammer_fsbuf_head head; 521 u_int8_t data[HAMMER_DATA_NODES][HAMMER_DATA_BLKSIZE]; 522 }; 523 524 /* 525 * Filesystem buffer rollup 526 */ 527 union hammer_fsbuf_ondisk { 528 struct hammer_fsbuf_head head; 529 struct hammer_fsbuf_btree btree; 530 struct hammer_fsbuf_recs record; 531 struct hammer_fsbuf_data data; 532 }; 533 534 typedef union hammer_fsbuf_ondisk *hammer_fsbuf_ondisk_t; 535 536 /* 537 * HAMMER UNIX Attribute data 538 * 539 * The data reference in a HAMMER inode record points to this structure. Any 540 * modifications to the contents of this structure will result in a record 541 * replacement operation. 542 * 543 * state_sum allows a filesystem object to be validated to a degree by 544 * generating a checksum of all of its pieces (in no particular order) and 545 * checking it against this field. 546 */ 547 struct hammer_inode_data { 548 u_int16_t version; /* inode data version */ 549 u_int16_t mode; /* basic unix permissions */ 550 u_int32_t uflags; /* chflags */ 551 u_int64_t reserved01; 552 u_int64_t reserved02; 553 u_int64_t state_sum; /* cumulative checksum */ 554 uuid_t uid; 555 uuid_t gid; 556 }; 557 558 #define HAMMER_INODE_DATA_VERSION 1 559 560 /* 561 * Rollup various structures embedded as record data 562 */ 563 union hammer_data { 564 struct hammer_inode_data inode; 565 }; 566 567