-
Notifications
You must be signed in to change notification settings - Fork 0
/
hammer2_disk.h
1300 lines (1187 loc) · 50.3 KB
/
hammer2_disk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2011-2014 The DragonFly Project. All rights reserved.
*
* This code is derived from software contributed to The DragonFly Project
* by Matthew Dillon <dillon@dragonflybsd.org>
* by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of The DragonFly Project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific, prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* The structures below represent the on-disk media structures for the HAMMER2
* filesystem. Note that all fields for on-disk structures are naturally
* aligned. The host endian format is typically used - compatibility is
* possible if the implementation detects reversed endian and adjusts accesses
* accordingly.
*
* HAMMER2 primarily revolves around the directory topology: inodes,
* directory entries, and block tables. Block device buffer cache buffers
* are always 64KB. Logical file buffers are typically 16KB. All data
* references utilize 64-bit byte offsets.
*
* Free block management is handled independently using blocks reserved by
* the media topology.
*/
/*
* The data at the end of a file or directory may be a fragment in order
* to optimize storage efficiency. The minimum fragment size is 1KB.
* Since allocations are in powers of 2 fragments must also be sized in
* powers of 2 (1024, 2048, ... 65536).
*
* For the moment the maximum allocation size is HAMMER2_PBUFSIZE (64K),
* which is 2^16. Larger extents may be supported in the future. Smaller
* fragments might be supported in the future (down to 64 bytes is possible),
* but probably will not be.
*
* A full indirect block use supports 512 x 128-byte blockrefs in a 64KB
* buffer. Indirect blocks down to 1KB are supported to keep small
* directories small.
*
* A maximally sized file (2^64-1 bytes) requires ~6 indirect block levels
* using 64KB indirect blocks (128 byte refs, 512 or radix 9 per indblk).
*
* 16(datablk) + 9 + 9 + 9 + 9 + 9 + 9 = ~70.
* 16(datablk) + 7 + 9 + 9 + 9 + 9 + 9 = ~68. (smaller top level indblk)
*
* The actual depth depends on copies redundancy and whether the filesystem
* has chosen to use a smaller indirect block size at the top level or not.
*/
#define HAMMER2_ALLOC_MIN 1024 /* minimum allocation size */
#define HAMMER2_RADIX_MIN 10 /* minimum allocation size 2^N */
#define HAMMER2_ALLOC_MAX 65536 /* maximum allocation size */
#define HAMMER2_RADIX_MAX 16 /* maximum allocation size 2^N */
#define HAMMER2_RADIX_KEY 64 /* number of bits in key */
/*
* MINALLOCSIZE - The minimum allocation size. This can be smaller
* or larger than the minimum physical IO size.
*
* NOTE: Should not be larger than 1K since inodes
* are 1K.
*
* MINIOSIZE - The minimum IO size. This must be less than
* or equal to HAMMER2_LBUFSIZE.
*
* HAMMER2_LBUFSIZE - Nominal buffer size for I/O rollups.
*
* HAMMER2_PBUFSIZE - Topological block size used by files for all
* blocks except the block straddling EOF.
*
* HAMMER2_SEGSIZE - Allocation map segment size, typically 2MB
* (space represented by a level0 bitmap).
*/
#define HAMMER2_SEGSIZE (1 << HAMMER2_FREEMAP_LEVEL0_RADIX)
#define HAMMER2_SEGRADIX HAMMER2_FREEMAP_LEVEL0_RADIX
#define HAMMER2_PBUFRADIX 16 /* physical buf (1<<16) bytes */
#define HAMMER2_PBUFSIZE 65536
#define HAMMER2_LBUFRADIX 14 /* logical buf (1<<14) bytes */
#define HAMMER2_LBUFSIZE 16384
/*
* Generally speaking we want to use 16K and 64K I/Os
*/
#define HAMMER2_MINIORADIX HAMMER2_LBUFRADIX
#define HAMMER2_MINIOSIZE HAMMER2_LBUFSIZE
#define HAMMER2_IND_BYTES_MIN 4096
#define HAMMER2_IND_BYTES_NOM HAMMER2_LBUFSIZE
#define HAMMER2_IND_BYTES_MAX HAMMER2_PBUFSIZE
#define HAMMER2_IND_RADIX_MIN 12
#define HAMMER2_IND_RADIX_NOM HAMMER2_LBUFRADIX
#define HAMMER2_IND_RADIX_MAX HAMMER2_PBUFRADIX
#define HAMMER2_IND_COUNT_MIN (HAMMER2_IND_BYTES_MIN / \
sizeof(hammer2_blockref_t))
#define HAMMER2_IND_COUNT_MAX (HAMMER2_IND_BYTES_MAX / \
sizeof(hammer2_blockref_t))
/*
* In HAMMER2, arrays of blockrefs are fully set-associative, meaning that
* any element can occur at any index and holes can be anywhere. As a
* future optimization we will be able to flag that such arrays are sorted
* and thus optimize lookups, but for now we don't.
*
* Inodes embed either 512 bytes of direct data or an array of 8 blockrefs,
* resulting in highly efficient storage for files <= 512 bytes and for files
* <= 512KB. Up to 8 directory entries can be referenced from a directory
* without requiring an indirect block.
*
* Indirect blocks are typically either 4KB (64 blockrefs / ~4MB represented),
* or 64KB (1024 blockrefs / ~64MB represented).
*/
#define HAMMER2_SET_RADIX 2 /* radix 2 = 4 entries */
#define HAMMER2_SET_COUNT (1 << HAMMER2_SET_RADIX)
#define HAMMER2_EMBEDDED_BYTES 512 /* inode blockset/dd size */
#define HAMMER2_EMBEDDED_RADIX 9
#define HAMMER2_PBUFMASK (HAMMER2_PBUFSIZE - 1)
#define HAMMER2_LBUFMASK (HAMMER2_LBUFSIZE - 1)
#define HAMMER2_SEGMASK (HAMMER2_SEGSIZE - 1)
#define HAMMER2_LBUFMASK64 ((hammer2_off_t)HAMMER2_LBUFMASK)
#define HAMMER2_PBUFSIZE64 ((hammer2_off_t)HAMMER2_PBUFSIZE)
#define HAMMER2_PBUFMASK64 ((hammer2_off_t)HAMMER2_PBUFMASK)
#define HAMMER2_SEGSIZE64 ((hammer2_off_t)HAMMER2_SEGSIZE)
#define HAMMER2_SEGMASK64 ((hammer2_off_t)HAMMER2_SEGMASK)
#define HAMMER2_UUID_STRING "5cbb9ad1-862d-11dc-a94d-01301bb8a9f5"
/*
* A HAMMER2 filesystem is always sized in multiples of 8MB.
*
* A 4MB segment is reserved at the beginning of each 2GB zone. This segment
* contains the volume header (or backup volume header), the free block
* table, and possibly other information in the future.
*
* 4MB = 64 x 64K blocks. Each 4MB segment is broken down as follows:
*
* +-----------------------+
* | Volume Hdr | block 0 volume header & alternates
* +-----------------------+ (first four zones only)
* | FreeBlk Section A | block 1-4
* +-----------------------+
* | FreeBlk Section B | block 5-8
* +-----------------------+
* | FreeBlk Section C | block 9-12
* +-----------------------+
* | FreeBlk Section D | block 13-16
* +-----------------------+
* | | block 17...63
* | reserved |
* | |
* +-----------------------+
*
* The first few 2GB zones contain volume headers and volume header backups.
* After that the volume header block# is reserved for future use. Similarly,
* there are many blocks related to various Freemap levels which are not
* used in every segment and those are also reserved for future use.
*
* Freemap (see the FREEMAP document)
*
* The freemap utilizes blocks #1-16 in 8 sets of 4 blocks. Each block in
* a set represents a level of depth in the freemap topology. Eight sets
* exist to prevent live updates from disturbing the state of the freemap
* were a crash/reboot to occur. That is, a live update is not committed
* until the update's flush reaches the volume root. There are FOUR volume
* roots representing the last four synchronization points, so the freemap
* must be consistent no matter which volume root is chosen by the mount
* code.
*
* Each freemap set is 4 x 64K blocks and represents the 2GB, 2TB, 2PB,
* and 2EB indirect map. The volume header itself has a set of 8 freemap
* blockrefs representing another 3 bits, giving us a total 64 bits of
* representable address space.
*
* The Level 0 64KB block represents 2GB of storage represented by
* (64 x struct hammer2_bmap_data). Each structure represents 2MB of storage
* and has a 256 bit bitmap, using 2 bits to represent a 16KB chunk of
* storage. These 2 bits represent the following states:
*
* 00 Free
* 01 (reserved) (Possibly partially allocated)
* 10 Possibly free
* 11 Allocated
*
* One important thing to note here is that the freemap resolution is 16KB,
* but the minimum storage allocation size is 1KB. The hammer2 vfs keeps
* track of sub-allocations in memory, which means that on a unmount or reboot
* the entire 16KB of a partially allocated block will be considered fully
* allocated. It is possible for fragmentation to build up over time, but
* defragmentation is fairly easy to accomplish since all modifications
* allocate a new block.
*
* The Second thing to note is that due to the way snapshots and inode
* replication works, deleting a file cannot immediately free the related
* space. Furthermore, deletions often do not bother to traverse the
* block subhierarchy being deleted. And to go even further, whole
* sub-directory trees can be deleted simply by deleting the directory inode
* at the top. So even though we have a symbol to represent a 'possibly free'
* block (binary 10), only the bulk free scanning code can actually use it.
* Normal 'rm's or other deletions do not.
*
* WARNING! ZONE_SEG and VOLUME_ALIGN must be a multiple of 1<<LEVEL0_RADIX
* (i.e. a multiple of 2MB). VOLUME_ALIGN must be >= ZONE_SEG.
*
* In Summary:
*
* (1) Modifications to freemap blocks 'allocate' a new copy (aka use a block
* from the next set). The new copy is reused until a flush occurs at
* which point the next modification will then rotate to the next set.
*
* (2) A total of 10 freemap sets is required.
*
* - 8 sets - 2 sets per volume header backup x 4 volume header backups
* - 2 sets used as backing store for the bulk freemap scan.
* - The freemap recovery scan which runs on-mount just uses the inactive
* set for whichever volume header was selected by the mount code.
*
*/
#define HAMMER2_VOLUME_ALIGN (8 * 1024 * 1024)
#define HAMMER2_VOLUME_ALIGN64 ((hammer2_off_t)HAMMER2_VOLUME_ALIGN)
#define HAMMER2_VOLUME_ALIGNMASK (HAMMER2_VOLUME_ALIGN - 1)
#define HAMMER2_VOLUME_ALIGNMASK64 ((hammer2_off_t)HAMMER2_VOLUME_ALIGNMASK)
#define HAMMER2_NEWFS_ALIGN (HAMMER2_VOLUME_ALIGN)
#define HAMMER2_NEWFS_ALIGN64 ((hammer2_off_t)HAMMER2_VOLUME_ALIGN)
#define HAMMER2_NEWFS_ALIGNMASK (HAMMER2_VOLUME_ALIGN - 1)
#define HAMMER2_NEWFS_ALIGNMASK64 ((hammer2_off_t)HAMMER2_NEWFS_ALIGNMASK)
#define HAMMER2_ZONE_BYTES64 (2LLU * 1024 * 1024 * 1024)
#define HAMMER2_ZONE_MASK64 (HAMMER2_ZONE_BYTES64 - 1)
#define HAMMER2_ZONE_SEG (4 * 1024 * 1024)
#define HAMMER2_ZONE_SEG64 ((hammer2_off_t)HAMMER2_ZONE_SEG)
#define HAMMER2_ZONE_BLOCKS_SEG (HAMMER2_ZONE_SEG / HAMMER2_PBUFSIZE)
#define HAMMER2_ZONE_FREEMAP_INC 5 /* 5 deep */
#define HAMMER2_ZONE_VOLHDR 0 /* volume header or backup */
#define HAMMER2_ZONE_FREEMAP_00 1 /* normal freemap rotation */
#define HAMMER2_ZONE_FREEMAP_01 6 /* normal freemap rotation */
#define HAMMER2_ZONE_FREEMAP_02 11 /* normal freemap rotation */
#define HAMMER2_ZONE_FREEMAP_03 16 /* normal freemap rotation */
#define HAMMER2_ZONE_FREEMAP_04 21 /* normal freemap rotation */
#define HAMMER2_ZONE_FREEMAP_05 26 /* normal freemap rotation */
#define HAMMER2_ZONE_FREEMAP_06 31 /* normal freemap rotation */
#define HAMMER2_ZONE_FREEMAP_07 36 /* normal freemap rotation */
#define HAMMER2_ZONE_FREEMAP_END 41 /* (non-inclusive) */
#define HAMMER2_ZONE_UNUSED41 41
#define HAMMER2_ZONE_UNUSED42 42
#define HAMMER2_ZONE_UNUSED43 43
#define HAMMER2_ZONE_UNUSED44 44
#define HAMMER2_ZONE_UNUSED45 45
#define HAMMER2_ZONE_UNUSED46 46
#define HAMMER2_ZONE_UNUSED47 47
#define HAMMER2_ZONE_UNUSED48 48
#define HAMMER2_ZONE_UNUSED49 49
#define HAMMER2_ZONE_UNUSED50 50
#define HAMMER2_ZONE_UNUSED51 51
#define HAMMER2_ZONE_UNUSED52 52
#define HAMMER2_ZONE_UNUSED53 53
#define HAMMER2_ZONE_UNUSED54 54
#define HAMMER2_ZONE_UNUSED55 55
#define HAMMER2_ZONE_UNUSED56 56
#define HAMMER2_ZONE_UNUSED57 57
#define HAMMER2_ZONE_UNUSED58 58
#define HAMMER2_ZONE_UNUSED59 59
#define HAMMER2_ZONE_UNUSED60 60
#define HAMMER2_ZONE_UNUSED61 61
#define HAMMER2_ZONE_UNUSED62 62
#define HAMMER2_ZONE_UNUSED63 63
#define HAMMER2_ZONE_END 64 /* non-inclusive */
#define HAMMER2_NFREEMAPS 8 /* FREEMAP_00 - FREEMAP_07 */
/* relative to FREEMAP_x */
#define HAMMER2_ZONEFM_LEVEL1 0 /* 1GB leafmap */
#define HAMMER2_ZONEFM_LEVEL2 1 /* 256GB indmap */
#define HAMMER2_ZONEFM_LEVEL3 2 /* 64TB indmap */
#define HAMMER2_ZONEFM_LEVEL4 3 /* 16PB indmap */
#define HAMMER2_ZONEFM_LEVEL5 4 /* 4EB indmap */
/* LEVEL6 is a set of 4 blockrefs in the volume header 16EB */
/*
* Freemap radix. Assumes a set-count of 4, 128-byte blockrefs,
* 32KB indirect block for freemap (LEVELN_PSIZE below).
*
* Leaf entry represents 4MB of storage broken down into a 512-bit
* bitmap, 2-bits per entry. So course bitmap item represents 16KB.
*/
#define HAMMER2_FREEMAP_LEVEL6_RADIX 64 /* 16EB (end) */
#define HAMMER2_FREEMAP_LEVEL5_RADIX 62 /* 4EB */
#define HAMMER2_FREEMAP_LEVEL4_RADIX 54 /* 16PB */
#define HAMMER2_FREEMAP_LEVEL3_RADIX 46 /* 64TB */
#define HAMMER2_FREEMAP_LEVEL2_RADIX 38 /* 256GB */
#define HAMMER2_FREEMAP_LEVEL1_RADIX 30 /* 1GB */
#define HAMMER2_FREEMAP_LEVEL0_RADIX 22 /* 4MB (128by in l-1 leaf) */
#define HAMMER2_FREEMAP_LEVELN_PSIZE 32768 /* physical bytes */
#define HAMMER2_FREEMAP_LEVEL5_SIZE ((hammer2_off_t)1 << \
HAMMER2_FREEMAP_LEVEL5_RADIX)
#define HAMMER2_FREEMAP_LEVEL4_SIZE ((hammer2_off_t)1 << \
HAMMER2_FREEMAP_LEVEL4_RADIX)
#define HAMMER2_FREEMAP_LEVEL3_SIZE ((hammer2_off_t)1 << \
HAMMER2_FREEMAP_LEVEL3_RADIX)
#define HAMMER2_FREEMAP_LEVEL2_SIZE ((hammer2_off_t)1 << \
HAMMER2_FREEMAP_LEVEL2_RADIX)
#define HAMMER2_FREEMAP_LEVEL1_SIZE ((hammer2_off_t)1 << \
HAMMER2_FREEMAP_LEVEL1_RADIX)
#define HAMMER2_FREEMAP_LEVEL0_SIZE ((hammer2_off_t)1 << \
HAMMER2_FREEMAP_LEVEL0_RADIX)
#define HAMMER2_FREEMAP_LEVEL5_MASK (HAMMER2_FREEMAP_LEVEL5_SIZE - 1)
#define HAMMER2_FREEMAP_LEVEL4_MASK (HAMMER2_FREEMAP_LEVEL4_SIZE - 1)
#define HAMMER2_FREEMAP_LEVEL3_MASK (HAMMER2_FREEMAP_LEVEL3_SIZE - 1)
#define HAMMER2_FREEMAP_LEVEL2_MASK (HAMMER2_FREEMAP_LEVEL2_SIZE - 1)
#define HAMMER2_FREEMAP_LEVEL1_MASK (HAMMER2_FREEMAP_LEVEL1_SIZE - 1)
#define HAMMER2_FREEMAP_LEVEL0_MASK (HAMMER2_FREEMAP_LEVEL0_SIZE - 1)
#define HAMMER2_FREEMAP_COUNT (int)(HAMMER2_FREEMAP_LEVELN_PSIZE / \
sizeof(hammer2_bmap_data_t))
/*
* 16KB bitmap granularity (x2 bits per entry).
*/
#define HAMMER2_FREEMAP_BLOCK_RADIX 14
#define HAMMER2_FREEMAP_BLOCK_SIZE (1 << HAMMER2_FREEMAP_BLOCK_RADIX)
#define HAMMER2_FREEMAP_BLOCK_MASK (HAMMER2_FREEMAP_BLOCK_SIZE - 1)
/*
* bitmap[] structure. 2 bits per HAMMER2_FREEMAP_BLOCK_SIZE.
*
* 8 x 64-bit elements, 2 bits per block.
* 32 blocks (radix 5) per element.
* representing INDEX_SIZE bytes worth of storage per element.
*/
typedef u64int hammer2_bitmap_t;
#define HAMMER2_BMAP_ALLONES ((hammer2_bitmap_t)-1)
#define HAMMER2_BMAP_ELEMENTS 8
#define HAMMER2_BMAP_BITS_PER_ELEMENT 64
#define HAMMER2_BMAP_INDEX_RADIX 5 /* 32 blocks per element */
#define HAMMER2_BMAP_BLOCKS_PER_ELEMENT (1 << HAMMER2_BMAP_INDEX_RADIX)
#define HAMMER2_BMAP_INDEX_SIZE (HAMMER2_FREEMAP_BLOCK_SIZE * \
HAMMER2_BMAP_BLOCKS_PER_ELEMENT)
#define HAMMER2_BMAP_INDEX_MASK (HAMMER2_BMAP_INDEX_SIZE - 1)
#define HAMMER2_BMAP_SIZE (HAMMER2_BMAP_INDEX_SIZE * \
HAMMER2_BMAP_ELEMENTS)
#define HAMMER2_BMAP_MASK (HAMMER2_BMAP_SIZE - 1)
/*
* Two linear areas can be reserved after the initial 2MB segment in the base
* zone (the one starting at offset 0). These areas are NOT managed by the
* block allocator and do not fall under HAMMER2 crc checking rules based
* at the volume header (but can be self-CRCd internally, depending).
*/
#define HAMMER2_BOOT_MIN_BYTES HAMMER2_VOLUME_ALIGN
#define HAMMER2_BOOT_NOM_BYTES (64*1024*1024)
#define HAMMER2_BOOT_MAX_BYTES (256*1024*1024)
#define HAMMER2_REDO_MIN_BYTES HAMMER2_VOLUME_ALIGN
#define HAMMER2_REDO_NOM_BYTES (256*1024*1024)
#define HAMMER2_REDO_MAX_BYTES (1024*1024*1024)
/*
* Most HAMMER2 types are implemented as unsigned 64-bit integers.
* Transaction ids are monotonic.
*
* We utilize 32-bit iSCSI CRCs.
*/
typedef u64int hammer2_tid_t;
typedef u64int hammer2_off_t;
typedef u64int hammer2_key_t;
typedef u32int hammer2_crc32_t;
/*
* Miscellanious ranges (all are unsigned).
*/
#define HAMMER2_TID_MIN 1ULL
#define HAMMER2_TID_MAX 0xFFFFFFFFFFFFFFFFULL
#define HAMMER2_KEY_MIN 0ULL
#define HAMMER2_KEY_MAX 0xFFFFFFFFFFFFFFFFULL
#define HAMMER2_OFFSET_MIN 0ULL
#define HAMMER2_OFFSET_MAX 0xFFFFFFFFFFFFFFFFULL
/*
* HAMMER2 data offset special cases and masking.
*
* All HAMMER2 data offsets have to be broken down into a 64K buffer base
* offset (HAMMER2_OFF_MASK_HI) and a 64K buffer index (HAMMER2_OFF_MASK_LO).
*
* Indexes into physical buffers are always 64-byte aligned. The low 6 bits
* of the data offset field specifies how large the data chunk being pointed
* to as a power of 2. The theoretical minimum radix is thus 6 (The space
* needed in the low bits of the data offset field). However, the practical
* minimum allocation chunk size is 1KB (a radix of 10), so HAMMER2 sets
* HAMMER2_RADIX_MIN to 10. The maximum radix is currently 16 (64KB), but
* we fully intend to support larger extents in the future.
*
* WARNING! A radix of 0 (such as when data_off is all 0's) is a special
* case which means no data associated with the blockref, and
* not the '1 byte' it would otherwise calculate to.
*/
#define HAMMER2_OFF_BAD ((hammer2_off_t)-1)
#define HAMMER2_OFF_MASK 0xFFFFFFFFFFFFFFC0ULL
#define HAMMER2_OFF_MASK_LO (HAMMER2_OFF_MASK & HAMMER2_PBUFMASK64)
#define HAMMER2_OFF_MASK_HI (~HAMMER2_PBUFMASK64)
#define HAMMER2_OFF_MASK_RADIX 0x000000000000003FULL
#define HAMMER2_MAX_COPIES 6
/*
* HAMMER2 directory support and pre-defined keys
*/
#define HAMMER2_DIRHASH_VISIBLE 0x8000000000000000ULL
#define HAMMER2_DIRHASH_USERMSK 0x7FFFFFFFFFFFFFFFULL
#define HAMMER2_DIRHASH_LOMASK 0x0000000000007FFFULL
#define HAMMER2_DIRHASH_HIMASK 0xFFFFFFFFFFFF0000ULL
#define HAMMER2_DIRHASH_FORCED 0x0000000000008000ULL /* bit forced on */
#define HAMMER2_SROOT_KEY 0x0000000000000000ULL /* volume to sroot */
#define HAMMER2_BOOT_KEY 0xd9b36ce135528000ULL /* sroot to BOOT PFS */
/************************************************************************
* DMSG SUPPORT *
************************************************************************
* LNK_VOLCONF
*
* All HAMMER2 directories directly under the super-root on your local
* media can be mounted separately, even if they share the same physical
* device.
*
* When you do a HAMMER2 mount you are effectively tying into a HAMMER2
* cluster via local media. The local media does not have to participate
* in the cluster, other than to provide the hammer2_volconf[] array and
* root inode for the mount.
*
* This is important: The mount device path you specify serves to bootstrap
* your entry into the cluster, but your mount will make active connections
* to ALL copy elements in the hammer2_volconf[] array which match the
* PFSID of the directory in the super-root that you specified. The local
* media path does not have to be mentioned in this array but becomes part
* of the cluster based on its type and access rights. ALL ELEMENTS ARE
* TREATED ACCORDING TO TYPE NO MATTER WHICH ONE YOU MOUNT FROM.
*
* The actual cluster may be far larger than the elements you list in the
* hammer2_volconf[] array. You list only the elements you wish to
* directly connect to and you are able to access the rest of the cluster
* indirectly through those connections.
*
* WARNING! This structure must be exactly 128 bytes long for its config
* array to fit in the volume header.
*/
#pragma packed on
struct hammer2_volconf {
u8int copyid; /* 00 copyid 0-255 (must match slot) */
u8int inprog; /* 01 operation in progress, or 0 */
u8int chain_to; /* 02 operation chaining to, or 0 */
u8int chain_from; /* 03 operation chaining from, or 0 */
u16int flags; /* 04-05 flags field */
u8int error; /* 06 last operational error */
u8int priority; /* 07 priority and round-robin flag */
u8int remote_pfs_type;/* 08 probed direct remote PFS type */
u8int reserved08[23]; /* 09-1F */
uuid_t pfs_clid; /* 20-2F copy target must match this uuid */
u8int label[16]; /* 30-3F import/export label */
u8int path[64]; /* 40-7F target specification string or key */
};
typedef struct hammer2_volconf hammer2_volconf_t;
/*
* HAMMER2 directory entry header (embedded in blockref) exactly 16 bytes
*/
struct hammer2_dirent_head {
hammer2_tid_t inum; /* inode number */
u16int namlen; /* name length */
u8int type; /* OBJTYPE_* */
u8int unused0B;
u8int unused0C[4];
};
typedef struct hammer2_dirent_head hammer2_dirent_head_t;
/*
* The media block reference structure. This forms the core of the HAMMER2
* media topology recursion. This 128-byte data structure is embedded in the
* volume header, in inodes (which are also directory entries), and in
* indirect blocks.
*
* A blockref references a single media item, which typically can be a
* directory entry (aka inode), indirect block, or data block.
*
* The primary feature a blockref represents is the ability to validate
* the entire tree underneath it via its check code. Any modification to
* anything propagates up the blockref tree all the way to the root, replacing
* the related blocks and compounding the generated check code.
*
* The check code can be a simple 32-bit iscsi code, a 64-bit crc, or as
* complex as a 512 bit cryptographic hash. I originally used a 64-byte
* blockref but later expanded it to 128 bytes to be able to support the
* larger check code as well as to embed statistics for quota operation.
*
* Simple check codes are not sufficient for unverified dedup. Even with
* a maximally-sized check code unverified dedup should only be used in
* in subdirectory trees where you do not need 100% data integrity.
*
* Unverified dedup is deduping based on meta-data only without verifying
* that the data blocks are actually identical. Verified dedup guarantees
* integrity but is a far more I/O-expensive operation.
*
* --
*
* mirror_tid - per cluster node modified (propagated upward by flush)
* modify_tid - clc record modified (not propagated).
* update_tid - clc record updated (propagated upward on verification)
*
* CLC - Stands for 'Cluster Level Change', identifiers which are identical
* within the topology across all cluster nodes (when fully
* synchronized).
*
* NOTE: The range of keys represented by the blockref is (key) to
* ((key) + (1LL << keybits) - 1). HAMMER2 usually populates
* blocks bottom-up, inserting a new root when radix expansion
* is required.
*
* leaf_count - Helps manage leaf collapse calculations when indirect
* blocks become mostly empty. This value caps out at
* HAMMER2_BLOCKREF_LEAF_MAX (65535).
*
* Used by the chain code to determine when to pull leafs up
* from nearly empty indirect blocks. For the purposes of this
* calculation, BREF_TYPE_INODE is considered a leaf, along
* with DIRENT and DATA.
*
* RESERVED FIELDS
*
* A number of blockref fields are reserved and should generally be set to
* 0 for future compatibility.
*
* FUTURE BLOCKREF EXPANSION
*
* CONTENT ADDRESSABLE INDEXING (future) - Using a 256 or 512-bit check code.
*/
struct hammer2_blockref { /* MUST BE EXACTLY 64 BYTES */
u8int type; /* type of underlying item */
u8int methods; /* check method & compression method */
u8int copyid; /* specify which copy this is */
u8int keybits; /* #of keybits masked off 0=leaf */
u8int vradix; /* virtual data/meta-data size */
u8int flags; /* blockref flags */
u16int leaf_count; /* leaf aggregation count */
hammer2_key_t key; /* key specification */
hammer2_tid_t mirror_tid; /* media flush topology & freemap */
hammer2_tid_t modify_tid; /* clc modify (not propagated) */
hammer2_off_t data_off; /* low 6 bits is phys size (radix)*/
hammer2_tid_t update_tid; /* clc modify (propagated upward) */
union {
char buf[16];
/*
* Directory entry header (BREF_TYPE_DIRENT)
*
* NOTE: check.buf contains filename if <= 64 bytes. Longer
* filenames are stored in a data reference of size
* HAMMER2_ALLOC_MIN (at least 256, typically 1024).
*
* NOTE: inode structure may contain a copy of a recently
* associated filename, for recovery purposes.
*
* NOTE: Superroot entries are INODEs, not DIRENTs. Code
* allows both cases.
*/
hammer2_dirent_head_t dirent;
/*
* Statistics aggregation (BREF_TYPE_INODE, BREF_TYPE_INDIRECT)
*/
struct {
hammer2_key_t data_count;
hammer2_key_t inode_count;
} stats;
} embed;
union { /* check info */
char buf[64];
struct {
u32int value;
u32int reserved[15];
} iscsi32;
struct {
u64int value;
u64int reserved[7];
} xxhash64;
struct {
char data[24];
char reserved[40];
} sha192;
struct {
char data[32];
char reserved[32];
} sha256;
struct {
char data[64];
} sha512;
/*
* Freemap hints are embedded in addition to the icrc32.
*
* bigmask - Radixes available for allocation (0-31).
* Heuristical (may be permissive but not
* restrictive). Typically only radix values
* 10-16 are used (i.e. (1<<10) through (1<<16)).
*
* avail - Total available space remaining, in bytes
*/
struct {
u32int icrc32;
u32int bigmask; /* available radixes */
u64int avail; /* total available bytes */
char reserved[48];
} freemap;
} check;
};
typedef struct hammer2_blockref hammer2_blockref_t;
#pragma packed off
#define HAMMER2_BLOCKREF_BYTES 128 /* blockref struct in bytes */
#define HAMMER2_BLOCKREF_RADIX 7
#define HAMMER2_BLOCKREF_LEAF_MAX 65535
/*
* On-media and off-media blockref types.
*
* types >= 128 are pseudo values that should never be present on-media.
*/
#define HAMMER2_BREF_TYPE_EMPTY 0
#define HAMMER2_BREF_TYPE_INODE 1
#define HAMMER2_BREF_TYPE_INDIRECT 2
#define HAMMER2_BREF_TYPE_DATA 3
#define HAMMER2_BREF_TYPE_DIRENT 4
#define HAMMER2_BREF_TYPE_FREEMAP_NODE 5
#define HAMMER2_BREF_TYPE_FREEMAP_LEAF 6
#define HAMMER2_BREF_TYPE_FREEMAP 254 /* pseudo-type */
#define HAMMER2_BREF_TYPE_VOLUME 255 /* pseudo-type */
#define HAMMER2_BREF_FLAG_PFSROOT 0x01 /* see also related opflag */
#define HAMMER2_BREF_FLAG_ZERO 0x02
/*
* Encode/decode check mode and compression mode for
* bref.methods. The compression level is not encoded in
* bref.methods.
*/
#define HAMMER2_ENC_CHECK(n) (((n) & 15) << 4)
#define HAMMER2_DEC_CHECK(n) (((n) >> 4) & 15)
#define HAMMER2_ENC_COMP(n) ((n) & 15)
#define HAMMER2_DEC_COMP(n) ((n) & 15)
#define HAMMER2_CHECK_NONE 0
#define HAMMER2_CHECK_DISABLED 1
#define HAMMER2_CHECK_ISCSI32 2
#define HAMMER2_CHECK_XXHASH64 3
#define HAMMER2_CHECK_SHA192 4
#define HAMMER2_CHECK_FREEMAP 5
#define HAMMER2_CHECK_DEFAULT HAMMER2_CHECK_XXHASH64
/* user-specifiable check modes only */
#define HAMMER2_CHECK_STRINGS { "none", "disabled", "crc32", \
"xxhash64", "sha192" }
#define HAMMER2_CHECK_STRINGS_COUNT 5
/*
* Encode/decode check or compression algorithm request in
* ipdata->meta.check_algo and ipdata->meta.comp_algo.
*/
#define HAMMER2_ENC_ALGO(n) (n)
#define HAMMER2_DEC_ALGO(n) ((n) & 15)
#define HAMMER2_ENC_LEVEL(n) ((n) << 4)
#define HAMMER2_DEC_LEVEL(n) (((n) >> 4) & 15)
#define HAMMER2_COMP_NONE 0
#define HAMMER2_COMP_AUTOZERO 1
#define HAMMER2_COMP_LZ4 2
#define HAMMER2_COMP_ZLIB 3
#define HAMMER2_COMP_NEWFS_DEFAULT HAMMER2_COMP_LZ4
#define HAMMER2_COMP_STRINGS { "none", "autozero", "lz4", "zlib" }
#define HAMMER2_COMP_STRINGS_COUNT 4
/*
* Passed to hammer2_chain_create(), causes methods to be inherited from
* parent.
*/
#define HAMMER2_METH_DEFAULT -1
/*
* HAMMER2 block references are collected into sets of 4 blockrefs. These
* sets are fully associative, meaning the elements making up a set are
* not sorted in any way and may contain duplicate entries, holes, or
* entries which shortcut multiple levels of indirection. Sets are used
* in various ways:
*
* (1) When redundancy is desired a set may contain several duplicate
* entries pointing to different copies of the same data. Up to 4 copies
* are supported.
*
* (2) The blockrefs in a set can shortcut multiple levels of indirections
* within the bounds imposed by the parent of set.
*
* When a set fills up another level of indirection is inserted, moving
* some or all of the set's contents into indirect blocks placed under the
* set. This is a top-down approach in that indirect blocks are not created
* until the set actually becomes full (that is, the entries in the set can
* shortcut the indirect blocks when the set is not full). Depending on how
* things are filled multiple indirect blocks will eventually be created.
*
* Indirect blocks are typically 4KB (64 entres) or 64KB (1024 entries) and
* are also treated as fully set-associative.
*/
struct hammer2_blockset {
hammer2_blockref_t blockref[HAMMER2_SET_COUNT];
};
typedef struct hammer2_blockset hammer2_blockset_t;
/*
* hammer2_bmap_data - A freemap entry in the LEVEL1 block.
*
* Each 128-byte entry contains the bitmap and meta-data required to manage
* a LEVEL0 (128KB) block of storage. The storage is managed in 128 x 1KB
* chunks.
*
* A smaller allocation granularity is supported via a linear iterator and/or
* must otherwise be tracked in ram.
*
* (data structure must be 128 bytes exactly)
*
* linear - A BYTE linear allocation offset used for sub-16KB allocations
* only. May contain values between 0 and 2MB. Must be ignored
* if 16KB-aligned (i.e. force bitmap scan), otherwise may be
* used to sub-allocate within the 16KB block (which is already
* marked as allocated in the bitmap).
*
* Sub-allocations need only be 1KB-aligned and do not have to be
* size-aligned, and 16KB or larger allocations do not update this
* field, resulting in pretty good packing.
*
* Please note that file data granularity may be limited by
* other issues such as buffer cache direct-mapping and the
* desire to support sector sizes up to 16KB (so H2 only issues
* I/O's in multiples of 16KB anyway).
*
* class - Clustering class. Cleared to 0 only if the entire leaf becomes
* free. Used to cluster device buffers so all elements must have
* the same device block size, but may mix logical sizes.
*
* Typically integrated with the blockref type in the upper 8 bits
* to localize inodes and indrect blocks, improving bulk free scans
* and directory scans.
*
* bitmap - Two bits per 16KB allocation block arranged in arrays of
* 32-bit elements, 256x2 bits representing ~4MB worth of media
* storage. Bit patterns are as follows:
*
* 00 Unallocated
* 01 (reserved)
* 10 Possibly free
* 11 Allocated
*/
#pragma packed on
struct hammer2_bmap_data {
s32int linear; /* 00 linear sub-granular allocation offset */
u16int class; /* 04-05 clustering class ((type<<8)|radix) */
u8int reserved06; /* 06 */
u8int reserved07; /* 07 */
u32int reserved08; /* 08 */
u32int reserved0C; /* 0C */
u32int reserved10; /* 10 */
u32int reserved14; /* 14 */
u32int reserved18; /* 18 */
u32int avail; /* 1C */
u32int reserved20[8]; /* 20-3F 256 bits manages 128K/1KB/2-bits */
/* 40-7F 512 bits manages 4MB of storage */
hammer2_bitmap_t bitmapq[HAMMER2_BMAP_ELEMENTS];
};
typedef struct hammer2_bmap_data hammer2_bmap_data_t;
/*
* In HAMMER2 inodes ARE directory entries, with a special exception for
* hardlinks. The inode number is stored in the inode rather than being
* based on the location of the inode (since the location moves every time
* the inode or anything underneath the inode is modified).
*
* The inode is 1024 bytes, made up of 256 bytes of meta-data, 256 bytes
* for the filename, and 512 bytes worth of direct file data OR an embedded
* blockset. The in-memory hammer2_inode structure contains only the mostly-
* node-independent meta-data portion (some flags are node-specific and will
* not be synchronized). The rest of the inode is node-specific and chain I/O
* is required to obtain it.
*
* Directories represent one inode per blockref. Inodes are not laid out
* as a file but instead are represented by the related blockrefs. The
* blockrefs, in turn, are indexed by the 64-bit directory hash key. Remember
* that blocksets are fully associative, so a certain degree efficiency is
* achieved just from that.
*
* Up to 512 bytes of direct data can be embedded in an inode, and since
* inodes are essentially directory entries this also means that small data
* files end up simply being laid out linearly in the directory, resulting
* in fewer seeks and highly optimal access.
*
* The compression mode can be changed at any time in the inode and is
* recorded on a blockref-by-blockref basis.
*
* Hardlinks are supported via the inode map. Essentially the way a hardlink
* works is that all individual directory entries representing the same file
* are special cased and specify the same inode number. The actual file
* is placed in the nearest parent directory that is parent to all instances
* of the hardlink. If all hardlinks to a file are in the same directory
* the actual file will also be placed in that directory. This file uses
* the inode number as the directory entry key and is invisible to normal
* directory scans. Real directory entry keys are differentiated from the
* inode number key via bit 63. Access to the hardlink silently looks up
* the real file and forwards all operations to that file. Removal of the
* last hardlink also removes the real file.
*
* (attr_tid) is only updated when the inode's specific attributes or regular
* file size has changed, and affects path lookups and stat. (attr_tid)
* represents a special cache coherency lock under the inode. The inode
* blockref's modify_tid will always cover it.
*
* (dirent_tid) is only updated when an entry under a directory inode has
* been created, deleted, renamed, or had its attributes change, and affects
* directory lookups and scans. (dirent_tid) represents another special cache
* coherency lock under the inode. The inode blockref's modify_tid will
* always cover it.
*/
#define HAMMER2_INODE_BYTES 1024 /* (asserted by code) */
#define HAMMER2_INODE_MAXNAME 256 /* maximum name in bytes */
#define HAMMER2_INODE_VERSION_ONE 1
#define HAMMER2_INODE_START 1024 /* dynamically allocated */
struct hammer2_inode_meta {
u16int version; /* 0000 inode data version */
u8int reserved02; /* 0002 */
u8int pfs_subtype; /* 0003 pfs sub-type */
/*
* core inode attributes, inode type, misc flags
*/
u32int uflags; /* 0004 chflags */
u32int rmajor; /* 0008 available for device nodes */
u32int rminor; /* 000C available for device nodes */
u64int ctime; /* 0010 inode change time */
u64int mtime; /* 0018 modified time */
u64int atime; /* 0020 access time (unsupported) */
u64int btime; /* 0028 birth time */
uuid_t uid; /* 0030 uid / degenerate unix uid */
uuid_t gid; /* 0040 gid / degenerate unix gid */
u8int type; /* 0050 object type */
u8int op_flags; /* 0051 operational flags */
u16int cap_flags; /* 0052 capability flags */
u32int mode; /* 0054 unix modes (typ low 16 bits) */
/*
* inode size, identification, localized recursive configuration
* for compression and backup copies.
*
* NOTE: Nominal parent inode number (iparent) is only applicable
* for directories but can also help for files during
* catastrophic recovery.
*/
hammer2_tid_t inum; /* 0058 inode number */
hammer2_off_t size; /* 0060 size of file */
u64int nlinks; /* 0068 hard links (typ only dirs) */
hammer2_tid_t iparent; /* 0070 nominal parent inum */
hammer2_key_t name_key; /* 0078 full filename key */
u16int name_len; /* 0080 filename length */
u8int ncopies; /* 0082 ncopies to local media */
u8int comp_algo; /* 0083 compression request & algo */
/*
* These fields are currently only applicable to PFSROOTs.
*
* NOTE: We can't use {volume_data->fsid, pfs_clid} to uniquely
* identify an instance of a PFS in the cluster because
* a mount may contain more than one copy of the PFS as
* a separate node. {pfs_clid, pfs_fsid} must be used for
* registration in the cluster.
*/
u8int target_type; /* 0084 hardlink target type */
u8int check_algo; /* 0085 check code request & algo */
u8int pfs_nmasters; /* 0086 (if PFSROOT) if multi-master */
u8int pfs_type; /* 0087 (if PFSROOT) node type */
u64int pfs_inum; /* 0088 (if PFSROOT) inum allocator */
uuid_t pfs_clid; /* 0090 (if PFSROOT) cluster uuid */
uuid_t pfs_fsid; /* 00A0 (if PFSROOT) unique uuid */
/*
* Quotas and aggregate sub-tree inode and data counters. Note that
* quotas are not replicated downward, they are explicitly set by
* the sysop and in-memory structures keep track of inheritence.
*/
hammer2_key_t data_quota; /* 00B0 subtree quota in bytes */
hammer2_key_t unusedB8; /* 00B8 subtree byte count */
hammer2_key_t inode_quota; /* 00C0 subtree quota inode count */
hammer2_key_t unusedC8; /* 00C8 subtree inode count */
/*
* The last snapshot tid is tested against modify_tid to determine
* when a copy must be made of a data block whos check mode has been
* disabled (a disabled check mode allows data blocks to be updated
* in place instead of copy-on-write).
*/
hammer2_tid_t pfs_lsnap_tid; /* 00D0 last snapshot tid */
hammer2_tid_t reservedD8; /* 00D8 (avail) */
/*
* Tracks (possibly degenerate) free areas covering all sub-tree
* allocations under inode, not counting the inode itself.
* 0/0 indicates empty entry. fully set-associative.
*
* (not yet implemented)
*/
u64int decrypt_check; /* 00E0 decryption validator */
hammer2_off_t reservedE0[3]; /* 00E8/F0/F8 */
};
typedef struct hammer2_inode_meta hammer2_inode_meta_t;
struct hammer2_inode_data {
hammer2_inode_meta_t meta; /* 0000-00FF */
unsigned char filename[HAMMER2_INODE_MAXNAME];
/* 0100-01FF (256 char, unterminated) */
union { /* 0200-03FF (64x8 = 512 bytes) */
struct hammer2_blockset blockset;
char data[HAMMER2_EMBEDDED_BYTES];
} u;
};
typedef struct hammer2_inode_data hammer2_inode_data_t;
#define HAMMER2_OPFLAG_DIRECTDATA 0x01
#define HAMMER2_OPFLAG_PFSROOT 0x02 /* (see also bref flag) */
#define HAMMER2_OPFLAG_COPYIDS 0x04 /* copyids override parent */
#define HAMMER2_OBJTYPE_UNKNOWN 0
#define HAMMER2_OBJTYPE_DIRECTORY 1
#define HAMMER2_OBJTYPE_REGFILE 2
#define HAMMER2_OBJTYPE_FIFO 4
#define HAMMER2_OBJTYPE_CDEV 5
#define HAMMER2_OBJTYPE_BDEV 6
#define HAMMER2_OBJTYPE_SOFTLINK 7
#define HAMMER2_OBJTYPE_UNUSED08 8
#define HAMMER2_OBJTYPE_SOCKET 9
#define HAMMER2_OBJTYPE_WHITEOUT 10
#define HAMMER2_COPYID_NONE 0
#define HAMMER2_COPYID_LOCAL ((u8int)-1)
#define HAMMER2_COPYID_COUNT 256