scst_vdisk: Flush FUA writes from the original offset

fileio_exec_write() passes its local loff to scst_writev(), which advances
it by the number of bytes written. Using that offset for the subsequent
FUA flush starts the range after the data instead of at its beginning.
The command can therefore complete without synchronizing its writes.

The 2011 opcode dispatch refactoring moved the flush into the write
function, where loff was already advanced between I/O batches. The 2012
zero-copy change then passed &loff instead of &fd->f_pos to vfs_writev(),
making the offset wrong even for a write completed in one call.

Use the unchanged command offset for the flush, including after short
writes and errors. Keep the working offset for advancing through the I/O.

Fixes: 63a6094cad ("Eliminate the blockio / fileio / nullio if-statements in vdisk_do_job() and the READ/WRITE functions called from that function. Convert the opcode switch in vdisk_*do_job() to an array with function pointers.")
Fixes: f742ae018e ("scst_vdisk: Add zero-copy file I/O readsupport")
Link: https://github.com/SCST-project/scst/issues/395
This commit is contained in:
Gleb Chesnokov
2026-10-14 17:39:14 +03:00
parent 6a4f85e6eb
commit 01bdcc047d
+1 -1
View File
@@ -5475,7 +5475,7 @@ restart:
out_sync:
/* O_DSYNC flag is used for WT devices */
if (p->fua)
vdisk_fsync(loff, scst_cmd_get_data_len(cmd), cmd->dev,
vdisk_fsync(p->loff, scst_cmd_get_data_len(cmd), cmd->dev,
cmd->cmd_gfp_mask, cmd, false);
out:
TRACE_EXIT();