[GFS2] gfs2_alloc_required performance
authorBob Peterson <rpeterso@redhat.com>
Fri, 11 Jan 2008 19:44:50 +0000 (13:44 -0600)
committerSteven Whitehouse <swhiteho@redhat.com>
Fri, 25 Jan 2008 08:19:03 +0000 (08:19 +0000)
This is a small I/O performance enhancement to gfs2.  (Actually, it is a rework of
an earlier version I got wrong).  The idea here is to check if the write extends
past the last block in the file.  If so, the function can save itself a lot of
time and trouble because it knows an allocate will be required.  Benchmarks like
iozone should see better performance.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/bmap.c

index 73dfad70de66b53261a9472db2af6d65745f9335..4356cc2fb3f5cca827a4b290c1e6871e8fe44bbe 100644 (file)
@@ -1224,6 +1224,11 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
                unsigned int shift = sdp->sd_sb.sb_bsize_shift;
                lblock = offset >> shift;
                lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift;
+               if (lblock_stop > ip->i_di.di_blocks) { /* writing past the
+                                                          last block */
+                       *alloc_required = 1;
+                       return 0;
+               }
        }
 
        for (; lblock < lblock_stop; lblock += extlen) {