aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2008-02-01 09:52:30 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2008-03-31 05:40:45 -0400
commit1639431a3f57b43da1e15e9268a1d691ac01ba26 (patch)
tree0e8147c9009c917566cf03c7e23f6ea4ffda8d72
parent5731be53e3d82aedd06e02574f833a57b07a08d2 (diff)
[GFS2] Merge gfs2_alloc_meta and gfs2_alloc_data
Thanks to the preceeding patches, the only difference between these two functions is their name. We can thus merge them and call the new function gfs2_alloc_block to reflect the fact that it can allocate either kind of block. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/gfs2/bmap.c13
-rw-r--r--fs/gfs2/dir.c2
-rw-r--r--fs/gfs2/eattr.c6
-rw-r--r--fs/gfs2/rgrp.c51
-rw-r--r--fs/gfs2/rgrp.h3
5 files changed, 13 insertions, 62 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 651e5320bb4f..e3a75a27cee7 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -137,7 +137,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
137 and write it out to disk */ 137 and write it out to disk */
138 138
139 if (isdir) { 139 if (isdir) {
140 block = gfs2_alloc_meta(ip); 140 block = gfs2_alloc_block(ip);
141 gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), block, 1); 141 gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), block, 1);
142 error = gfs2_dir_get_new_buffer(ip, block, &bh); 142 error = gfs2_dir_get_new_buffer(ip, block, &bh);
143 if (error) 143 if (error)
@@ -146,7 +146,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
146 dibh, sizeof(struct gfs2_dinode)); 146 dibh, sizeof(struct gfs2_dinode));
147 brelse(bh); 147 brelse(bh);
148 } else { 148 } else {
149 block = gfs2_alloc_data(ip); 149 block = gfs2_alloc_block(ip);
150 150
151 error = gfs2_unstuffer_page(ip, dibh, block, page); 151 error = gfs2_unstuffer_page(ip, dibh, block, page);
152 if (error) 152 if (error)
@@ -205,7 +205,7 @@ static int build_height(struct inode *inode, struct metapath *mp, unsigned heigh
205 return error; 205 return error;
206 206
207 for(n = 0; n < new_height; n++) { 207 for(n = 0; n < new_height; n++) {
208 bn = gfs2_alloc_meta(ip); 208 bn = gfs2_alloc_block(ip);
209 gfs2_trans_add_unrevoke(GFS2_SB(inode), bn, 1); 209 gfs2_trans_add_unrevoke(GFS2_SB(inode), bn, 1);
210 mp->mp_bh[n] = gfs2_meta_new(ip->i_gl, bn); 210 mp->mp_bh[n] = gfs2_meta_new(ip->i_gl, bn);
211 gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[n], 1); 211 gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[n], 1);
@@ -369,12 +369,9 @@ static int lookup_block(struct gfs2_inode *ip, unsigned int height,
369 if (!create) 369 if (!create)
370 return 0; 370 return 0;
371 371
372 if (height == ip->i_height - 1 && !gfs2_is_dir(ip)) 372 *block = gfs2_alloc_block(ip);
373 *block = gfs2_alloc_data(ip); 373 if (height != ip->i_height - 1 || gfs2_is_dir(ip))
374 else {
375 *block = gfs2_alloc_meta(ip);
376 gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), *block, 1); 374 gfs2_trans_add_unrevoke(GFS2_SB(&ip->i_inode), *block, 1);
377 }
378 375
379 gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[height], 1); 376 gfs2_trans_add_bh(ip->i_gl, mp->mp_bh[height], 1);
380 377
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 55514ee06dd8..fbdf31957cb5 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -803,7 +803,7 @@ got_dent:
803static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh, u16 depth) 803static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh, u16 depth)
804{ 804{
805 struct gfs2_inode *ip = GFS2_I(inode); 805 struct gfs2_inode *ip = GFS2_I(inode);
806 u64 bn = gfs2_alloc_meta(ip); 806 u64 bn = gfs2_alloc_block(ip);
807 struct buffer_head *bh = gfs2_meta_new(ip->i_gl, bn); 807 struct buffer_head *bh = gfs2_meta_new(ip->i_gl, bn);
808 struct gfs2_leaf *leaf; 808 struct gfs2_leaf *leaf;
809 struct gfs2_dirent *dent; 809 struct gfs2_dirent *dent;
diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c
index c7fa0a8b1648..f9f63bc21cd2 100644
--- a/fs/gfs2/eattr.c
+++ b/fs/gfs2/eattr.c
@@ -584,7 +584,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
584 struct gfs2_ea_header *ea; 584 struct gfs2_ea_header *ea;
585 u64 block; 585 u64 block;
586 586
587 block = gfs2_alloc_meta(ip); 587 block = gfs2_alloc_block(ip);
588 gfs2_trans_add_unrevoke(sdp, block, 1); 588 gfs2_trans_add_unrevoke(sdp, block, 1);
589 *bhp = gfs2_meta_new(ip->i_gl, block); 589 *bhp = gfs2_meta_new(ip->i_gl, block);
590 gfs2_trans_add_bh(ip->i_gl, *bhp, 1); 590 gfs2_trans_add_bh(ip->i_gl, *bhp, 1);
@@ -643,7 +643,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
643 u64 block; 643 u64 block;
644 int mh_size = sizeof(struct gfs2_meta_header); 644 int mh_size = sizeof(struct gfs2_meta_header);
645 645
646 block = gfs2_alloc_meta(ip); 646 block = gfs2_alloc_block(ip);
647 gfs2_trans_add_unrevoke(sdp, block, 1); 647 gfs2_trans_add_unrevoke(sdp, block, 1);
648 bh = gfs2_meta_new(ip->i_gl, block); 648 bh = gfs2_meta_new(ip->i_gl, block);
649 gfs2_trans_add_bh(ip->i_gl, bh, 1); 649 gfs2_trans_add_bh(ip->i_gl, bh, 1);
@@ -967,7 +967,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
967 } else { 967 } else {
968 u64 blk; 968 u64 blk;
969 969
970 blk = gfs2_alloc_meta(ip); 970 blk = gfs2_alloc_block(ip);
971 gfs2_trans_add_unrevoke(sdp, blk, 1); 971 gfs2_trans_add_unrevoke(sdp, blk, 1);
972 indbh = gfs2_meta_new(ip->i_gl, blk); 972 indbh = gfs2_meta_new(ip->i_gl, blk);
973 gfs2_trans_add_bh(ip->i_gl, indbh, 1); 973 gfs2_trans_add_bh(ip->i_gl, indbh, 1);
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 9f28463e62e5..274a2df13f02 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -1405,58 +1405,13 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart,
1405} 1405}
1406 1406
1407/** 1407/**
1408 * gfs2_alloc_data - Allocate a data block 1408 * gfs2_alloc_block - Allocate a block
1409 * @ip: the inode to allocate the data block for 1409 * @ip: the inode to allocate the block for
1410 * 1410 *
1411 * Returns: the allocated block 1411 * Returns: the allocated block
1412 */ 1412 */
1413 1413
1414u64 gfs2_alloc_data(struct gfs2_inode *ip) 1414u64 gfs2_alloc_block(struct gfs2_inode *ip)
1415{
1416 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1417 struct gfs2_alloc *al = ip->i_alloc;
1418 struct gfs2_rgrpd *rgd = al->al_rgd;
1419 u32 goal, blk;
1420 u64 block;
1421
1422 if (rgrp_contains_block(rgd, ip->i_goal))
1423 goal = ip->i_goal - rgd->rd_data0;
1424 else
1425 goal = rgd->rd_last_alloc;
1426
1427 blk = rgblk_search(rgd, goal, GFS2_BLKST_FREE, GFS2_BLKST_USED);
1428 BUG_ON(blk == BFITNOENT);
1429 rgd->rd_last_alloc = blk;
1430
1431 block = rgd->rd_data0 + blk;
1432 ip->i_goal = block;
1433
1434 gfs2_assert_withdraw(sdp, rgd->rd_rg.rg_free);
1435 rgd->rd_rg.rg_free--;
1436
1437 gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1);
1438 gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data);
1439
1440 al->al_alloced++;
1441
1442 gfs2_statfs_change(sdp, 0, -1, 0);
1443 gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
1444
1445 spin_lock(&sdp->sd_rindex_spin);
1446 rgd->rd_free_clone--;
1447 spin_unlock(&sdp->sd_rindex_spin);
1448
1449 return block;
1450}
1451
1452/**
1453 * gfs2_alloc_meta - Allocate a metadata block
1454 * @ip: the inode to allocate the metadata block for
1455 *
1456 * Returns: the allocated block
1457 */
1458
1459u64 gfs2_alloc_meta(struct gfs2_inode *ip)
1460{ 1415{
1461 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1416 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1462 struct gfs2_alloc *al = ip->i_alloc; 1417 struct gfs2_alloc *al = ip->i_alloc;
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
index 5683605695fd..5e66613b33db 100644
--- a/fs/gfs2/rgrp.h
+++ b/fs/gfs2/rgrp.h
@@ -46,8 +46,7 @@ void gfs2_inplace_release(struct gfs2_inode *ip);
46 46
47unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block); 47unsigned char gfs2_get_block_type(struct gfs2_rgrpd *rgd, u64 block);
48 48
49u64 gfs2_alloc_data(struct gfs2_inode *ip); 49u64 gfs2_alloc_block(struct gfs2_inode *ip);
50u64 gfs2_alloc_meta(struct gfs2_inode *ip);
51u64 gfs2_alloc_di(struct gfs2_inode *ip, u64 *generation); 50u64 gfs2_alloc_di(struct gfs2_inode *ip, u64 *generation);
52 51
53void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen); 52void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen);