aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/resize.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-11-13 17:49:14 -0500
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:36:53 -0500
commit68f64d471be38631d7196b938d9809802dd467fa (patch)
treeb94f14b3a8b093dc52f2b034e7666b14c536f0d6 /fs/ocfs2/resize.c
parent57e3e7971136003c96766346049aa73b82cab079 (diff)
ocfs2: Wrap group descriptor reads in a dedicated function.
We have a clean call for validating group descriptors, but every place that wants the always does a read_block()+validate() call pair. Create a toplevel ocfs2_read_group_descriptor() that does the right thing. This allows us to leverage the single call point later for fancier handling. We also add validation of gd->bg_generation against the superblock and gd->bg_blkno against the block we thought we read. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/resize.c')
-rw-r--r--fs/ocfs2/resize.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index a2de32a317ad..252baff5eb84 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -330,20 +330,14 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters)
330 lgd_blkno = ocfs2_which_cluster_group(main_bm_inode, 330 lgd_blkno = ocfs2_which_cluster_group(main_bm_inode,
331 first_new_cluster - 1); 331 first_new_cluster - 1);
332 332
333 ret = ocfs2_read_block(main_bm_inode, lgd_blkno, &group_bh); 333 ret = ocfs2_read_group_descriptor(main_bm_inode, fe, lgd_blkno,
334 &group_bh);
334 if (ret < 0) { 335 if (ret < 0) {
335 mlog_errno(ret); 336 mlog_errno(ret);
336 goto out_unlock; 337 goto out_unlock;
337 } 338 }
338
339 group = (struct ocfs2_group_desc *)group_bh->b_data; 339 group = (struct ocfs2_group_desc *)group_bh->b_data;
340 340
341 ret = ocfs2_check_group_descriptor(inode->i_sb, fe, group);
342 if (ret) {
343 mlog_errno(ret);
344 goto out_unlock;
345 }
346
347 cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc); 341 cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
348 if (le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters > 342 if (le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters >
349 le16_to_cpu(fe->id2.i_chain.cl_cpg)) { 343 le16_to_cpu(fe->id2.i_chain.cl_cpg)) {
@@ -400,7 +394,7 @@ static int ocfs2_check_new_group(struct inode *inode,
400 (struct ocfs2_group_desc *)group_bh->b_data; 394 (struct ocfs2_group_desc *)group_bh->b_data;
401 u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc); 395 u16 cl_bpc = le16_to_cpu(di->id2.i_chain.cl_bpc);
402 396
403 ret = ocfs2_validate_group_descriptor(inode->i_sb, di, gd, 1); 397 ret = ocfs2_validate_group_descriptor(inode->i_sb, di, group_bh, 1);
404 if (ret) 398 if (ret)
405 goto out; 399 goto out;
406 400