Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

target/file: fix inclusive vfs_fsync_range() end

Both of the file target's calls to vfs_fsync_range() got the end offset
off by one. The range is inclusive, not exclusive. It would sync a bit
more data than was required.

The sync path already tested the length of the range and fell back to
LLONG_MAX so I copied that pattern in the rw path.

This is untested. I found the errors by inspection while following other
code.

Signed-off-by: Zach Brown <zab@zabbo.net>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

authored by

Zach Brown and committed by
Nicholas Bellinger
62d3ab49 0d0f660d

+7 -2
+7 -2
drivers/target/target_core_file.c
··· 415 415 } else { 416 416 start = cmd->t_task_lba * dev->dev_attrib.block_size; 417 417 if (cmd->data_length) 418 - end = start + cmd->data_length; 418 + end = start + cmd->data_length - 1; 419 419 else 420 420 end = LLONG_MAX; 421 421 } ··· 680 680 struct fd_dev *fd_dev = FD_DEV(dev); 681 681 loff_t start = cmd->t_task_lba * 682 682 dev->dev_attrib.block_size; 683 - loff_t end = start + cmd->data_length; 683 + loff_t end; 684 + 685 + if (cmd->data_length) 686 + end = start + cmd->data_length - 1; 687 + else 688 + end = LLONG_MAX; 684 689 685 690 vfs_fsync_range(fd_dev->fd_file, start, end, 1); 686 691 }