[GFS2] Speed up gfs2_write_alloc_required, deprecate gfs2_extent_map

This patch removes the call to gfs2_extent_map from gfs2_write_alloc_required,
instead we call gfs2_block_map directly. This results in fewer overall calls
to gfs2_block_map in the multi-block case.

Also, gfs2_extent_map is marked as deprecated so that people know that its
going away as soon as all the callers have been converted.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
This commit is contained in:
Steven Whitehouse 2008-01-28 08:47:38 +00:00
parent a9edadbf79
commit 941e6d7d09

View File

@ -548,6 +548,9 @@ out_fail:
return error; return error;
} }
/*
* Deprecated: do not use in new code
*/
int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen)
{ {
struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 }; struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 };
@ -1197,10 +1200,9 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
unsigned int len, int *alloc_required) unsigned int len, int *alloc_required)
{ {
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
u64 lblock, lblock_stop, dblock; struct buffer_head bh;
u32 extlen; unsigned int shift;
int new = 0; u64 lblock, lblock_stop, size;
int error = 0;
*alloc_required = 0; *alloc_required = 0;
@ -1214,6 +1216,8 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
return 0; return 0;
} }
*alloc_required = 1;
shift = sdp->sd_sb.sb_bsize_shift;
if (gfs2_is_dir(ip)) { if (gfs2_is_dir(ip)) {
unsigned int bsize = sdp->sd_jbsize; unsigned int bsize = sdp->sd_jbsize;
lblock = offset; lblock = offset;
@ -1221,27 +1225,25 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
lblock_stop = offset + len + bsize - 1; lblock_stop = offset + len + bsize - 1;
do_div(lblock_stop, bsize); do_div(lblock_stop, bsize);
} else { } else {
unsigned int shift = sdp->sd_sb.sb_bsize_shift;
u64 end_of_file = (ip->i_di.di_size + sdp->sd_sb.sb_bsize - 1) >> shift; u64 end_of_file = (ip->i_di.di_size + sdp->sd_sb.sb_bsize - 1) >> shift;
lblock = offset >> shift; lblock = offset >> shift;
lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift; lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift;
if (lblock_stop > end_of_file) { if (lblock_stop > end_of_file)
*alloc_required = 1;
return 0; return 0;
}
} }
for (; lblock < lblock_stop; lblock += extlen) { size = (lblock_stop - lblock) << shift;
error = gfs2_extent_map(&ip->i_inode, lblock, &new, &dblock, &extlen); do {
if (error) bh.b_state = 0;
return error; bh.b_size = size;
gfs2_block_map(&ip->i_inode, lblock, &bh, 0);
if (!dblock) { if (!buffer_mapped(&bh))
*alloc_required = 1;
return 0; return 0;
} size -= bh.b_size;
} lblock += (bh.b_size >> ip->i_inode.i_blkbits);
} while(size > 0);
*alloc_required = 0;
return 0; return 0;
} }