diff options
author | Tao Ma <tao.ma@oracle.com> | 2010-04-13 02:38:06 -0400 |
---|---|---|
committer | Tao Ma <tao.ma@oracle.com> | 2010-04-13 02:38:06 -0400 |
commit | 8571882c21e5073b2f96147ec4ff9b7042339e1b (patch) | |
tree | 1f7925e293e656e5c1c6cd2c2876ea977a7277e5 /fs/ocfs2 | |
parent | 4711954eaa8d30f653fda238cecf919f1ae40d6f (diff) |
ocfs2: ocfs2_group_bitmap_size has to handle old volume.
ocfs2_group_bitmap_size has to handle the case when the
volume don't have discontiguous block group support. So
pass the feature_incompat in and check it.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/localalloc.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/ocfs2_fs.h | 37 | ||||
-rw-r--r-- | fs/ocfs2/resize.c | 6 | ||||
-rw-r--r-- | fs/ocfs2/suballoc.c | 3 | ||||
-rw-r--r-- | fs/ocfs2/super.c | 3 |
5 files changed, 34 insertions, 17 deletions
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index aab1b634cc8e..3d7419682dc0 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -122,7 +122,7 @@ unsigned int ocfs2_la_default_mb(struct ocfs2_super *osb) | |||
122 | struct super_block *sb = osb->sb; | 122 | struct super_block *sb = osb->sb; |
123 | 123 | ||
124 | gd_mb = ocfs2_clusters_to_megabytes(osb->sb, | 124 | gd_mb = ocfs2_clusters_to_megabytes(osb->sb, |
125 | 8 * ocfs2_group_bitmap_size(sb, 0)); | 125 | 8 * ocfs2_group_bitmap_size(sb, 0, osb->s_feature_incompat)); |
126 | 126 | ||
127 | /* | 127 | /* |
128 | * This takes care of files systems with very small group | 128 | * This takes care of files systems with very small group |
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index a17bce591ee3..67bb8a77e868 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h | |||
@@ -1338,15 +1338,21 @@ static inline u16 ocfs2_local_alloc_size(struct super_block *sb) | |||
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | static inline int ocfs2_group_bitmap_size(struct super_block *sb, | 1340 | static inline int ocfs2_group_bitmap_size(struct super_block *sb, |
1341 | int suballocator) | 1341 | int suballocator, |
1342 | u32 feature_incompat) | ||
1342 | { | 1343 | { |
1343 | int size; | 1344 | int size = sb->s_blocksize - |
1345 | offsetof(struct ocfs2_group_desc, bg_bitmap); | ||
1344 | 1346 | ||
1345 | if (suballocator) | 1347 | /* |
1348 | * The cluster allocator uses the entire block. Suballocators have | ||
1349 | * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older | ||
1350 | * code expects bg_size set to the maximum. Thus we must keep | ||
1351 | * bg_size as-is unless discontig_bg is enabled. | ||
1352 | */ | ||
1353 | if (suballocator && | ||
1354 | (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG)) | ||
1346 | size = OCFS2_MAX_BG_BITMAP_SIZE; | 1355 | size = OCFS2_MAX_BG_BITMAP_SIZE; |
1347 | else | ||
1348 | size = sb->s_blocksize - | ||
1349 | offsetof(struct ocfs2_group_desc, bg_bitmap); | ||
1350 | 1356 | ||
1351 | return size; | 1357 | return size; |
1352 | } | 1358 | } |
@@ -1479,15 +1485,22 @@ static inline int ocfs2_local_alloc_size(int blocksize) | |||
1479 | return size; | 1485 | return size; |
1480 | } | 1486 | } |
1481 | 1487 | ||
1482 | static inline int ocfs2_group_bitmap_size(int blocksize, int suballocator) | 1488 | static inline int ocfs2_group_bitmap_size(int blocksize, |
1489 | int suballocator, | ||
1490 | uint32_t feature_incompat) | ||
1483 | { | 1491 | { |
1484 | int size; | 1492 | int size = sb->s_blocksize - |
1493 | offsetof(struct ocfs2_group_desc, bg_bitmap); | ||
1485 | 1494 | ||
1486 | if (suballocator) | 1495 | /* |
1496 | * The cluster allocator uses the entire block. Suballocators have | ||
1497 | * never used more than OCFS2_MAX_BG_BITMAP_SIZE. Unfortunately, older | ||
1498 | * code expects bg_size set to the maximum. Thus we must keep | ||
1499 | * bg_size as-is unless discontig_bg is enabled. | ||
1500 | */ | ||
1501 | if (suballocator && | ||
1502 | (feature_incompat & OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG)) | ||
1487 | size = OCFS2_MAX_BG_BITMAP_SIZE; | 1503 | size = OCFS2_MAX_BG_BITMAP_SIZE; |
1488 | else | ||
1489 | size = blocksize - | ||
1490 | offsetof(struct ocfs2_group_desc, bg_bitmap); | ||
1491 | 1504 | ||
1492 | return size; | 1505 | return size; |
1493 | } | 1506 | } |
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c index 5bbfc123781f..dacd553d8617 100644 --- a/fs/ocfs2/resize.c +++ b/fs/ocfs2/resize.c | |||
@@ -315,7 +315,8 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters) | |||
315 | BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); | 315 | BUG_ON(!OCFS2_IS_VALID_DINODE(fe)); |
316 | 316 | ||
317 | if (le16_to_cpu(fe->id2.i_chain.cl_cpg) != | 317 | if (le16_to_cpu(fe->id2.i_chain.cl_cpg) != |
318 | ocfs2_group_bitmap_size(osb->sb, 0) * 8) { | 318 | ocfs2_group_bitmap_size(osb->sb, 0, |
319 | osb->s_feature_incompat) * 8) { | ||
319 | mlog(ML_ERROR, "The disk is too old and small. " | 320 | mlog(ML_ERROR, "The disk is too old and small. " |
320 | "Force to do offline resize."); | 321 | "Force to do offline resize."); |
321 | ret = -EINVAL; | 322 | ret = -EINVAL; |
@@ -496,7 +497,8 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) | |||
496 | fe = (struct ocfs2_dinode *)main_bm_bh->b_data; | 497 | fe = (struct ocfs2_dinode *)main_bm_bh->b_data; |
497 | 498 | ||
498 | if (le16_to_cpu(fe->id2.i_chain.cl_cpg) != | 499 | if (le16_to_cpu(fe->id2.i_chain.cl_cpg) != |
499 | ocfs2_group_bitmap_size(osb->sb, 0) * 8) { | 500 | ocfs2_group_bitmap_size(osb->sb, 0, |
501 | osb->s_feature_incompat) * 8) { | ||
500 | mlog(ML_ERROR, "The disk is too old and small." | 502 | mlog(ML_ERROR, "The disk is too old and small." |
501 | " Force to do offline resize."); | 503 | " Force to do offline resize."); |
502 | ret = -EINVAL; | 504 | ret = -EINVAL; |
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index b7491e2481ca..6f39da4a9a10 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c | |||
@@ -391,7 +391,8 @@ static int ocfs2_block_group_fill(handle_t *handle, | |||
391 | memset(bg, 0, sb->s_blocksize); | 391 | memset(bg, 0, sb->s_blocksize); |
392 | strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); | 392 | strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); |
393 | bg->bg_generation = cpu_to_le32(OCFS2_SB(sb)->fs_generation); | 393 | bg->bg_generation = cpu_to_le32(OCFS2_SB(sb)->fs_generation); |
394 | bg->bg_size = cpu_to_le16(ocfs2_group_bitmap_size(sb, 1)); | 394 | bg->bg_size = cpu_to_le16(ocfs2_group_bitmap_size(sb, 1, |
395 | osb->s_feature_incompat)); | ||
395 | bg->bg_chain = cpu_to_le16(my_chain); | 396 | bg->bg_chain = cpu_to_le16(my_chain); |
396 | bg->bg_next_group = cl->cl_recs[my_chain].c_blkno; | 397 | bg->bg_next_group = cl->cl_recs[my_chain].c_blkno; |
397 | bg->bg_parent_dinode = cpu_to_le64(OCFS2_I(alloc_inode)->ip_blkno); | 398 | bg->bg_parent_dinode = cpu_to_le64(OCFS2_I(alloc_inode)->ip_blkno); |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 59930ee4fe2e..106becf5d00f 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -2277,7 +2277,8 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
2277 | osb->osb_clusters_at_boot = OCFS2_I(inode)->ip_clusters; | 2277 | osb->osb_clusters_at_boot = OCFS2_I(inode)->ip_clusters; |
2278 | iput(inode); | 2278 | iput(inode); |
2279 | 2279 | ||
2280 | osb->bitmap_cpg = ocfs2_group_bitmap_size(sb, 0) * 8; | 2280 | osb->bitmap_cpg = ocfs2_group_bitmap_size(sb, 0, |
2281 | osb->s_feature_incompat) * 8; | ||
2281 | 2282 | ||
2282 | status = ocfs2_init_slot_info(osb); | 2283 | status = ocfs2_init_slot_info(osb); |
2283 | if (status < 0) { | 2284 | if (status < 0) { |