Commit b0d5fd30 authored by Bob Peterson's avatar Bob Peterson Committed by Steven Whitehouse

[GFS2] Only fetch the dinode once in block_map

Function gfs2_block_map was often looking up the disk inode twice.
This optimizes it so that only does it once.
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent 398bbe68
...@@ -469,6 +469,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock, ...@@ -469,6 +469,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
unsigned int maxlen = bh_map->b_size >> inode->i_blkbits; unsigned int maxlen = bh_map->b_size >> inode->i_blkbits;
struct metapath mp; struct metapath mp;
u64 size; u64 size;
struct buffer_head *dibh = NULL;
BUG_ON(maxlen == 0); BUG_ON(maxlen == 0);
...@@ -499,6 +500,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock, ...@@ -499,6 +500,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
error = gfs2_meta_inode_buffer(ip, &bh); error = gfs2_meta_inode_buffer(ip, &bh);
if (error) if (error)
goto out_fail; goto out_fail;
dibh = bh;
get_bh(dibh);
for (x = 0; x < end_of_metadata; x++) { for (x = 0; x < end_of_metadata; x++) {
lookup_block(ip, bh, x, &mp, create, &new, &dblock); lookup_block(ip, bh, x, &mp, create, &new, &dblock);
...@@ -517,13 +520,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock, ...@@ -517,13 +520,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
if (boundary) if (boundary)
set_buffer_boundary(bh_map); set_buffer_boundary(bh_map);
if (new) { if (new) {
struct buffer_head *dibh; gfs2_trans_add_bh(ip->i_gl, dibh, 1);
error = gfs2_meta_inode_buffer(ip, &dibh); gfs2_dinode_out(ip, dibh->b_data);
if (!error) {
gfs2_trans_add_bh(ip->i_gl, dibh, 1);
gfs2_dinode_out(ip, dibh->b_data);
brelse(dibh);
}
set_buffer_new(bh_map); set_buffer_new(bh_map);
goto out_brelse; goto out_brelse;
} }
...@@ -544,6 +542,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock, ...@@ -544,6 +542,8 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
out_ok: out_ok:
error = 0; error = 0;
out_fail: out_fail:
if (dibh)
brelse(dibh);
bmap_unlock(inode, create); bmap_unlock(inode, create);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment