aboutsummaryrefslogtreecommitdiff
path: root/fs/udf/inode.c
diff options
context:
space:
mode:
authorGravatar Jan Kara <jack@suse.cz> 2022-12-21 12:18:23 +0100
committerGravatar Jan Kara <jack@suse.cz> 2023-01-09 10:39:53 +0100
commite57191a8d40086537d505241a8ee49d8b62ce1d6 (patch)
treefbef25e7c56b0706111fec1ec56b7532abc6a984 /fs/udf/inode.c
parentudf: Allocate name buffer in directory iterator on heap (diff)
downloadlinux-e57191a8d40086537d505241a8ee49d8b62ce1d6.tar.gz
linux-e57191a8d40086537d505241a8ee49d8b62ce1d6.tar.bz2
linux-e57191a8d40086537d505241a8ee49d8b62ce1d6.zip
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: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf/inode.c')
-rw-r--r--fs/udf/inode.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 6d99d1300289..000ce37e6e1e 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -419,6 +419,7 @@ static int udf_do_extend_file(struct inode *inode,
~(sb->s_blocksize - 1);
}
+ add = 0;
/* Can we merge with the previous extent? */
if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) ==
EXT_NOT_RECORDED_NOT_ALLOCATED) {
@@ -451,6 +452,7 @@ static int udf_do_extend_file(struct inode *inode,
if (new_block_bytes)
udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0);
}
+ iinfo->i_lenExtents += add;
/* Managed to do everything necessary? */
if (!new_block_bytes)
@@ -469,6 +471,7 @@ static int udf_do_extend_file(struct inode *inode,
last_ext->extLength, 1);
if (err)
goto out_err;
+ iinfo->i_lenExtents += add;
count++;
}
if (new_block_bytes) {
@@ -478,6 +481,7 @@ static int udf_do_extend_file(struct inode *inode,
last_ext->extLength, 1);
if (err)
goto out_err;
+ iinfo->i_lenExtents += new_block_bytes;
count++;
}
@@ -585,7 +589,6 @@ static int udf_extend_file(struct inode *inode, loff_t newsize)
if (err < 0)
goto out;
err = 0;
- iinfo->i_lenExtents = newsize;
out:
brelse(epos.bh);
return err;