diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2009-04-23 03:59:41 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2009-04-23 05:07:37 -0400 |
commit | d9ba7615bfd8bb06f79c853f9dfff9e93a837941 (patch) | |
tree | 647f6078a7804a53b4902b90942864942e9d425b /fs | |
parent | d8bd504ab800c8e9aadb983914a33e7166320bec (diff) |
GFS2: Ensure that the inode goal block settings are updated
GFS2 has a goal block associated with each inode indicating the
search start position for future block allocations (in fact there
are two, but thats for backward compatibility with GFS1 as they
are set to identical locations in GFS2).
In some circumstances, depending on the ordering of updates to
the inode it was possible for the goal block settings to not
be updated on disk. This patch ensures that the goal block will
always get updated, thus reducing the potential for searching
the same (already allocated) blocks again when looking for free
space during block allocation.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/rgrp.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index c9786a46cdfc..565038243fa2 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -1444,10 +1444,12 @@ static struct gfs2_rgrpd *rgblk_free(struct gfs2_sbd *sdp, u64 bstart, | |||
1444 | u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n) | 1444 | u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n) |
1445 | { | 1445 | { |
1446 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1446 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
1447 | struct buffer_head *dibh; | ||
1447 | struct gfs2_alloc *al = ip->i_alloc; | 1448 | struct gfs2_alloc *al = ip->i_alloc; |
1448 | struct gfs2_rgrpd *rgd = al->al_rgd; | 1449 | struct gfs2_rgrpd *rgd = al->al_rgd; |
1449 | u32 goal, blk; | 1450 | u32 goal, blk; |
1450 | u64 block; | 1451 | u64 block; |
1452 | int error; | ||
1451 | 1453 | ||
1452 | if (rgrp_contains_block(rgd, ip->i_goal)) | 1454 | if (rgrp_contains_block(rgd, ip->i_goal)) |
1453 | goal = ip->i_goal - rgd->rd_data0; | 1455 | goal = ip->i_goal - rgd->rd_data0; |
@@ -1460,7 +1462,13 @@ u64 gfs2_alloc_block(struct gfs2_inode *ip, unsigned int *n) | |||
1460 | rgd->rd_last_alloc = blk; | 1462 | rgd->rd_last_alloc = blk; |
1461 | block = rgd->rd_data0 + blk; | 1463 | block = rgd->rd_data0 + blk; |
1462 | ip->i_goal = block; | 1464 | ip->i_goal = block; |
1463 | 1465 | error = gfs2_meta_inode_buffer(ip, &dibh); | |
1466 | if (error == 0) { | ||
1467 | struct gfs2_dinode *di = (struct gfs2_dinode *)dibh->b_data; | ||
1468 | gfs2_trans_add_bh(ip->i_gl, dibh, 1); | ||
1469 | di->di_goal_meta = di->di_goal_data = cpu_to_be64(ip->i_goal); | ||
1470 | brelse(dibh); | ||
1471 | } | ||
1464 | gfs2_assert_withdraw(sdp, rgd->rd_free >= *n); | 1472 | gfs2_assert_withdraw(sdp, rgd->rd_free >= *n); |
1465 | rgd->rd_free -= *n; | 1473 | rgd->rd_free -= *n; |
1466 | 1474 | ||