]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - fs/udf/inode.c
udf: don't increment lenExtents while writing to a hole
[karo-tx-linux.git] / fs / udf / inode.c
index df88b957ccf04f39751686d3ff85f8f69ed8cdd2..8266f2ed7fc4b0b8fa4f09858db25b73b2135218 100644 (file)
@@ -601,6 +601,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;
@@ -680,7 +681,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];
@@ -723,6 +724,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,
@@ -765,10 +767,13 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
                                goal, err);
                if (!newblocknum) {
                        brelse(prev_epos.bh);
+                       brelse(cur_epos.bh);
+                       brelse(next_epos.bh);
                        *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
@@ -795,6 +800,8 @@ static sector_t inode_getblk(struct inode *inode, sector_t block,
        udf_update_extents(inode, laarr, startnum, endnum, &prev_epos);
 
        brelse(prev_epos.bh);
+       brelse(cur_epos.bh);
+       brelse(next_epos.bh);
 
        newblock = udf_get_pblock(inode->i_sb, newblocknum,
                                iinfo->i_location.partitionReferenceNum, 0);