diff options
Diffstat (limited to 'fs/ocfs2/ocfs2_fs.h')
-rw-r--r-- | fs/ocfs2/ocfs2_fs.h | 144 |
1 files changed, 121 insertions, 23 deletions
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index bb37218a7978..33f1c9a8258d 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h | |||
@@ -100,7 +100,8 @@ | |||
100 | | OCFS2_FEATURE_INCOMPAT_XATTR \ | 100 | | OCFS2_FEATURE_INCOMPAT_XATTR \ |
101 | | OCFS2_FEATURE_INCOMPAT_META_ECC \ | 101 | | OCFS2_FEATURE_INCOMPAT_META_ECC \ |
102 | | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \ | 102 | | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS \ |
103 | | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE) | 103 | | OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE \ |
104 | | OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG) | ||
104 | #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ | 105 | #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ |
105 | | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ | 106 | | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ |
106 | | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) | 107 | | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) |
@@ -165,6 +166,9 @@ | |||
165 | /* Refcount tree support */ | 166 | /* Refcount tree support */ |
166 | #define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000 | 167 | #define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000 |
167 | 168 | ||
169 | /* Discontigous block groups */ | ||
170 | #define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000 | ||
171 | |||
168 | /* | 172 | /* |
169 | * backup superblock flag is used to indicate that this volume | 173 | * backup superblock flag is used to indicate that this volume |
170 | * has backup superblocks. | 174 | * has backup superblocks. |
@@ -283,14 +287,6 @@ | |||
283 | #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) | 287 | #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) |
284 | 288 | ||
285 | /* | 289 | /* |
286 | * Default local alloc size (in megabytes) | ||
287 | * | ||
288 | * The value chosen should be such that most allocations, including new | ||
289 | * block groups, use local alloc. | ||
290 | */ | ||
291 | #define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8 | ||
292 | |||
293 | /* | ||
294 | * Inline extended attribute size (in bytes) | 290 | * Inline extended attribute size (in bytes) |
295 | * The value chosen should be aligned to 16 byte boundaries. | 291 | * The value chosen should be aligned to 16 byte boundaries. |
296 | */ | 292 | */ |
@@ -512,7 +508,10 @@ struct ocfs2_extent_block | |||
512 | block group */ | 508 | block group */ |
513 | __le32 h_fs_generation; /* Must match super block */ | 509 | __le32 h_fs_generation; /* Must match super block */ |
514 | __le64 h_blkno; /* Offset on disk, in blocks */ | 510 | __le64 h_blkno; /* Offset on disk, in blocks */ |
515 | /*20*/ __le64 h_reserved3; | 511 | /*20*/ __le64 h_suballoc_loc; /* Suballocator block group this |
512 | eb belongs to. Only valid | ||
513 | if allocated from a | ||
514 | discontiguous block group */ | ||
516 | __le64 h_next_leaf_blk; /* Offset on disk, in blocks, | 515 | __le64 h_next_leaf_blk; /* Offset on disk, in blocks, |
517 | of next leaf header pointing | 516 | of next leaf header pointing |
518 | to data */ | 517 | to data */ |
@@ -679,7 +678,11 @@ struct ocfs2_dinode { | |||
679 | /*80*/ struct ocfs2_block_check i_check; /* Error checking */ | 678 | /*80*/ struct ocfs2_block_check i_check; /* Error checking */ |
680 | /*88*/ __le64 i_dx_root; /* Pointer to dir index root block */ | 679 | /*88*/ __le64 i_dx_root; /* Pointer to dir index root block */ |
681 | /*90*/ __le64 i_refcount_loc; | 680 | /*90*/ __le64 i_refcount_loc; |
682 | __le64 i_reserved2[4]; | 681 | __le64 i_suballoc_loc; /* Suballocator block group this |
682 | inode belongs to. Only valid | ||
683 | if allocated from a | ||
684 | discontiguous block group */ | ||
685 | /*A0*/ __le64 i_reserved2[3]; | ||
683 | /*B8*/ union { | 686 | /*B8*/ union { |
684 | __le64 i_pad1; /* Generic way to refer to this | 687 | __le64 i_pad1; /* Generic way to refer to this |
685 | 64bit union */ | 688 | 64bit union */ |
@@ -814,7 +817,12 @@ struct ocfs2_dx_root_block { | |||
814 | __le32 dr_reserved2; | 817 | __le32 dr_reserved2; |
815 | __le64 dr_free_blk; /* Pointer to head of free | 818 | __le64 dr_free_blk; /* Pointer to head of free |
816 | * unindexed block list. */ | 819 | * unindexed block list. */ |
817 | __le64 dr_reserved3[15]; | 820 | __le64 dr_suballoc_loc; /* Suballocator block group |
821 | this root belongs to. | ||
822 | Only valid if allocated | ||
823 | from a discontiguous | ||
824 | block group */ | ||
825 | __le64 dr_reserved3[14]; | ||
818 | union { | 826 | union { |
819 | struct ocfs2_extent_list dr_list; /* Keep this aligned to 128 | 827 | struct ocfs2_extent_list dr_list; /* Keep this aligned to 128 |
820 | * bits for maximum space | 828 | * bits for maximum space |
@@ -840,6 +848,13 @@ struct ocfs2_dx_leaf { | |||
840 | }; | 848 | }; |
841 | 849 | ||
842 | /* | 850 | /* |
851 | * Largest bitmap for a block (suballocator) group in bytes. This limit | ||
852 | * does not affect cluster groups (global allocator). Cluster group | ||
853 | * bitmaps run to the end of the block. | ||
854 | */ | ||
855 | #define OCFS2_MAX_BG_BITMAP_SIZE 256 | ||
856 | |||
857 | /* | ||
843 | * On disk allocator group structure for OCFS2 | 858 | * On disk allocator group structure for OCFS2 |
844 | */ | 859 | */ |
845 | struct ocfs2_group_desc | 860 | struct ocfs2_group_desc |
@@ -860,7 +875,29 @@ struct ocfs2_group_desc | |||
860 | __le64 bg_blkno; /* Offset on disk, in blocks */ | 875 | __le64 bg_blkno; /* Offset on disk, in blocks */ |
861 | /*30*/ struct ocfs2_block_check bg_check; /* Error checking */ | 876 | /*30*/ struct ocfs2_block_check bg_check; /* Error checking */ |
862 | __le64 bg_reserved2; | 877 | __le64 bg_reserved2; |
863 | /*40*/ __u8 bg_bitmap[0]; | 878 | /*40*/ union { |
879 | __u8 bg_bitmap[0]; | ||
880 | struct { | ||
881 | /* | ||
882 | * Block groups may be discontiguous when | ||
883 | * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set. | ||
884 | * The extents of a discontigous block group are | ||
885 | * stored in bg_list. It is a flat list. | ||
886 | * l_tree_depth must always be zero. A | ||
887 | * discontiguous group is signified by a non-zero | ||
888 | * bg_list->l_next_free_rec. Only block groups | ||
889 | * can be discontiguous; Cluster groups cannot. | ||
890 | * We've never made a block group with more than | ||
891 | * 2048 blocks (256 bytes of bg_bitmap). This | ||
892 | * codifies that limit so that we can fit bg_list. | ||
893 | * bg_size of a discontiguous block group will | ||
894 | * be 256 to match bg_bitmap_filler. | ||
895 | */ | ||
896 | __u8 bg_bitmap_filler[OCFS2_MAX_BG_BITMAP_SIZE]; | ||
897 | /*140*/ struct ocfs2_extent_list bg_list; | ||
898 | }; | ||
899 | }; | ||
900 | /* Actual on-disk size is one block */ | ||
864 | }; | 901 | }; |
865 | 902 | ||
866 | struct ocfs2_refcount_rec { | 903 | struct ocfs2_refcount_rec { |
@@ -905,7 +942,11 @@ struct ocfs2_refcount_block { | |||
905 | /*40*/ __le32 rf_generation; /* generation number. all be the same | 942 | /*40*/ __le32 rf_generation; /* generation number. all be the same |
906 | * for the same refcount tree. */ | 943 | * for the same refcount tree. */ |
907 | __le32 rf_reserved0; | 944 | __le32 rf_reserved0; |
908 | __le64 rf_reserved1[7]; | 945 | __le64 rf_suballoc_loc; /* Suballocator block group this |
946 | refcount block belongs to. Only | ||
947 | valid if allocated from a | ||
948 | discontiguous block group */ | ||
949 | /*50*/ __le64 rf_reserved1[6]; | ||
909 | /*80*/ union { | 950 | /*80*/ union { |
910 | struct ocfs2_refcount_list rf_records; /* List of refcount | 951 | struct ocfs2_refcount_list rf_records; /* List of refcount |
911 | records */ | 952 | records */ |
@@ -1017,7 +1058,10 @@ struct ocfs2_xattr_block { | |||
1017 | real xattr or a xattr tree. */ | 1058 | real xattr or a xattr tree. */ |
1018 | __le16 xb_reserved0; | 1059 | __le16 xb_reserved0; |
1019 | __le32 xb_reserved1; | 1060 | __le32 xb_reserved1; |
1020 | __le64 xb_reserved2; | 1061 | __le64 xb_suballoc_loc; /* Suballocator block group this |
1062 | xattr block belongs to. Only | ||
1063 | valid if allocated from a | ||
1064 | discontiguous block group */ | ||
1021 | /*30*/ union { | 1065 | /*30*/ union { |
1022 | struct ocfs2_xattr_header xb_header; /* xattr header if this | 1066 | struct ocfs2_xattr_header xb_header; /* xattr header if this |
1023 | block contains xattr */ | 1067 | block contains xattr */ |
@@ -1254,6 +1298,16 @@ static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb) | |||
1254 | return size / sizeof(struct ocfs2_extent_rec); | 1298 | return size / sizeof(struct ocfs2_extent_rec); |
1255 | } | 1299 | } |
1256 | 1300 | ||
1301 | static inline u16 ocfs2_extent_recs_per_gd(struct super_block *sb) | ||
1302 | { | ||
1303 | int size; | ||
1304 | |||
1305 | size = sb->s_blocksize - | ||
1306 | offsetof(struct ocfs2_group_desc, bg_list.l_recs); | ||
1307 | |||
1308 | return size / sizeof(struct ocfs2_extent_rec); | ||
1309 | } | ||
1310 | |||
1257 | static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb) | 1311 | static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb) |
1258 | { | 1312 | { |
1259 | int size; | 1313 | int size; |
@@ -1284,13 +1338,23 @@ static inline u16 ocfs2_local_alloc_size(struct super_block *sb) | |||
1284 | return size; | 1338 | return size; |
1285 | } | 1339 | } |
1286 | 1340 | ||
1287 | static inline int ocfs2_group_bitmap_size(struct super_block *sb) | 1341 | static inline int ocfs2_group_bitmap_size(struct super_block *sb, |
1342 | int suballocator, | ||
1343 | u32 feature_incompat) | ||
1288 | { | 1344 | { |
1289 | int size; | 1345 | int size = sb->s_blocksize - |
1290 | |||
1291 | size = sb->s_blocksize - | ||
1292 | offsetof(struct ocfs2_group_desc, bg_bitmap); | 1346 | offsetof(struct ocfs2_group_desc, bg_bitmap); |
1293 | 1347 | ||
1348 | /* | ||
1349 | * The cluster allocator uses the entire block. Suballocators have | ||
1350 | * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older | ||
1351 | * code expects bg_size set to the maximum. Thus we must keep | ||
1352 | * bg_size as-is unless discontig_bg is enabled. | ||
1353 | */ | ||
1354 | if (suballocator && | ||
1355 | (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG)) | ||
1356 | size = OCFS2_MAX_BG_BITMAP_SIZE; | ||
1357 | |||
1294 | return size; | 1358 | return size; |
1295 | } | 1359 | } |
1296 | 1360 | ||
@@ -1402,23 +1466,43 @@ static inline int ocfs2_extent_recs_per_eb(int blocksize) | |||
1402 | return size / sizeof(struct ocfs2_extent_rec); | 1466 | return size / sizeof(struct ocfs2_extent_rec); |
1403 | } | 1467 | } |
1404 | 1468 | ||
1405 | static inline int ocfs2_local_alloc_size(int blocksize) | 1469 | static inline int ocfs2_extent_recs_per_gd(int blocksize) |
1406 | { | 1470 | { |
1407 | int size; | 1471 | int size; |
1408 | 1472 | ||
1409 | size = blocksize - | 1473 | size = blocksize - |
1410 | offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); | 1474 | offsetof(struct ocfs2_group_desc, bg_list.l_recs); |
1411 | 1475 | ||
1412 | return size; | 1476 | return size / sizeof(struct ocfs2_extent_rec); |
1413 | } | 1477 | } |
1414 | 1478 | ||
1415 | static inline int ocfs2_group_bitmap_size(int blocksize) | 1479 | static inline int ocfs2_local_alloc_size(int blocksize) |
1416 | { | 1480 | { |
1417 | int size; | 1481 | int size; |
1418 | 1482 | ||
1419 | size = blocksize - | 1483 | size = blocksize - |
1484 | offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); | ||
1485 | |||
1486 | return size; | ||
1487 | } | ||
1488 | |||
1489 | static inline int ocfs2_group_bitmap_size(int blocksize, | ||
1490 | int suballocator, | ||
1491 | uint32_t feature_incompat) | ||
1492 | { | ||
1493 | int size = sb->s_blocksize - | ||
1420 | offsetof(struct ocfs2_group_desc, bg_bitmap); | 1494 | offsetof(struct ocfs2_group_desc, bg_bitmap); |
1421 | 1495 | ||
1496 | /* | ||
1497 | * The cluster allocator uses the entire block. Suballocators have | ||
1498 | * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older | ||
1499 | * code expects bg_size set to the maximum. Thus we must keep | ||
1500 | * bg_size as-is unless discontig_bg is enabled. | ||
1501 | */ | ||
1502 | if (suballocator && | ||
1503 | (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG)) | ||
1504 | size = OCFS2_MAX_BG_BITMAP_SIZE; | ||
1505 | |||
1422 | return size; | 1506 | return size; |
1423 | } | 1507 | } |
1424 | 1508 | ||
@@ -1491,5 +1575,19 @@ static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de, | |||
1491 | de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; | 1575 | de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT]; |
1492 | } | 1576 | } |
1493 | 1577 | ||
1578 | static inline int ocfs2_gd_is_discontig(struct ocfs2_group_desc *gd) | ||
1579 | { | ||
1580 | if ((offsetof(struct ocfs2_group_desc, bg_bitmap) + | ||
1581 | le16_to_cpu(gd->bg_size)) != | ||
1582 | offsetof(struct ocfs2_group_desc, bg_list)) | ||
1583 | return 0; | ||
1584 | /* | ||
1585 | * Only valid to check l_next_free_rec if | ||
1586 | * bg_bitmap + bg_size == bg_list. | ||
1587 | */ | ||
1588 | if (!gd->bg_list.l_next_free_rec) | ||
1589 | return 0; | ||
1590 | return 1; | ||
1591 | } | ||
1494 | #endif /* _OCFS2_FS_H */ | 1592 | #endif /* _OCFS2_FS_H */ |
1495 | 1593 | ||