Skip to content

Commit 9257336

Browse files
OjaswinMtytso
authored andcommitted
ext4: treat end of range as exclusive in ext4_zero_range()
The call to filemap_write_and_wait_range() assumes the range passed to be inclusive, so fix the call to make sure we follow that. Signed-off-by: Ojaswin Mujoo <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/e503107a7c73a2b68dec645c5ad798c437717c45.1698856309.git.ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o <[email protected]>
1 parent e89fdcc commit 9257336

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/ext4/extents.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4523,7 +4523,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
45234523
* Round up offset. This is not fallocate, we need to zero out
45244524
* blocks, so convert interior block aligned part of the range to
45254525
* unwritten and possibly manually zero out unaligned parts of the
4526-
* range.
4526+
* range. Here, start and partial_begin are inclusive, end and
4527+
* partial_end are exclusive.
45274528
*/
45284529
start = round_up(offset, 1 << blkbits);
45294530
end = round_down((offset + len), 1 << blkbits);
@@ -4609,7 +4610,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
46094610
* disk in case of crash before zeroing trans is committed.
46104611
*/
46114612
if (ext4_should_journal_data(inode)) {
4612-
ret = filemap_write_and_wait_range(mapping, start, end);
4613+
ret = filemap_write_and_wait_range(mapping, start,
4614+
end - 1);
46134615
if (ret) {
46144616
filemap_invalidate_unlock(mapping);
46154617
goto out_mutex;

0 commit comments

Comments
 (0)