udf: don't increment lenExtents while writing to a hole
authorNamjae Jeon <namjae.jeon@samsung.com>
Tue, 9 Oct 2012 15:09:12 +0000 (00:09 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jan 2013 16:50:53 +0000 (08:50 -0800)
commit fb719c59bdb4fca86ee1fd1f42ab3735ca12b6b2 upstream.

Incrementing lenExtents even while writing to a hole is bad
for performance as calls to udf_discard_prealloc and
udf_truncate_tail_extent would not return from start if
isize != lenExtents

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Shuah Khan <shuah.khan@hp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/udf/inode.c

index ad68793..aa70035 100644 (file)
@@ -574,6 +574,7 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
        struct udf_inode_info *iinfo = UDF_I(inode);
        int goal = 0, pgoal = iinfo->i_location.logicalBlockNum;
        int lastblock = 0;
+       bool isBeyondEOF;
 
        *err = 0;
        *new = 0;
@@ -653,7 +654,7 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
        /* Are we beyond EOF? */
        if (etype == -1) {
                int ret;
-
+               isBeyondEOF = 1;
                if (count) {
                        if (c)
                                laarr[0] = laarr[1];
@@ -696,6 +697,7 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
                endnum = c + 1;
                lastblock = 1;
        } else {
+               isBeyondEOF = 0;
                endnum = startnum = ((count > 2) ? 2 : count);
 
                /* if the current extent is in position 0,
@@ -743,7 +745,8 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
                        *err = -ENOSPC;
                        return 0;
                }
-               iinfo->i_lenExtents += inode->i_sb->s_blocksize;
+               if (isBeyondEOF)
+                       iinfo->i_lenExtents += inode->i_sb->s_blocksize;
        }
 
        /* if the extent the requsted block is located in contains multiple