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#define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \
105 | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \
106 | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
107
108
109
110
111
112
113#define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002
114
115
116
117
118
119
120#define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004
121
122
123#define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008
124
125
126#define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010
127
128
129
130
131
132
133
134
135
136
137#define OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG 0x0020
138
139
140#define OCFS2_FEATURE_INCOMPAT_INLINE_DATA 0x0040
141
142
143
144
145
146
147
148
149
150
151#define OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK 0x0080
152
153
154#define OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP 0x100
155
156
157#define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200
158
159
160#define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400
161
162
163#define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800
164
165
166#define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
167
168
169
170
171
172#define OCFS2_FEATURE_COMPAT_BACKUP_SB 0x0001
173
174
175
176
177#define OCFS2_FEATURE_COMPAT_JBD2_SB 0x0002
178
179
180
181
182#define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
183
184
185
186
187#define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
188#define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
189
190
191
192
193#define OCFS2_BACKUP_SB_START 1 << 30
194
195
196#define OCFS2_MAX_BACKUP_SUPERBLOCKS 6
197
198
199
200
201#define OCFS2_TUNEFS_INPROG_REMOVE_SLOT 0x0001
202
203
204
205
206#define OCFS2_VALID_FL (0x00000001)
207#define OCFS2_UNUSED2_FL (0x00000002)
208#define OCFS2_ORPHANED_FL (0x00000004)
209#define OCFS2_UNUSED3_FL (0x00000008)
210
211#define OCFS2_SYSTEM_FL (0x00000010)
212#define OCFS2_SUPER_BLOCK_FL (0x00000020)
213#define OCFS2_LOCAL_ALLOC_FL (0x00000040)
214#define OCFS2_BITMAP_FL (0x00000080)
215#define OCFS2_JOURNAL_FL (0x00000100)
216#define OCFS2_HEARTBEAT_FL (0x00000200)
217#define OCFS2_CHAIN_FL (0x00000400)
218#define OCFS2_DEALLOC_FL (0x00000800)
219#define OCFS2_QUOTA_FL (0x00001000)
220
221
222
223
224
225
226
227#define OCFS2_INLINE_DATA_FL (0x0001)
228#define OCFS2_HAS_XATTR_FL (0x0002)
229#define OCFS2_INLINE_XATTR_FL (0x0004)
230#define OCFS2_INDEXED_DIR_FL (0x0008)
231#define OCFS2_HAS_REFCOUNT_FL (0x0010)
232
233
234#define OCFS2_SECRM_FL (0x00000001)
235#define OCFS2_UNRM_FL (0x00000002)
236#define OCFS2_COMPR_FL (0x00000004)
237#define OCFS2_SYNC_FL (0x00000008)
238#define OCFS2_IMMUTABLE_FL (0x00000010)
239#define OCFS2_APPEND_FL (0x00000020)
240#define OCFS2_NODUMP_FL (0x00000040)
241#define OCFS2_NOATIME_FL (0x00000080)
242#define OCFS2_DIRSYNC_FL (0x00010000)
243
244#define OCFS2_FL_VISIBLE (0x000100FF)
245#define OCFS2_FL_MODIFIABLE (0x000100FF)
246
247
248
249
250#define OCFS2_EXT_UNWRITTEN (0x01)
251
252#define OCFS2_EXT_REFCOUNTED (0x02)
253
254
255
256
257
258
259#define OCFS2_IOC_GETFLAGS _IOR('f', 1, long)
260#define OCFS2_IOC_SETFLAGS _IOW('f', 2, long)
261#define OCFS2_IOC32_GETFLAGS _IOR('f', 1, int)
262#define OCFS2_IOC32_SETFLAGS _IOW('f', 2, int)
263
264
265
266
267
268
269
270
271struct ocfs2_space_resv {
272 __s16 l_type;
273 __s16 l_whence;
274 __s64 l_start;
275 __s64 l_len;
276 __s32 l_sysid;
277 __u32 l_pid;
278 __s32 l_pad[4];
279};
280
281#define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv)
282#define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv)
283#define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv)
284#define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv)
285#define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv)
286#define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv)
287#define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv)
288#define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv)
289
290
291struct ocfs2_new_group_input {
292 __u64 group;
293 __u32 clusters;
294 __u32 frees;
295 __u16 chain;
296 __u16 reserved1;
297 __u32 reserved2;
298};
299
300#define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int)
301#define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)
302#define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input)
303
304
305struct reflink_arguments {
306 __u64 old_path;
307 __u64 new_path;
308 __u64 preserve;
309};
310#define OCFS2_IOC_REFLINK _IOW('o', 4, struct reflink_arguments)
311
312
313
314
315
316#define OCFS2_JOURNAL_DIRTY_FL (0x00000001)
317
318
319
320
321#define OCFS2_ERROR_FS (0x00000001)
322
323
324#define OCFS2_MAX_FILENAME_LEN 255
325
326
327#define OCFS2_MAX_SLOTS 255
328
329
330#define OCFS2_INVALID_SLOT -1
331
332#define OCFS2_VOL_UUID_LEN 16
333#define OCFS2_MAX_VOL_LABEL_LEN 64
334
335
336#define OCFS2_STACK_LABEL_LEN 4
337#define OCFS2_CLUSTER_NAME_LEN 16
338
339
340#define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024)
341
342
343
344
345
346
347
348#define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8
349
350
351
352
353
354#define OCFS2_MIN_XATTR_INLINE_SIZE 256
355
356struct ocfs2_system_inode_info {
357 char *si_name;
358 int si_iflags;
359 int si_mode;
360};
361
362
363enum {
364 BAD_BLOCK_SYSTEM_INODE = 0,
365 GLOBAL_INODE_ALLOC_SYSTEM_INODE,
366 SLOT_MAP_SYSTEM_INODE,
367#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
368 HEARTBEAT_SYSTEM_INODE,
369 GLOBAL_BITMAP_SYSTEM_INODE,
370 USER_QUOTA_SYSTEM_INODE,
371 GROUP_QUOTA_SYSTEM_INODE,
372#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
373 ORPHAN_DIR_SYSTEM_INODE,
374 EXTENT_ALLOC_SYSTEM_INODE,
375 INODE_ALLOC_SYSTEM_INODE,
376 JOURNAL_SYSTEM_INODE,
377 LOCAL_ALLOC_SYSTEM_INODE,
378 TRUNCATE_LOG_SYSTEM_INODE,
379 LOCAL_USER_QUOTA_SYSTEM_INODE,
380 LOCAL_GROUP_QUOTA_SYSTEM_INODE,
381 NUM_SYSTEM_INODES
382};
383
384static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
385
386
387 [BAD_BLOCK_SYSTEM_INODE] = { "bad_blocks", 0, S_IFREG | 0644 },
388 [GLOBAL_INODE_ALLOC_SYSTEM_INODE] = { "global_inode_alloc", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
389
390
391 [SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
392 [HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
393 [GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
394 [USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
395 [GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
396
397
398 [ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
399 [EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
400 [INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
401 [JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
402 [LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
403 [TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
404 [LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
405 [LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
406};
407
408
409#define OCFS2_HB_NONE "heartbeat=none"
410#define OCFS2_HB_LOCAL "heartbeat=local"
411
412
413
414
415
416#define OCFS2_FT_UNKNOWN 0
417#define OCFS2_FT_REG_FILE 1
418#define OCFS2_FT_DIR 2
419#define OCFS2_FT_CHRDEV 3
420#define OCFS2_FT_BLKDEV 4
421#define OCFS2_FT_FIFO 5
422#define OCFS2_FT_SOCK 6
423#define OCFS2_FT_SYMLINK 7
424
425#define OCFS2_FT_MAX 8
426
427
428
429
430
431
432#define OCFS2_DIR_PAD 4
433#define OCFS2_DIR_ROUND (OCFS2_DIR_PAD - 1)
434#define OCFS2_DIR_MEMBER_LEN offsetof(struct ocfs2_dir_entry, name)
435#define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \
436 OCFS2_DIR_ROUND) & \
437 ~OCFS2_DIR_ROUND)
438#define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1)
439
440#define OCFS2_LINK_MAX 32000
441#define OCFS2_DX_LINK_MAX ((1U << 31) - 1U)
442#define OCFS2_LINKS_HI_SHIFT 16
443#define OCFS2_DX_ENTRIES_MAX (0xffffffffU)
444
445#define S_SHIFT 12
446static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = {
447 [S_IFREG >> S_SHIFT] = OCFS2_FT_REG_FILE,
448 [S_IFDIR >> S_SHIFT] = OCFS2_FT_DIR,
449 [S_IFCHR >> S_SHIFT] = OCFS2_FT_CHRDEV,
450 [S_IFBLK >> S_SHIFT] = OCFS2_FT_BLKDEV,
451 [S_IFIFO >> S_SHIFT] = OCFS2_FT_FIFO,
452 [S_IFSOCK >> S_SHIFT] = OCFS2_FT_SOCK,
453 [S_IFLNK >> S_SHIFT] = OCFS2_FT_SYMLINK,
454};
455
456
457
458
459
460#define OCFS2_RAW_SB(dinode) (&((dinode)->id2.i_super))
461
462
463
464
465
466
467struct ocfs2_block_check {
468 __le32 bc_crc32e;
469 __le16 bc_ecc;
470
471
472
473
474 __le16 bc_reserved1;
475
476};
477
478
479
480
481
482
483
484
485struct ocfs2_extent_rec {
486 __le32 e_cpos;
487 union {
488 __le32 e_int_clusters;
489 struct {
490 __le16 e_leaf_clusters;
491
492 __u8 e_reserved1;
493 __u8 e_flags;
494 };
495 };
496 __le64 e_blkno;
497
498};
499
500struct ocfs2_chain_rec {
501 __le32 c_free;
502 __le32 c_total;
503 __le64 c_blkno;
504};
505
506struct ocfs2_truncate_rec {
507 __le32 t_start;
508 __le32 t_clusters;
509};
510
511
512
513
514
515
516
517struct ocfs2_extent_list {
518 __le16 l_tree_depth;
519
520
521
522
523
524
525 __le16 l_count;
526 __le16 l_next_free_rec;
527 __le16 l_reserved1;
528 __le64 l_reserved2;
529
530 struct ocfs2_extent_rec l_recs[0];
531};
532
533
534
535
536
537
538struct ocfs2_chain_list {
539 __le16 cl_cpg;
540 __le16 cl_bpc;
541 __le16 cl_count;
542 __le16 cl_next_free_rec;
543 __le64 cl_reserved1;
544 struct ocfs2_chain_rec cl_recs[0];
545};
546
547
548
549
550
551
552struct ocfs2_truncate_log {
553 __le16 tl_count;
554 __le16 tl_used;
555 __le32 tl_reserved1;
556 struct ocfs2_truncate_rec tl_recs[0];
557};
558
559
560
561
562struct ocfs2_extent_block
563{
564 __u8 h_signature[8];
565 struct ocfs2_block_check h_check;
566 __le16 h_suballoc_slot;
567
568 __le16 h_suballoc_bit;
569
570 __le32 h_fs_generation;
571 __le64 h_blkno;
572 __le64 h_reserved3;
573 __le64 h_next_leaf_blk;
574
575
576 struct ocfs2_extent_list h_list;
577
578};
579
580
581
582
583
584
585struct ocfs2_slot_map {
586 __le16 sm_slots[0];
587
588
589
590
591};
592
593struct ocfs2_extended_slot {
594 __u8 es_valid;
595 __u8 es_reserved1[3];
596 __le32 es_node_num;
597
598};
599
600
601
602
603
604
605
606struct ocfs2_slot_map_extended {
607 struct ocfs2_extended_slot se_slots[0];
608
609
610
611
612};
613
614struct ocfs2_cluster_info {
615 __u8 ci_stack[OCFS2_STACK_LABEL_LEN];
616 __le32 ci_reserved;
617 __u8 ci_cluster[OCFS2_CLUSTER_NAME_LEN];
618
619};
620
621
622
623
624
625
626struct ocfs2_super_block {
627 __le16 s_major_rev_level;
628 __le16 s_minor_rev_level;
629 __le16 s_mnt_count;
630 __le16 s_max_mnt_count;
631 __le16 s_state;
632 __le16 s_errors;
633 __le32 s_checkinterval;
634 __le64 s_lastcheck;
635 __le32 s_creator_os;
636 __le32 s_feature_compat;
637 __le32 s_feature_incompat;
638 __le32 s_feature_ro_compat;
639 __le64 s_root_blkno;
640
641 __le64 s_system_dir_blkno;
642
643 __le32 s_blocksize_bits;
644 __le32 s_clustersize_bits;
645 __le16 s_max_slots;
646
647 __le16 s_tunefs_flag;
648 __le32 s_uuid_hash;
649 __le64 s_first_cluster_group;
650
651 __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN];
652 __u8 s_uuid[OCFS2_VOL_UUID_LEN];
653 struct ocfs2_cluster_info s_cluster_info;
654
655
656 __le16 s_xattr_inline_size;
657
658 __le16 s_reserved0;
659 __le32 s_dx_seed[3];
660
661 __le64 s_reserved2[15];
662
663
664
665
666
667
668
669
670
671
672};
673
674
675
676
677
678
679struct ocfs2_local_alloc
680{
681 __le32 la_bm_off;
682 __le16 la_size;
683 __le16 la_reserved1;
684 __le64 la_reserved2;
685 __u8 la_bitmap[0];
686};
687
688
689
690
691
692struct ocfs2_inline_data
693{
694 __le16 id_count;
695
696 __le16 id_reserved0;
697 __le32 id_reserved1;
698 __u8 id_data[0];
699};
700
701
702
703
704struct ocfs2_dinode {
705 __u8 i_signature[8];
706 __le32 i_generation;
707 __le16 i_suballoc_slot;
708
709 __le16 i_suballoc_bit;
710
711 __le16 i_links_count_hi;
712 __le16 i_xattr_inline_size;
713 __le32 i_clusters;
714 __le32 i_uid;
715 __le32 i_gid;
716 __le64 i_size;
717 __le16 i_mode;
718 __le16 i_links_count;
719 __le32 i_flags;
720 __le64 i_atime;
721 __le64 i_ctime;
722 __le64 i_mtime;
723 __le64 i_dtime;
724 __le64 i_blkno;
725 __le64 i_last_eb_blk;
726
727 __le32 i_fs_generation;
728 __le32 i_atime_nsec;
729 __le32 i_ctime_nsec;
730 __le32 i_mtime_nsec;
731 __le32 i_attr;
732 __le16 i_orphaned_slot;
733
734 __le16 i_dyn_features;
735 __le64 i_xattr_loc;
736 struct ocfs2_block_check i_check;
737 __le64 i_dx_root;
738 __le64 i_refcount_loc;
739 __le64 i_reserved2[4];
740 union {
741 __le64 i_pad1;
742
743 struct {
744 __le64 i_rdev;
745 } dev1;
746 struct {
747
748 __le32 i_used;
749 __le32 i_total;
750
751 } bitmap1;
752 struct {
753
754 __le32 ij_flags;
755 __le32 ij_recovery_generation;
756
757
758
759 } journal1;
760 } id1;
761 union {
762 struct ocfs2_super_block i_super;
763 struct ocfs2_local_alloc i_lab;
764 struct ocfs2_chain_list i_chain;
765 struct ocfs2_extent_list i_list;
766 struct ocfs2_truncate_log i_dealloc;
767 struct ocfs2_inline_data i_data;
768 __u8 i_symlink[0];
769 } id2;
770
771};
772
773
774
775
776
777
778struct ocfs2_dir_entry {
779 __le64 inode;
780 __le16 rec_len;
781 __u8 name_len;
782 __u8 file_type;
783 char name[OCFS2_MAX_FILENAME_LEN];
784
785} __attribute__ ((packed));
786
787
788
789
790
791
792
793
794
795struct ocfs2_dir_block_trailer {
796 __le64 db_compat_inode;
797
798 __le16 db_compat_rec_len;
799
800 __u8 db_compat_name_len;
801 __u8 db_reserved0;
802 __le16 db_reserved1;
803 __le16 db_free_rec_len;
804
805 __u8 db_signature[8];
806 __le64 db_reserved2;
807 __le64 db_free_next;
808 __le64 db_blkno;
809 __le64 db_parent_dinode;
810
811 struct ocfs2_block_check db_check;
812
813};
814
815
816
817
818
819
820
821
822struct ocfs2_dx_entry {
823 __le32 dx_major_hash;
824
825 __le32 dx_minor_hash;
826
827 __le64 dx_dirent_blk;
828
829};
830
831struct ocfs2_dx_entry_list {
832 __le32 de_reserved;
833 __le16 de_count;
834
835 __le16 de_num_used;
836
837 struct ocfs2_dx_entry de_entries[0];
838
839
840};
841
842#define OCFS2_DX_FLAG_INLINE 0x01
843
844
845
846
847
848
849
850
851struct ocfs2_dx_root_block {
852 __u8 dr_signature[8];
853 struct ocfs2_block_check dr_check;
854 __le16 dr_suballoc_slot;
855
856 __le16 dr_suballoc_bit;
857
858 __le32 dr_fs_generation;
859 __le64 dr_blkno;
860 __le64 dr_last_eb_blk;
861
862 __le32 dr_clusters;
863
864 __u8 dr_flags;
865 __u8 dr_reserved0;
866 __le16 dr_reserved1;
867 __le64 dr_dir_blkno;
868 __le32 dr_num_entries;
869
870
871 __le32 dr_reserved2;
872 __le64 dr_free_blk;
873
874 __le64 dr_reserved3[15];
875 union {
876 struct ocfs2_extent_list dr_list;
877
878
879 struct ocfs2_dx_entry_list dr_entries;
880
881
882
883 };
884};
885
886
887
888
889struct ocfs2_dx_leaf {
890 __u8 dl_signature[8];
891 struct ocfs2_block_check dl_check;
892 __le64 dl_blkno;
893 __le32 dl_fs_generation;
894 __le32 dl_reserved0;
895 __le64 dl_reserved1;
896 struct ocfs2_dx_entry_list dl_list;
897};
898
899
900
901
902struct ocfs2_group_desc
903{
904 __u8 bg_signature[8];
905 __le16 bg_size;
906
907 __le16 bg_bits;
908
909 __le16 bg_free_bits_count;
910 __le16 bg_chain;
911 __le32 bg_generation;
912 __le32 bg_reserved1;
913 __le64 bg_next_group;
914
915 __le64 bg_parent_dinode;
916
917 __le64 bg_blkno;
918 struct ocfs2_block_check bg_check;
919 __le64 bg_reserved2;
920 __u8 bg_bitmap[0];
921};
922
923struct ocfs2_refcount_rec {
924 __le64 r_cpos;
925 __le32 r_clusters;
926 __le32 r_refcount;
927
928};
929#define OCFS2_32BIT_POS_MASK (0xffffffffULL)
930
931#define OCFS2_REFCOUNT_LEAF_FL (0x00000001)
932#define OCFS2_REFCOUNT_TREE_FL (0x00000002)
933
934struct ocfs2_refcount_list {
935 __le16 rl_count;
936
937 __le16 rl_used;
938 __le32 rl_reserved2;
939 __le64 rl_reserved1;
940 struct ocfs2_refcount_rec rl_recs[0];
941};
942
943
944struct ocfs2_refcount_block {
945 __u8 rf_signature[8];
946 __le16 rf_suballoc_slot;
947
948 __le16 rf_suballoc_bit;
949
950 __le32 rf_fs_generation;
951 __le64 rf_blkno;
952 __le64 rf_parent;
953
954
955 struct ocfs2_block_check rf_check;
956 __le64 rf_last_eb_blk;
957 __le32 rf_count;
958
959 __le32 rf_flags;
960 __le32 rf_clusters;
961 __le32 rf_cpos;
962 __le32 rf_generation;
963
964 __le32 rf_reserved0;
965 __le64 rf_reserved1[7];
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[0];
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_reserved2;
1078 union {
1079 struct ocfs2_xattr_header xb_header;
1080
1081 struct ocfs2_xattr_tree_root xb_root;
1082
1083
1084 } xb_attrs;
1085};
1086
1087#define OCFS2_XATTR_ENTRY_LOCAL 0x80
1088#define OCFS2_XATTR_TYPE_MASK 0x7F
1089static inline void ocfs2_xattr_set_local(struct ocfs2_xattr_entry *xe,
1090 int local)
1091{
1092 if (local)
1093 xe->xe_type |= OCFS2_XATTR_ENTRY_LOCAL;
1094 else
1095 xe->xe_type &= ~OCFS2_XATTR_ENTRY_LOCAL;
1096}
1097
1098static inline int ocfs2_xattr_is_local(struct ocfs2_xattr_entry *xe)
1099{
1100 return xe->xe_type & OCFS2_XATTR_ENTRY_LOCAL;
1101}
1102
1103static inline void ocfs2_xattr_set_type(struct ocfs2_xattr_entry *xe, int type)
1104{
1105 xe->xe_type |= type & OCFS2_XATTR_TYPE_MASK;
1106}
1107
1108static inline int ocfs2_xattr_get_type(struct ocfs2_xattr_entry *xe)
1109{
1110 return xe->xe_type & OCFS2_XATTR_TYPE_MASK;
1111}
1112
1113
1114
1115
1116
1117
1118#define OCFS2_GLOBAL_QMAGICS {\
1119 0x0cf52470, \
1120 0x0cf52471 \
1121}
1122
1123#define OCFS2_GLOBAL_QVERSIONS {\
1124 0, \
1125 0, \
1126}
1127
1128
1129
1130
1131
1132#define OCFS2_QBLK_RESERVED_SPACE 8
1133
1134
1135struct ocfs2_disk_dqheader {
1136 __le32 dqh_magic;
1137 __le32 dqh_version;
1138};
1139
1140#define OCFS2_GLOBAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1141
1142
1143
1144struct ocfs2_global_disk_dqinfo {
1145 __le32 dqi_bgrace;
1146 __le32 dqi_igrace;
1147 __le32 dqi_syncms;
1148
1149 __le32 dqi_blocks;
1150 __le32 dqi_free_blk;
1151 __le32 dqi_free_entry;
1152
1153};
1154
1155
1156
1157struct ocfs2_global_disk_dqblk {
1158 __le32 dqb_id;
1159 __le32 dqb_use_count;
1160 __le64 dqb_ihardlimit;
1161 __le64 dqb_isoftlimit;
1162 __le64 dqb_curinodes;
1163 __le64 dqb_bhardlimit;
1164 __le64 dqb_bsoftlimit;
1165 __le64 dqb_curspace;
1166 __le64 dqb_btime;
1167 __le64 dqb_itime;
1168 __le64 dqb_pad1;
1169 __le64 dqb_pad2;
1170};
1171
1172
1173
1174
1175
1176
1177#define OCFS2_LOCAL_QMAGICS {\
1178 0x0cf524c0, \
1179 0x0cf524c1 \
1180}
1181
1182#define OCFS2_LOCAL_QVERSIONS {\
1183 0, \
1184 0, \
1185}
1186
1187
1188#define OLQF_CLEAN 0x0001
1189
1190
1191#define OCFS2_LOCAL_INFO_OFF (sizeof(struct ocfs2_disk_dqheader))
1192
1193
1194
1195struct ocfs2_local_disk_dqinfo {
1196 __le32 dqi_flags;
1197 __le32 dqi_chunks;
1198
1199 __le32 dqi_blocks;
1200};
1201
1202
1203struct ocfs2_local_disk_chunk {
1204 __le32 dqc_free;
1205 u8 dqc_bitmap[0];
1206
1207};
1208
1209
1210struct ocfs2_local_disk_dqblk {
1211 __le64 dqb_id;
1212 __le64 dqb_spacemod;
1213 __le64 dqb_inodemod;
1214};
1215
1216
1217
1218
1219
1220
1221struct ocfs2_disk_dqtrailer {
1222 struct ocfs2_block_check dq_check;
1223
1224};
1225
1226static inline struct ocfs2_disk_dqtrailer *ocfs2_block_dqtrailer(int blocksize,
1227 void *buf)
1228{
1229 char *ptr = buf;
1230 ptr += blocksize - OCFS2_QBLK_RESERVED_SPACE;
1231
1232 return (struct ocfs2_disk_dqtrailer *)ptr;
1233}
1234
1235#ifdef __KERNEL__
1236static inline int ocfs2_fast_symlink_chars(struct super_block *sb)
1237{
1238 return sb->s_blocksize -
1239 offsetof(struct ocfs2_dinode, id2.i_symlink);
1240}
1241
1242static inline int ocfs2_max_inline_data_with_xattr(struct super_block *sb,
1243 struct ocfs2_dinode *di)
1244{
1245 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1246
1247 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1248 return sb->s_blocksize -
1249 offsetof(struct ocfs2_dinode, id2.i_data.id_data) -
1250 xattrsize;
1251 else
1252 return sb->s_blocksize -
1253 offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1254}
1255
1256static inline int ocfs2_extent_recs_per_inode(struct super_block *sb)
1257{
1258 int size;
1259
1260 size = sb->s_blocksize -
1261 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1262
1263 return size / sizeof(struct ocfs2_extent_rec);
1264}
1265
1266static inline int ocfs2_extent_recs_per_inode_with_xattr(
1267 struct super_block *sb,
1268 struct ocfs2_dinode *di)
1269{
1270 int size;
1271 unsigned int xattrsize = le16_to_cpu(di->i_xattr_inline_size);
1272
1273 if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_XATTR_FL)
1274 size = sb->s_blocksize -
1275 offsetof(struct ocfs2_dinode, id2.i_list.l_recs) -
1276 xattrsize;
1277 else
1278 size = sb->s_blocksize -
1279 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1280
1281 return size / sizeof(struct ocfs2_extent_rec);
1282}
1283
1284static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb)
1285{
1286 int size;
1287
1288 size = sb->s_blocksize -
1289 offsetof(struct ocfs2_dx_root_block, dr_list.l_recs);
1290
1291 return size / sizeof(struct ocfs2_extent_rec);
1292}
1293
1294static inline int ocfs2_chain_recs_per_inode(struct super_block *sb)
1295{
1296 int size;
1297
1298 size = sb->s_blocksize -
1299 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1300
1301 return size / sizeof(struct ocfs2_chain_rec);
1302}
1303
1304static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb)
1305{
1306 int size;
1307
1308 size = sb->s_blocksize -
1309 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1310
1311 return size / sizeof(struct ocfs2_extent_rec);
1312}
1313
1314static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb)
1315{
1316 int size;
1317
1318 size = sb->s_blocksize -
1319 offsetof(struct ocfs2_dx_leaf, dl_list.de_entries);
1320
1321 return size / sizeof(struct ocfs2_dx_entry);
1322}
1323
1324static inline int ocfs2_dx_entries_per_root(struct super_block *sb)
1325{
1326 int size;
1327
1328 size = sb->s_blocksize -
1329 offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries);
1330
1331 return size / sizeof(struct ocfs2_dx_entry);
1332}
1333
1334static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
1335{
1336 u16 size;
1337
1338 size = sb->s_blocksize -
1339 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1340
1341 return size;
1342}
1343
1344static inline int ocfs2_group_bitmap_size(struct super_block *sb)
1345{
1346 int size;
1347
1348 size = sb->s_blocksize -
1349 offsetof(struct ocfs2_group_desc, bg_bitmap);
1350
1351 return size;
1352}
1353
1354static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb)
1355{
1356 int size;
1357
1358 size = sb->s_blocksize -
1359 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1360
1361 return size / sizeof(struct ocfs2_truncate_rec);
1362}
1363
1364static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index)
1365{
1366 u64 offset = OCFS2_BACKUP_SB_START;
1367
1368 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1369 offset <<= (2 * index);
1370 offset >>= sb->s_blocksize_bits;
1371 return offset;
1372 }
1373
1374 return 0;
1375
1376}
1377
1378static inline u16 ocfs2_xattr_recs_per_xb(struct super_block *sb)
1379{
1380 int size;
1381
1382 size = sb->s_blocksize -
1383 offsetof(struct ocfs2_xattr_block,
1384 xb_attrs.xb_root.xt_list.l_recs);
1385
1386 return size / sizeof(struct ocfs2_extent_rec);
1387}
1388
1389static inline u16 ocfs2_extent_recs_per_rb(struct super_block *sb)
1390{
1391 int size;
1392
1393 size = sb->s_blocksize -
1394 offsetof(struct ocfs2_refcount_block, rf_list.l_recs);
1395
1396 return size / sizeof(struct ocfs2_extent_rec);
1397}
1398
1399static inline u16 ocfs2_refcount_recs_per_rb(struct super_block *sb)
1400{
1401 int size;
1402
1403 size = sb->s_blocksize -
1404 offsetof(struct ocfs2_refcount_block, rf_records.rl_recs);
1405
1406 return size / sizeof(struct ocfs2_refcount_rec);
1407}
1408
1409static inline u32
1410ocfs2_get_ref_rec_low_cpos(const struct ocfs2_refcount_rec *rec)
1411{
1412 return le64_to_cpu(rec->r_cpos) & OCFS2_32BIT_POS_MASK;
1413}
1414#else
1415static inline int ocfs2_fast_symlink_chars(int blocksize)
1416{
1417 return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);
1418}
1419
1420static inline int ocfs2_max_inline_data(int blocksize)
1421{
1422 return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);
1423}
1424
1425static inline int ocfs2_extent_recs_per_inode(int blocksize)
1426{
1427 int size;
1428
1429 size = blocksize -
1430 offsetof(struct ocfs2_dinode, id2.i_list.l_recs);
1431
1432 return size / sizeof(struct ocfs2_extent_rec);
1433}
1434
1435static inline int ocfs2_chain_recs_per_inode(int blocksize)
1436{
1437 int size;
1438
1439 size = blocksize -
1440 offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs);
1441
1442 return size / sizeof(struct ocfs2_chain_rec);
1443}
1444
1445static inline int ocfs2_extent_recs_per_eb(int blocksize)
1446{
1447 int size;
1448
1449 size = blocksize -
1450 offsetof(struct ocfs2_extent_block, h_list.l_recs);
1451
1452 return size / sizeof(struct ocfs2_extent_rec);
1453}
1454
1455static inline int ocfs2_local_alloc_size(int blocksize)
1456{
1457 int size;
1458
1459 size = blocksize -
1460 offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap);
1461
1462 return size;
1463}
1464
1465static inline int ocfs2_group_bitmap_size(int blocksize)
1466{
1467 int size;
1468
1469 size = blocksize -
1470 offsetof(struct ocfs2_group_desc, bg_bitmap);
1471
1472 return size;
1473}
1474
1475static inline int ocfs2_truncate_recs_per_inode(int blocksize)
1476{
1477 int size;
1478
1479 size = blocksize -
1480 offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs);
1481
1482 return size / sizeof(struct ocfs2_truncate_rec);
1483}
1484
1485static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index)
1486{
1487 uint64_t offset = OCFS2_BACKUP_SB_START;
1488
1489 if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) {
1490 offset <<= (2 * index);
1491 offset /= blocksize;
1492 return offset;
1493 }
1494
1495 return 0;
1496}
1497
1498static inline int ocfs2_xattr_recs_per_xb(int blocksize)
1499{
1500 int size;
1501
1502 size = blocksize -
1503 offsetof(struct ocfs2_xattr_block,
1504 xb_attrs.xb_root.xt_list.l_recs);
1505
1506 return size / sizeof(struct ocfs2_extent_rec);
1507}
1508#endif
1509
1510
1511static inline int ocfs2_system_inode_is_global(int type)
1512{
1513 return ((type >= 0) &&
1514 (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));
1515}
1516
1517static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
1518 int type, int slot)
1519{
1520 int chars;
1521
1522
1523
1524
1525
1526
1527 if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
1528 chars = snprintf(buf, len, "%s",
1529 ocfs2_system_inodes[type].si_name);
1530 else
1531 chars = snprintf(buf, len,
1532 ocfs2_system_inodes[type].si_name,
1533 slot);
1534
1535 return chars;
1536}
1537
1538static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de,
1539 umode_t mode)
1540{
1541 de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1542}
1543
1544#endif
1545
1546