Commit e57191a8 authored by Jan Kara's avatar Jan Kara

udf: Move setting of i_lenExtents into udf_do_extend_file()

When expanding file for a write into a hole, we were not updating total
length of inode's extents properly. Move the update of i_lenExtents into
udf_do_extend_file() so that both expanding of file by truncate and
expanding of file by writing beyond EOF properly update the length of
extents. As a bonus, we also correctly update the length of extents when
only part of extents can be written.
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 0aba4860
...@@ -419,6 +419,7 @@ static int udf_do_extend_file(struct inode *inode, ...@@ -419,6 +419,7 @@ static int udf_do_extend_file(struct inode *inode,
~(sb->s_blocksize - 1); ~(sb->s_blocksize - 1);
} }
add = 0;
/* Can we merge with the previous extent? */ /* Can we merge with the previous extent? */
if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) ==
EXT_NOT_RECORDED_NOT_ALLOCATED) { EXT_NOT_RECORDED_NOT_ALLOCATED) {
...@@ -451,6 +452,7 @@ static int udf_do_extend_file(struct inode *inode, ...@@ -451,6 +452,7 @@ static int udf_do_extend_file(struct inode *inode,
if (new_block_bytes) if (new_block_bytes)
udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0); udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0);
} }
iinfo->i_lenExtents += add;
/* Managed to do everything necessary? */ /* Managed to do everything necessary? */
if (!new_block_bytes) if (!new_block_bytes)
...@@ -469,6 +471,7 @@ static int udf_do_extend_file(struct inode *inode, ...@@ -469,6 +471,7 @@ static int udf_do_extend_file(struct inode *inode,
last_ext->extLength, 1); last_ext->extLength, 1);
if (err) if (err)
goto out_err; goto out_err;
iinfo->i_lenExtents += add;
count++; count++;
} }
if (new_block_bytes) { if (new_block_bytes) {
...@@ -478,6 +481,7 @@ static int udf_do_extend_file(struct inode *inode, ...@@ -478,6 +481,7 @@ static int udf_do_extend_file(struct inode *inode,
last_ext->extLength, 1); last_ext->extLength, 1);
if (err) if (err)
goto out_err; goto out_err;
iinfo->i_lenExtents += new_block_bytes;
count++; count++;
} }
...@@ -585,7 +589,6 @@ static int udf_extend_file(struct inode *inode, loff_t newsize) ...@@ -585,7 +589,6 @@ static int udf_extend_file(struct inode *inode, loff_t newsize)
if (err < 0) if (err < 0)
goto out; goto out;
err = 0; err = 0;
iinfo->i_lenExtents = newsize;
out: out:
brelse(epos.bh); brelse(epos.bh);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment