mirror of
https://github.com/torvalds/linux.git
synced 2024-11-02 10:11:36 +00:00
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>
This commit is contained in:
parent
0d0f660d88
commit
62d3ab49b8
@ -415,7 +415,7 @@ fd_execute_sync_cache(struct se_cmd *cmd)
|
|||||||
} else {
|
} else {
|
||||||
start = cmd->t_task_lba * dev->dev_attrib.block_size;
|
start = cmd->t_task_lba * dev->dev_attrib.block_size;
|
||||||
if (cmd->data_length)
|
if (cmd->data_length)
|
||||||
end = start + cmd->data_length;
|
end = start + cmd->data_length - 1;
|
||||||
else
|
else
|
||||||
end = LLONG_MAX;
|
end = LLONG_MAX;
|
||||||
}
|
}
|
||||||
@ -680,7 +680,12 @@ fd_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
|
|||||||
struct fd_dev *fd_dev = FD_DEV(dev);
|
struct fd_dev *fd_dev = FD_DEV(dev);
|
||||||
loff_t start = cmd->t_task_lba *
|
loff_t start = cmd->t_task_lba *
|
||||||
dev->dev_attrib.block_size;
|
dev->dev_attrib.block_size;
|
||||||
loff_t end = start + cmd->data_length;
|
loff_t end;
|
||||||
|
|
||||||
|
if (cmd->data_length)
|
||||||
|
end = start + cmd->data_length - 1;
|
||||||
|
else
|
||||||
|
end = LLONG_MAX;
|
||||||
|
|
||||||
vfs_fsync_range(fd_dev->fd_file, start, end, 1);
|
vfs_fsync_range(fd_dev->fd_file, start, end, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user