[Cluster-devel] [GFS2] [Patch 7/10] Only fetch the dinode once in block_map

Bob Peterson rpeterso at redhat.com
Wed Dec 12 01:16:09 UTC 2007


Hi,

Function gfs2_block_map was often looking up the disk inode twice.
This optimizes it so that only does it once.

Regards,

Bob Peterson
Red Hat GFS

Signed-off-by: Bob Peterson <rpeterso at redhat.com> 
--
 .../fs/gfs2/bmap.c                                 |   14 +++++++-------
  1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gfs2-2.6.git.patch6/fs/gfs2/bmap.c b/gfs2-2.6.git.patch7/fs/gfs2/bmap.c
index 4cdf4d4..0974912 100644
--- a/gfs2-2.6.git.patch6/fs/gfs2/bmap.c
+++ b/gfs2-2.6.git.patch7/fs/gfs2/bmap.c
@@ -469,6 +469,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 	unsigned int maxlen = bh_map->b_size >> inode->i_blkbits;
 	struct metapath mp;
 	u64 size;
+	struct buffer_head *dibh = NULL;
 
 	BUG_ON(maxlen == 0);
 
@@ -499,6 +500,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 	error = gfs2_meta_inode_buffer(ip, &bh);
 	if (error)
 		goto out_fail;
+	dibh = bh;
+	get_bh(dibh);
 
 	for (x = 0; x < end_of_metadata; x++) {
 		lookup_block(ip, bh, x, &mp, create, &new, &dblock);
@@ -517,13 +520,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 		if (boundary)
 			set_buffer_boundary(bh_map);
 		if (new) {
-			struct buffer_head *dibh;
-			error = gfs2_meta_inode_buffer(ip, &dibh);
-			if (!error) {
-				gfs2_trans_add_bh(ip->i_gl, dibh, 1);
-				gfs2_dinode_out(ip, dibh->b_data);
-				brelse(dibh);
-			}
+			gfs2_trans_add_bh(ip->i_gl, dibh, 1);
+			gfs2_dinode_out(ip, dibh->b_data);
 			set_buffer_new(bh_map);
 			goto out_brelse;
 		}
@@ -544,6 +542,8 @@ out_brelse:
 out_ok:
 	error = 0;
 out_fail:
+	if (dibh)
+		brelse(dibh);
 	bmap_unlock(inode, create);
 	return error;
 }





More information about the Cluster-devel mailing list