diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2008-01-28 03:47:38 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2008-03-31 05:39:44 -0400 |
commit | 941e6d7d09aaf455c0d7ad383f7f5ae67e4ccf16 (patch) | |
tree | b6d066178387b9222fa25dfd7ea3555cc8b91621 /fs/gfs2 | |
parent | a9edadbf790d72adf6ebed476cb5caf7743e7e4a (diff) |
[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>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/bmap.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index e9456ebd3bb..a25444ac648 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
@@ -548,6 +548,9 @@ out_fail: | |||
548 | return error; | 548 | return error; |
549 | } | 549 | } |
550 | 550 | ||
551 | /* | ||
552 | * Deprecated: do not use in new code | ||
553 | */ | ||
551 | int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) | 554 | int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) |
552 | { | 555 | { |
553 | struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 }; | 556 | 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, | |||
1197 | unsigned int len, int *alloc_required) | 1200 | unsigned int len, int *alloc_required) |
1198 | { | 1201 | { |
1199 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1202 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
1200 | u64 lblock, lblock_stop, dblock; | 1203 | struct buffer_head bh; |
1201 | u32 extlen; | 1204 | unsigned int shift; |
1202 | int new = 0; | 1205 | u64 lblock, lblock_stop, size; |
1203 | int error = 0; | ||
1204 | 1206 | ||
1205 | *alloc_required = 0; | 1207 | *alloc_required = 0; |
1206 | 1208 | ||
@@ -1214,6 +1216,8 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, | |||
1214 | return 0; | 1216 | return 0; |
1215 | } | 1217 | } |
1216 | 1218 | ||
1219 | *alloc_required = 1; | ||
1220 | shift = sdp->sd_sb.sb_bsize_shift; | ||
1217 | if (gfs2_is_dir(ip)) { | 1221 | if (gfs2_is_dir(ip)) { |
1218 | unsigned int bsize = sdp->sd_jbsize; | 1222 | unsigned int bsize = sdp->sd_jbsize; |
1219 | lblock = offset; | 1223 | lblock = offset; |
@@ -1221,27 +1225,25 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset, | |||
1221 | lblock_stop = offset + len + bsize - 1; | 1225 | lblock_stop = offset + len + bsize - 1; |
1222 | do_div(lblock_stop, bsize); | 1226 | do_div(lblock_stop, bsize); |
1223 | } else { | 1227 | } else { |
1224 | unsigned int shift = sdp->sd_sb.sb_bsize_shift; | ||
1225 | u64 end_of_file = (ip->i_di.di_size + sdp->sd_sb.sb_bsize - 1) >> shift; | 1228 | u64 end_of_file = (ip->i_di.di_size + sdp->sd_sb.sb_bsize - 1) >> shift; |
1226 | lblock = offset >> shift; | 1229 | lblock = offset >> shift; |
1227 | lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift; | 1230 | lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift; |
1228 | if (lblock_stop > end_of_file) { | 1231 | if (lblock_stop > end_of_file) |
1229 | *alloc_required = 1; | ||
1230 | return 0; | 1232 | return 0; |
1231 | } | ||
1232 | } | 1233 | } |
1233 | 1234 | ||
1234 | for (; lblock < lblock_stop; lblock += extlen) { | 1235 | size = (lblock_stop - lblock) << shift; |
1235 | error = gfs2_extent_map(&ip->i_inode, lblock, &new, &dblock, &extlen); | 1236 | do { |
1236 | if (error) | 1237 | bh.b_state = 0; |
1237 | return error; | 1238 | bh.b_size = size; |
1238 | 1239 | gfs2_block_map(&ip->i_inode, lblock, &bh, 0); | |
1239 | if (!dblock) { | 1240 | if (!buffer_mapped(&bh)) |
1240 | *alloc_required = 1; | ||
1241 | return 0; | 1241 | return 0; |
1242 | } | 1242 | size -= bh.b_size; |
1243 | } | 1243 | lblock += (bh.b_size >> ip->i_inode.i_blkbits); |
1244 | } while(size > 0); | ||
1244 | 1245 | ||
1246 | *alloc_required = 0; | ||
1245 | return 0; | 1247 | return 0; |
1246 | } | 1248 | } |
1247 | 1249 | ||