aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/resize.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/resize.c')
-rw-r--r--fs/ocfs2/resize.c40
1 files changed, 8 insertions, 32 deletions
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index 739d452f6174..a2de32a317ad 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -396,41 +396,16 @@ static int ocfs2_check_new_group(struct inode *inode,
396 struct buffer_head *group_bh) 396 struct buffer_head *group_bh)
397{ 397{
398 int ret; 398 int ret;
399 struct ocfs2_group_desc *gd; 399 struct ocfs2_group_desc *gd =
400 (struct ocfs2_group_desc *)group_bh->b_data;
400 u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc); 401 u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc);
401 unsigned int max_bits = le16_to_cpu(di->id2.i_chain.cl_cpg) *
402 le16_to_cpu(di->id2.i_chain.cl_bpc);
403 402
403 ret = ocfs2_validate_group_descriptor(inode->i_sb, di, gd, 1);
404 if (ret)
405 goto out;
404 406
405 gd = (struct ocfs2_group_desc *)group_bh->b_data; 407 ret = -EINVAL;
406 408 if (le16_to_cpu(gd->bg_chain) != input->chain)
407 ret = -EIO;
408 if (!OCFS2_IS_VALID_GROUP_DESC(gd))
409 mlog(ML_ERROR, "Group descriptor # %llu isn't valid.\n",
410 (unsigned long long)le64_to_cpu(gd->bg_blkno));
411 else if (di->i_blkno != gd->bg_parent_dinode)
412 mlog(ML_ERROR, "Group descriptor # %llu has bad parent "
413 "pointer (%llu, expected %llu)\n",
414 (unsigned long long)le64_to_cpu(gd->bg_blkno),
415 (unsigned long long)le64_to_cpu(gd->bg_parent_dinode),
416 (unsigned long long)le64_to_cpu(di->i_blkno));
417 else if (le16_to_cpu(gd->bg_bits) > max_bits)
418 mlog(ML_ERROR, "Group descriptor # %llu has bit count of %u\n",
419 (unsigned long long)le64_to_cpu(gd->bg_blkno),
420 le16_to_cpu(gd->bg_bits));
421 else if (le16_to_cpu(gd->bg_free_bits_count) > le16_to_cpu(gd->bg_bits))
422 mlog(ML_ERROR, "Group descriptor # %llu has bit count %u but "
423 "claims that %u are free\n",
424 (unsigned long long)le64_to_cpu(gd->bg_blkno),
425 le16_to_cpu(gd->bg_bits),
426 le16_to_cpu(gd->bg_free_bits_count));
427 else if (le16_to_cpu(gd->bg_bits) > (8 * le16_to_cpu(gd->bg_size)))
428 mlog(ML_ERROR, "Group descriptor # %llu has bit count %u but "
429 "max bitmap bits of %u\n",
430 (unsigned long long)le64_to_cpu(gd->bg_blkno),
431 le16_to_cpu(gd->bg_bits),
432 8 * le16_to_cpu(gd->bg_size));
433 else if (le16_to_cpu(gd->bg_chain) != input->chain)
434 mlog(ML_ERROR, "Group descriptor # %llu has bad chain %u " 409 mlog(ML_ERROR, "Group descriptor # %llu has bad chain %u "
435 "while input has %u set.\n", 410 "while input has %u set.\n",
436 (unsigned long long)le64_to_cpu(gd->bg_blkno), 411 (unsigned long long)le64_to_cpu(gd->bg_blkno),
@@ -449,6 +424,7 @@ static int ocfs2_check_new_group(struct inode *inode,
449 else 424 else
450 ret = 0; 425 ret = 0;
451 426
427out:
452 return ret; 428 return ret;
453} 429}
454 430