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#ifndef _OCFS2_FS_H
26#define _OCFS2_FS_H
27
28
29#define OCFS2_MAJOR_REV_LEVEL 0
30#define OCFS2_MINOR_REV_LEVEL 90
31
32
33
34
35
36
37
38
39
40
41
42
43#define OCFS2_SUPER_BLOCK_BLKNO 2
44
45
46
47
48
49#define OCFS2_MIN_CLUSTERSIZE 4096
50#define OCFS2_MAX_CLUSTERSIZE 1048576
51
52
53
54
55
56#define OCFS2_MIN_BLOCKSIZE 512
57#define OCFS2_MAX_BLOCKSIZE OCFS2_MIN_CLUSTERSIZE
58
59
60#define OCFS2_SUPER_MAGIC 0x7461636f
61
62
63#define OCFS2_SUPER_BLOCK_SIGNATURE "OCFSV2"
64#define OCFS2_INODE_SIGNATURE "INODE01"
65#define OCFS2_EXTENT_BLOCK_SIGNATURE "EXBLK01"
66#define OCFS2_GROUP_DESC_SIGNATURE "GROUP01"
67#define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01"
68#define OCFS2_DIR_TRAILER_SIGNATURE "DIRTRL1"
69#define OCFS2_DX_ROOT_SIGNATURE "DXDIR01"
70#define OCFS2_DX_LEAF_SIGNATURE "DXLEAF1"
71#define OCFS2_REFCOUNT_BLOCK_SIGNATURE "REFCNT1"
72
73
74#define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \
75 ( OCFS2_SB(sb)->s_feature_compat & (mask) )
76#define OCFS2_HAS_RO_COMPAT_FEATURE(sb,mask) \
77 ( OCFS2_SB(sb)->s_feature_ro_compat & (mask) )
78#define OCFS2_HAS_INCOMPAT_FEATURE(sb,mask) \
79 ( OCFS2_SB(sb)->s_feature_incompat & (mask) )
80#define OCFS2_SET_COMPAT_FEATURE(sb,mask) \
81 OCFS2_SB(sb)->s_feature_compat |= (mask)
82#define OCFS2_SET_RO_COMPAT_FEATURE(sb,mask) \
83 OCFS2_SB(sb)->s_feature_ro_compat |= (mask)
84#define OCFS2_SET_INCOMPAT_FEATURE(sb,mask) \
85 OCFS2_SB(sb)->s_feature_incompat |= (mask)
86#define OCFS2_CLEAR_COMPAT_FEATURE(sb,mask) \
87 OCFS2_SB(sb)->s_feature_compat &= ~(mask)
88#define OCFS2_CLEAR_RO_COMPAT_FEATURE(sb,mask) \
89 OCFS2_SB(sb)->s_feature_ro_compat &= ~(mask)
90#define OCFS2_CLEAR_INCOMPAT_FEATURE(sb,mask) \
91 OCFS2_SB(sb)->s_feature_incompat &= ~(mask)
92
93#define OCFS2_FEATURE_COMPAT_SUPP (OCFS2_FEATURE_COMPAT_BACKUP_SB \
94 | OCFS2_FEATURE_COMPAT_JBD2_SB)
95#define OCFS2_FEATURE_INCOMPAT_SUPP (OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT \
96 | OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC \
97 | OCFS2_FEATURE_INCOMPAT_INLINE_DATA \
98 | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
99 | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
100 | OCFS2_FEATURE_INCOMPAT_XATTR \
101 | OCFS2_FEATURE_INCOMPAT_META_ECC \
102 | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \
103 | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \
104 | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG \
105 | OCFS2_FEATURE_INCOMPAT_CLUSTERINFO \
106 | OCFS2_FEATURE_INCOMPAT_APPEND_DIO)
107#define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
108 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
109 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
110
111
112
113
114
115
116#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
117
118
119
120
121
122
123#define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
124
125
126#define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
127
128
129#define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
130
131
132
133
134
135
136
137
138
139
140#define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
141
142
143#define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
144
145
146
147
148
149
150
151
152
153
154#define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
155
156
157#define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
158
159
160#define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
161
162
163#define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400
164
165
166#define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
167
168
169#define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
170
171
172#define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000
173
174
175
176
177
178
179#define OCFS2_FEATURE_INCOMPAT_CLUSTERINFO 0x4000
180
181
182
183
184#define OCFS2_FEATURE_INCOMPAT_APPEND_DIO 0x8000
185
186
187
188
189
190#define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
191
192
193
194
195#define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
196
197
198
199
200#define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
201
202
203
204
205#define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
206#define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
207
208
209
210
211
212#define OCFS2_BACKUP_SB_START 1 << 30
213
214
215#define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
216
217
218
219
220#define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001
221
222
223
224
225#define OCFS2_VALID_FL (0x00000001)
226#define OCFS2_UNUSED2_FL (0x00000002)
227#define OCFS2_ORPHANED_FL (0x00000004)
228#define OCFS2_UNUSED3_FL (0x00000008)
229
230#define OCFS2_SYSTEM_FL (0x00000010)
231#define OCFS2_SUPER_BLOCK_FL (0x00000020)
232#define OCFS2_LOCAL_ALLOC_FL (0x00000040)
233#define OCFS2_BITMAP_FL (0x00000080)
234#define OCFS2_JOURNAL_FL (0x00000100)
235#define OCFS2_HEARTBEAT_FL (0x00000200)
236#define OCFS2_CHAIN_FL (0x00000400)
237#define OCFS2_DEALLOC_FL (0x00000800)
238#define OCFS2_QUOTA_FL (0x00001000)
239#define OCFS2_DIO_ORPHANED_FL (0X00002000)
240
241
242
243
244
245
246
247
248#define OCFS2_INLINE_DATA_FL (0x0001)
249#define OCFS2_HAS_XATTR_FL (0x0002)
250#define OCFS2_INLINE_XATTR_FL (0x0004)
251#define OCFS2_INDEXED_DIR_FL (0x0008)
252#define OCFS2_HAS_REFCOUNT_FL (0x0010)
253
254
255#define OCFS2_SECRM_FL FS_SECRM_FL
256#define OCFS2_UNRM_FL FS_UNRM_FL
257#define OCFS2_COMPR_FL FS_COMPR_FL
258#define OCFS2_SYNC_FL FS_SYNC_FL
259#define OCFS2_IMMUTABLE_FL FS_IMMUTABLE_FL
260#define OCFS2_APPEND_FL FS_APPEND_FL
261#define OCFS2_NODUMP_FL FS_NODUMP_FL
262#define OCFS2_NOATIME_FL FS_NOATIME_FL
263
264#define OCFS2_DIRTY_FL FS_DIRTY_FL
265#define OCFS2_COMPRBLK_FL FS_COMPRBLK_FL
266#define OCFS2_NOCOMP_FL FS_NOCOMP_FL
267#define OCFS2_ECOMPR_FL FS_ECOMPR_FL
268
269#define OCFS2_BTREE_FL FS_BTREE_FL
270#define OCFS2_INDEX_FL FS_INDEX_FL
271#define OCFS2_IMAGIC_FL FS_IMAGIC_FL
272#define OCFS2_JOURNAL_DATA_FL FS_JOURNAL_DATA_FL
273#define OCFS2_NOTAIL_FL FS_NOTAIL_FL
274#define OCFS2_DIRSYNC_FL FS_DIRSYNC_FL
275#define OCFS2_TOPDIR_FL FS_TOPDIR_FL
276#define OCFS2_RESERVED_FL FS_RESERVED_FL
277
278#define OCFS2_FL_VISIBLE FS_FL_USER_VISIBLE
279#define OCFS2_FL_MODIFIABLE FS_FL_USER_MODIFIABLE
280
281
282
283
284#define OCFS2_EXT_UNWRITTEN (0x01)
285
286#define OCFS2_EXT_REFCOUNTED (0x02)
287
288
289
290
291
292
293#define OCFS2_JOURNAL_DIRTY_FL (0x00000001)
294
295
296
297
298#define OCFS2_ERROR_FS (0x00000001)
299
300
301#define OCFS2_MAX_FILENAME_LEN 255
302
303
304#define OCFS2_MAX_SLOTS 255
305
306
307#define OCFS2_INVALID_SLOT -1
308
309#define OCFS2_VOL_UUID_LEN 16
310#define OCFS2_MAX_VOL_LABEL_LEN 64
311
312
313#define OCFS2_STACK_LABEL_LEN 4
314#define OCFS2_CLUSTER_NAME_LEN 16
315
316
317#define OCFS2_CLASSIC_CLUSTER_STACK "o2cb"
318
319
320#define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
321
322
323
324
325
326#define OCFS2_MIN_XATTR_INLINE_SIZE 256
327
328
329
330
331#define OCFS2_CLUSTER_O2CB_GLOBAL_HEARTBEAT (0x01)
332
333struct ocfs2_system_inode_info {
334 char *si_name;
335 int si_iflags;
336 int si_mode;
337};
338
339
340enum {
341 BAD_BLOCK_SYSTEM_INODE = 0,
342 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
343 SLOT_MAP_SYSTEM_INODE,
344#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
345 HEARTBEAT_SYSTEM_INODE,
346 GLOBAL_BITMAP_SYSTEM_INODE,
347 USER_QUOTA_SYSTEM_INODE,
348 GROUP_QUOTA_SYSTEM_INODE,
349#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
350#define OCFS2_FIRST_LOCAL_SYSTEM_INODE ORPHAN_DIR_SYSTEM_INODE
351 ORPHAN_DIR_SYSTEM_INODE,
352 EXTENT_ALLOC_SYSTEM_INODE,
353 INODE_ALLOC_SYSTEM_INODE,
354 JOURNAL_SYSTEM_INODE,
355 LOCAL_ALLOC_SYSTEM_INODE,
356 TRUNCATE_LOG_SYSTEM_INODE,
357 LOCAL_USER_QUOTA_SYSTEM_INODE,
358 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
359#define OCFS2_LAST_LOCAL_SYSTEM_INODE LOCAL_GROUP_QUOTA_SYSTEM_INODE
360 NUM_SYSTEM_INODES
361};
362#define NUM_GLOBAL_SYSTEM_INODES OCFS2_FIRST_LOCAL_SYSTEM_INODE
363#define NUM_LOCAL_SYSTEM_INODES \
364 (NUM_SYSTEM_INODES - OCFS2_FIRST_LOCAL_SYSTEM_INODE)
365
366static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
367
368
369 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
370 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
371
372
373 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
374 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
375 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
376 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
377 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
378
379
380 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
381 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
382 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
383 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
384 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
385 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
386 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
387 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
388};
389
390
391#define OCFS2_HB_NONE "heartbeat=none"
392#define OCFS2_HB_LOCAL "heartbeat=local"
393#define OCFS2_HB_GLOBAL "heartbeat=global"
394
395
396
397
398
399#define OCFS2_FT_UNKNOWN 0
400#define OCFS2_FT_REG_FILE 1
401#define OCFS2_FT_DIR 2
402#define OCFS2_FT_CHRDEV 3
403#define OCFS2_FT_BLKDEV 4
404#define OCFS2_FT_FIFO 5
405#define OCFS2_FT_SOCK 6
406#define OCFS2_FT_SYMLINK 7
407
408#define OCFS2_FT_MAX 8
409
410
411
412
413
414
415#define OCFS2_DIR_PAD 4
416#define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
417#define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
418#define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
419 OCFS2_DIR_ROUND) & \
420 ~OCFS2_DIR_ROUND)
421#define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
422
423#define OCFS2_LINK_MAX 32000
424#define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
425#define OCFS2_LINKS_HI_SHIFT 16
426#define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
427
428#define S_SHIFT 12
429static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
430 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
431 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
432 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
433 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
434 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
435 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
436 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
437};
438
439
440
441
442
443#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
444
445
446
447
448
449
450struct ocfs2_block_check {
451 __le32 bc_crc32e;
452 __le16 bc_ecc;
453
454
455
456
457 __le16 bc_reserved1;
458
459};
460
461
462
463
464
465
466
467
468struct ocfs2_extent_rec {
469 __le32 e_cpos;
470 union {
471 __le32 e_int_clusters;
472 struct {
473 __le16 e_leaf_clusters;
474
475 __u8 e_reserved1;
476 __u8 e_flags;
477 };
478 };
479 __le64 e_blkno;
480
481};
482
483struct ocfs2_chain_rec {
484 __le32 c_free;
485 __le32 c_total;
486 __le64 c_blkno;
487};
488
489struct ocfs2_truncate_rec {
490 __le32 t_start;
491 __le32 t_clusters;
492};
493
494
495
496
497
498
499
500struct ocfs2_extent_list {
501 __le16 l_tree_depth;
502
503
504
505
506
507
508 __le16 l_count;
509 __le16 l_next_free_rec;
510 __le16 l_reserved1;
511 __le64 l_reserved2;
512
513 struct ocfs2_extent_rec l_recs[0];
514};
515
516
517
518
519
520
521struct ocfs2_chain_list {
522 __le16 cl_cpg;
523 __le16 cl_bpc;
524 __le16 cl_count;
525 __le16 cl_next_free_rec;
526 __le64 cl_reserved1;
527 struct ocfs2_chain_rec cl_recs[0];
528};
529
530
531
532
533
534
535struct ocfs2_truncate_log {
536 __le16 tl_count;
537 __le16 tl_used;
538 __le32 tl_reserved1;
539 struct ocfs2_truncate_rec tl_recs[0];
540};
541
542
543
544
545struct ocfs2_extent_block
546{
547 __u8 h_signature[8];
548 struct ocfs2_block_check h_check;
549 __le16 h_suballoc_slot;
550
551 __le16 h_suballoc_bit;
552
553 __le32 h_fs_generation;
554 __le64 h_blkno;
555 __le64 h_suballoc_loc;
556
557
558
559 __le64 h_next_leaf_blk;
560
561
562 struct ocfs2_extent_list h_list;
563
564};
565
566
567
568
569
570
571struct ocfs2_slot_map {
572 __le16 sm_slots[0];
573
574
575
576
577};
578
579struct ocfs2_extended_slot {
580 __u8 es_valid;
581 __u8 es_reserved1[3];
582 __le32 es_node_num;
583
584};
585
586
587
588
589
590
591
592struct ocfs2_slot_map_extended {
593 struct ocfs2_extended_slot se_slots[0];
594
595
596
597
598};
599
600
601
602
603
604struct ocfs2_cluster_info {
605 __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
606 union {
607 __le32 ci_reserved;
608 struct {
609 __u8 ci_stackflags;
610 __u8 ci_reserved1;
611 __u8 ci_reserved2;
612 __u8 ci_reserved3;
613 };
614 };
615 __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
616
617};
618
619
620
621
622
623
624struct ocfs2_super_block {
625 __le16 s_major_rev_level;
626 __le16 s_minor_rev_level;
627 __le16 s_mnt_count;
628 __le16 s_max_mnt_count;
629 __le16 s_state;
630 __le16 s_errors;
631 __le32 s_checkinterval;
632 __le64 s_lastcheck;
633 __le32 s_creator_os;
634 __le32 s_feature_compat;
635 __le32 s_feature_incompat;
636 __le32 s_feature_ro_compat;
637 __le64 s_root_blkno;
638
639 __le64 s_system_dir_blkno;
640
641 __le32 s_blocksize_bits;
642 __le32 s_clustersize_bits;
643 __le16 s_max_slots;
644
645 __le16 s_tunefs_flag;
646 __le32 s_uuid_hash;
647 __le64 s_first_cluster_group;
648
649 __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN];
650 __u8 s_uuid[OCFS2_VOL_UUID_LEN];
651 struct ocfs2_cluster_info s_cluster_info;
652
653
654 __le16 s_xattr_inline_size;
655
656 __le16 s_reserved0;
657 __le32 s_dx_seed[3];
658
659 __le64 s_reserved2[15];
660
661
662
663
664
665
666
667
668
669
670};
671
672
673
674
675
676
677struct ocfs2_local_alloc
678{
679 __le32 la_bm_off;
680 __le16 la_size;
681 __le16 la_reserved1;
682 __le64 la_reserved2;
683 __u8 la_bitmap[0];
684};
685
686
687
688
689
690struct ocfs2_inline_data
691{
692 __le16 id_count;
693
694 __le16 id_reserved0;
695 __le32 id_reserved1;
696 __u8 id_data[0];
697};
698
699
700
701
702struct ocfs2_dinode {
703 __u8 i_signature[8];
704 __le32 i_generation;
705 __le16 i_suballoc_slot;
706
707 __le16 i_suballoc_bit;
708
709 __le16 i_links_count_hi;
710 __le16 i_xattr_inline_size;
711 __le32 i_clusters;
712 __le32 i_uid;
713 __le32 i_gid;
714 __le64 i_size;
715 __le16 i_mode;
716 __le16 i_links_count;
717 __le32 i_flags;
718 __le64 i_atime;
719 __le64 i_ctime;
720 __le64 i_mtime;
721 __le64 i_dtime;
722 __le64 i_blkno;
723 __le64 i_last_eb_blk;
724
725 __le32 i_fs_generation;
726 __le32 i_atime_nsec;
727 __le32 i_ctime_nsec;
728 __le32 i_mtime_nsec;
729 __le32 i_attr;
730 __le16 i_orphaned_slot;
731
732 __le16 i_dyn_features;
733 __le64 i_xattr_loc;
734 struct ocfs2_block_check i_check;
735 __le64 i_dx_root;
736 __le64 i_refcount_loc;
737 __le64 i_suballoc_loc;
738
739
740
741 __le16 i_dio_orphaned_slot;
742 __le16 i_reserved1[3];
743 __le64 i_reserved2[2];
744 union {
745 __le64 i_pad1;
746
747 struct {
748 __le64 i_rdev;
749 } dev1;
750 struct {
751
752 __le32 i_used;
753 __le32 i_total;
754
755 } bitmap1;
756 struct {
757
758 __le32 ij_flags;
759 __le32 ij_recovery_generation;
760
761
762
763 } journal1;
764 } id1;
765 union {
766 struct ocfs2_super_block i_super;
767 struct ocfs2_local_alloc i_lab;
768 struct ocfs2_chain_list i_chain;
769 struct ocfs2_extent_list i_list;
770 struct ocfs2_truncate_log i_dealloc;
771 struct ocfs2_inline_data i_data;
772 __u8 i_symlink[0];
773 } id2;
774
775};
776
777
778
779
780
781
782struct ocfs2_dir_entry {
783 __le64 inode;
784 __le16 rec_len;
785 __u8 name_len;
786 __u8 file_type;
787 char name[OCFS2_MAX_FILENAME_LEN];
788
789} __attribute__ ((packed));
790
791
792
793
794
795
796
797
798
799struct ocfs2_dir_block_trailer {
800 __le64 db_compat_inode;
801
802 __le16 db_compat_rec_len;
803
804 __u8 db_compat_name_len;
805 __u8 db_reserved0;
806 __le16 db_reserved1;
807 __le16 db_free_rec_len;
808
809 __u8 db_signature[8];
810 __le64 db_reserved2;
811 __le64 db_free_next;
812 __le64 db_blkno;
813 __le64 db_parent_dinode;
814
815 struct ocfs2_block_check db_check;
816
817};
818
819
820
821
822
823
824
825
826struct ocfs2_dx_entry {
827 __le32 dx_major_hash;
828
829 __le32 dx_minor_hash;
830
831 __le64 dx_dirent_blk;
832
833};
834
835struct ocfs2_dx_entry_list {
836 __le32 de_reserved;
837 __le16 de_count;
838
839 __le16 de_num_used;
840
841 struct ocfs2_dx_entry de_entries[0];
842
843
844};
845
846#define OCFS2_DX_FLAG_INLINE 0x01
847
848
849
850
851
852
853
854
855struct ocfs2_dx_root_block {
856 __u8 dr_signature[8];
857 struct ocfs2_block_check dr_check;
858 __le16 dr_suballoc_slot;
859
860 __le16 dr_suballoc_bit;
861
862 __le32 dr_fs_generation;
863 __le64 dr_blkno;
864 __le64 dr_last_eb_blk;
865
866 __le32 dr_clusters;
867
868 __u8 dr_flags;
869 __u8 dr_reserved0;
870 __le16 dr_reserved1;
871 __le64 dr_dir_blkno;
872 __le32 dr_num_entries;
873
874
875 __le32 dr_reserved2;
876 __le64 dr_free_blk;
877
878 __le64 dr_suballoc_loc;
879
880
881
882
883 __le64 dr_reserved3[14];
884 union {
885 struct ocfs2_extent_list dr_list;
886
887
888 struct ocfs2_dx_entry_list dr_entries;
889
890
891
892 };
893};
894
895
896
897
898struct ocfs2_dx_leaf {
899 __u8 dl_signature[8];
900 struct ocfs2_block_check dl_check;
901 __le64 dl_blkno;
902 __le32 dl_fs_generation;
903 __le32 dl_reserved0;
904 __le64 dl_reserved1;
905 struct ocfs2_dx_entry_list dl_list;
906};
907
908
909
910
911
912
913#define OCFS2_MAX_BG_BITMAP_SIZE 256
914
915
916
917
918struct ocfs2_group_desc
919{
920 __u8 bg_signature[8];
921 __le16 bg_size;
922
923 __le16 bg_bits;
924
925 __le16 bg_free_bits_count;
926 __le16 bg_chain;
927 __le32 bg_generation;
928 __le32 bg_reserved1;
929 __le64 bg_next_group;
930
931 __le64 bg_parent_dinode;
932
933 __le64 bg_blkno;
934 struct ocfs2_block_check bg_check;
935 __le64 bg_reserved2;
936 union {
937 __u8 bg_bitmap[0];
938 struct {
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954 __u8 bg_bitmap_filler[OCFS2_MAX_BG_BITMAP_SIZE];
955 struct ocfs2_extent_list bg_list;
956 };
957 };
958
959};
960
961struct ocfs2_refcount_rec {
962 __le64 r_cpos;
963 __le32 r_clusters;
964 __le32 r_refcount;
965
966};
967#define OCFS2_32BIT_POS_MASK (0xffffffffULL)
968
969#define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
970#define OCFS2_REFCOUNT_TREE_FL (0x00000002)
971
972struct ocfs2_refcount_list {
973 __le16 rl_count;
974
975 __le16 rl_used;
976 __le32 rl_reserved2;
977 __le64 rl_reserved1;
978 struct ocfs2_refcount_rec rl_recs[0];
979};
980
981
982struct ocfs2_refcount_block {
983 __u8 rf_signature[8];
984 __le16 rf_suballoc_slot;
985
986 __le16 rf_suballoc_bit;
987
988 __le32 rf_fs_generation;
989 __le64 rf_blkno;
990 __le64 rf_parent;
991
992
993 struct ocfs2_block_check rf_check;
994 __le64 rf_last_eb_blk;
995 __le32 rf_count;
996
997 __le32 rf_flags;
998 __le32 rf_clusters;
999 __le32 rf_cpos;
1000 __le32 rf_generation;
1001
1002 __le32 rf_reserved0;
1003 __le64 rf_suballoc_loc;
1004
1005
1006
1007 __le64 rf_reserved1[6];
1008 union {
1009 struct ocfs2_refcount_list rf_records;
1010
1011 struct ocfs2_extent_list rf_list;
1012
1013
1014
1015 };
1016
1017};
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028struct ocfs2_xattr_entry {
1029 __le32 xe_name_hash;
1030 __le16 xe_name_offset;
1031
1032
1033 __u8 xe_name_len;
1034 __u8 xe_type;
1035
1036
1037 __le64 xe_value_size;
1038};
1039
1040
1041
1042
1043
1044
1045
1046struct ocfs2_xattr_header {
1047 __le16 xh_count;
1048
1049
1050 __le16 xh_free_start;
1051
1052 __le16 xh_name_value_len;
1053
1054 __le16 xh_num_buckets;
1055
1056
1057
1058 struct ocfs2_block_check xh_check;
1059
1060
1061
1062
1063
1064 struct ocfs2_xattr_entry xh_entries[0];
1065};
1066
1067
1068
1069
1070
1071
1072
1073struct ocfs2_xattr_value_root {
1074 __le32 xr_clusters;
1075 __le32 xr_reserved0;
1076 __le64 xr_last_eb_blk;
1077 struct ocfs2_extent_list xr_list;
1078};
1079
1080
1081
1082
1083
1084
1085
1086struct ocfs2_xattr_tree_root {
1087 __le32 xt_clusters;
1088 __le32 xt_reserved0;
1089 __le64 xt_last_eb_blk;
1090 struct ocfs2_extent_list xt_list;
1091};
1092
1093#define OCFS2_XATTR_INDEXED 0x1
1094#define OCFS2_HASH_SHIFT 5
1095#define OCFS2_XATTR_ROUND 3
1096#define OCFS2_XATTR_SIZE(size) (((size) + OCFS2_XATTR_ROUND) & \
1097 ~(OCFS2_XATTR_ROUND))
1098
1099#define OCFS2_XATTR_BUCKET_SIZE 4096
1100#define OCFS2_XATTR_MAX_BLOCKS_PER_BUCKET (OCFS2_XATTR_BUCKET_SIZE \
1101 / OCFS2_MIN_BLOCKSIZE)
1102
1103
1104
1105
1106struct ocfs2_xattr_block {
1107 __u8 xb_signature[8];
1108 __le16 xb_suballoc_slot;
1109
1110 __le16 xb_suballoc_bit;
1111
1112 __le32 xb_fs_generation;
1113 __le64 xb_blkno;
1114 struct ocfs2_block_check xb_check;
1115 __le16 xb_flags;
1116
1117 __le16 xb_reserved0;
1118 __le32 xb_reserved1;
1119 __le64 xb_suballoc_loc;
1120
1121
1122
1123 union {
1124 struct ocfs2_xattr_header xb_header;
1125
1126 struct ocfs2_xattr_tree_root xb_root;
1127
1128
1129 } xb_attrs;
1130};
1131
1132#define OCFS2_XATTR_ENTRY_LOCAL 0x80
1133#define OCFS2_XATTR_TYPE_MASK 0x7F
1134static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1135 int local)
1136{
1137 if (local)
1138 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1139 else
1140 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1141}
1142
1143static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1144{
1145 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1146}
1147
1148static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1149{
1150 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1151}
1152
1153static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1154{
1155 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1156}
1157
1158
1159
1160
1161
1162
1163#define OCFS2_GLOBAL_QMAGICS {\
1164 0x0cf52470, \
1165 0x0cf52471 \
1166}
1167
1168#define OCFS2_GLOBAL_QVERSIONS {\
1169 0, \
1170 0, \
1171}
1172
1173
1174
1175
1176
1177#define OCFS2_QBLK_RESERVED_SPACE 8
1178
1179
1180struct ocfs2_disk_dqheader {
1181 __le32 dqh_magic;
1182 __le32 dqh_version;
1183};
1184
1185#define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1186
1187
1188
1189struct ocfs2_global_disk_dqinfo {
1190 __le32 dqi_bgrace;
1191 __le32 dqi_igrace;
1192 __le32 dqi_syncms;
1193
1194 __le32 dqi_blocks;
1195 __le32 dqi_free_blk;
1196 __le32 dqi_free_entry;
1197
1198};
1199
1200
1201
1202struct ocfs2_global_disk_dqblk {
1203 __le32 dqb_id;
1204 __le32 dqb_use_count;
1205 __le64 dqb_ihardlimit;
1206 __le64 dqb_isoftlimit;
1207 __le64 dqb_curinodes;
1208 __le64 dqb_bhardlimit;
1209 __le64 dqb_bsoftlimit;
1210 __le64 dqb_curspace;
1211 __le64 dqb_btime;
1212 __le64 dqb_itime;
1213 __le64 dqb_pad1;
1214 __le64 dqb_pad2;
1215};
1216
1217
1218
1219
1220
1221
1222#define OCFS2_LOCAL_QMAGICS {\
1223 0x0cf524c0, \
1224 0x0cf524c1 \
1225}
1226
1227#define OCFS2_LOCAL_QVERSIONS {\
1228 0, \
1229 0, \
1230}
1231
1232
1233#define OLQF_CLEAN 0x0001
1234
1235
1236#define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1237
1238
1239
1240struct ocfs2_local_disk_dqinfo {
1241 __le32 dqi_flags;
1242 __le32 dqi_chunks;
1243
1244 __le32 dqi_blocks;
1245};
1246
1247
1248struct ocfs2_local_disk_chunk {
1249 __le32 dqc_free;
1250 __u8 dqc_bitmap[0];
1251
1252};
1253
1254
1255struct ocfs2_local_disk_dqblk {
1256 __le64 dqb_id;
1257 __le64 dqb_spacemod;
1258 __le64 dqb_inodemod;
1259};
1260
1261
1262
1263
1264
1265
1266struct ocfs2_disk_dqtrailer {
1267 struct ocfs2_block_check dq_check;
1268
1269};
1270
1271static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1272 void *buf)
1273{
1274 char *ptr = buf;
1275 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1276
1277 return (struct ocfs2_disk_dqtrailer *)ptr;
1278}
1279
1280#ifdef __KERNEL__
1281static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1282{
1283 return sb->s_blocksize -
1284 offsetof(struct ocfs2_dinode, id2.i_symlink);
1285}
1286
1287static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1288 struct ocfs2_dinode *di)
1289{
1290 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1291
1292 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1293 return sb->s_blocksize -
1294 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1295 xattrsize;
1296 else
1297 return sb->s_blocksize -
1298 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1299}
1300
1301static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1302{
1303 int size;
1304
1305 size = sb->s_blocksize -
1306 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1307
1308 return size / sizeof(struct ocfs2_extent_rec);
1309}
1310
1311static inline int ocfs2_extent_recs_per_inode_with_xattr(
1312 struct super_block *sb,
1313 struct ocfs2_dinode *di)
1314{
1315 int size;
1316 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1317
1318 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1319 size = sb->s_blocksize -
1320 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1321 xattrsize;
1322 else
1323 size = sb->s_blocksize -
1324 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1325
1326 return size / sizeof(struct ocfs2_extent_rec);
1327}
1328
1329static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1330{
1331 int size;
1332
1333 size = sb->s_blocksize -
1334 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1335
1336 return size / sizeof(struct ocfs2_extent_rec);
1337}
1338
1339static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1340{
1341 int size;
1342
1343 size = sb->s_blocksize -
1344 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1345
1346 return size / sizeof(struct ocfs2_chain_rec);
1347}
1348
1349static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1350{
1351 int size;
1352
1353 size = sb->s_blocksize -
1354 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1355
1356 return size / sizeof(struct ocfs2_extent_rec);
1357}
1358
1359static inline u16 ocfs2_extent_recs_per_gd(struct super_block *sb)
1360{
1361 int size;
1362
1363 size = sb->s_blocksize -
1364 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1365
1366 return size / sizeof(struct ocfs2_extent_rec);
1367}
1368
1369static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1370{
1371 int size;
1372
1373 size = sb->s_blocksize -
1374 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1375
1376 return size / sizeof(struct ocfs2_dx_entry);
1377}
1378
1379static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1380{
1381 int size;
1382
1383 size = sb->s_blocksize -
1384 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1385
1386 return size / sizeof(struct ocfs2_dx_entry);
1387}
1388
1389static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1390{
1391 u16 size;
1392
1393 size = sb->s_blocksize -
1394 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1395
1396 return size;
1397}
1398
1399static inline int ocfs2_group_bitmap_size(struct super_block *sb,
1400 int suballocator,
1401 u32 feature_incompat)
1402{
1403 int size = sb->s_blocksize -
1404 offsetof(struct ocfs2_group_desc, bg_bitmap);
1405
1406
1407
1408
1409
1410
1411
1412 if (suballocator &&
1413 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1414 size = OCFS2_MAX_BG_BITMAP_SIZE;
1415
1416 return size;
1417}
1418
1419static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1420{
1421 int size;
1422
1423 size = sb->s_blocksize -
1424 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1425
1426 return size / sizeof(struct ocfs2_truncate_rec);
1427}
1428
1429static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1430{
1431 u64 offset = OCFS2_BACKUP_SB_START;
1432
1433 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1434 offset <<= (2 * index);
1435 offset >>= sb->s_blocksize_bits;
1436 return offset;
1437 }
1438
1439 return 0;
1440
1441}
1442
1443static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1444{
1445 int size;
1446
1447 size = sb->s_blocksize -
1448 offsetof(struct ocfs2_xattr_block,
1449 xb_attrs.xb_root.xt_list.l_recs);
1450
1451 return size / sizeof(struct ocfs2_extent_rec);
1452}
1453
1454static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1455{
1456 int size;
1457
1458 size = sb->s_blocksize -
1459 offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1460
1461 return size / sizeof(struct ocfs2_extent_rec);
1462}
1463
1464static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1465{
1466 int size;
1467
1468 size = sb->s_blocksize -
1469 offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1470
1471 return size / sizeof(struct ocfs2_refcount_rec);
1472}
1473
1474static inline u32
1475ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1476{
1477 return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1478}
1479#else
1480static inline int ocfs2_fast_symlink_chars(int blocksize)
1481{
1482 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1483}
1484
1485static inline int ocfs2_max_inline_data_with_xattr(int blocksize,
1486 struct ocfs2_dinode *di)
1487{
1488 if (di && (di->i_dyn_features & OCFS2_INLINE_XATTR_FL))
1489 return blocksize -
1490 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1491 di->i_xattr_inline_size;
1492 else
1493 return blocksize -
1494 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1495}
1496
1497static inline int ocfs2_extent_recs_per_inode(int blocksize)
1498{
1499 int size;
1500
1501 size = blocksize -
1502 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1503
1504 return size / sizeof(struct ocfs2_extent_rec);
1505}
1506
1507static inline int ocfs2_chain_recs_per_inode(int blocksize)
1508{
1509 int size;
1510
1511 size = blocksize -
1512 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1513
1514 return size / sizeof(struct ocfs2_chain_rec);
1515}
1516
1517static inline int ocfs2_extent_recs_per_eb(int blocksize)
1518{
1519 int size;
1520
1521 size = blocksize -
1522 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1523
1524 return size / sizeof(struct ocfs2_extent_rec);
1525}
1526
1527static inline int ocfs2_extent_recs_per_gd(int blocksize)
1528{
1529 int size;
1530
1531 size = blocksize -
1532 offsetof(struct ocfs2_group_desc, bg_list.l_recs);
1533
1534 return size / sizeof(struct ocfs2_extent_rec);
1535}
1536
1537static inline int ocfs2_local_alloc_size(int blocksize)
1538{
1539 int size;
1540
1541 size = blocksize -
1542 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1543
1544 return size;
1545}
1546
1547static inline int ocfs2_group_bitmap_size(int blocksize,
1548 int suballocator,
1549 uint32_t feature_incompat)
1550{
1551 int size = sb->s_blocksize -
1552 offsetof(struct ocfs2_group_desc, bg_bitmap);
1553
1554
1555
1556
1557
1558
1559
1560 if (suballocator &&
1561 (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
1562 size = OCFS2_MAX_BG_BITMAP_SIZE;
1563
1564 return size;
1565}
1566
1567static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1568{
1569 int size;
1570
1571 size = blocksize -
1572 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1573
1574 return size / sizeof(struct ocfs2_truncate_rec);
1575}
1576
1577static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1578{
1579 uint64_t offset = OCFS2_BACKUP_SB_START;
1580
1581 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1582 offset <<= (2 * index);
1583 offset /= blocksize;
1584 return offset;
1585 }
1586
1587 return 0;
1588}
1589
1590static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1591{
1592 int size;
1593
1594 size = blocksize -
1595 offsetof(struct ocfs2_xattr_block,
1596 xb_attrs.xb_root.xt_list.l_recs);
1597
1598 return size / sizeof(struct ocfs2_extent_rec);
1599}
1600#endif
1601
1602
1603static inline int ocfs2_system_inode_is_global(int type)
1604{
1605 return ((type >= 0) &&
1606 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1607}
1608
1609static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1610 int type, int slot)
1611{
1612 int chars;
1613
1614
1615
1616
1617
1618
1619 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1620 chars = snprintf(buf, len, "%s",
1621 ocfs2_system_inodes[type].si_name);
1622 else
1623 chars = snprintf(buf, len,
1624 ocfs2_system_inodes[type].si_name,
1625 slot);
1626
1627 return chars;
1628}
1629
1630static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1631 umode_t mode)
1632{
1633 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1634}
1635
1636static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc *gd)
1637{
1638 if ((offsetof(struct ocfs2_group_desc, bg_bitmap) +
1639 le16_to_cpu(gd->bg_size)) !=
1640 offsetof(struct ocfs2_group_desc, bg_list))
1641 return 0;
1642
1643
1644
1645
1646 if (!gd->bg_list.l_next_free_rec)
1647 return 0;
1648 return 1;
1649}
1650#endif
1651
1652