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