From 01bdcc047d26d2334748a00d54c77be499f7b2a0 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Mon, 12 Oct 2026 14:04:42 +0300 Subject: [PATCH] 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: 63a6094cad78 ("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: f742ae018e81 ("scst_vdisk: Add zero-copy file I/O readsupport") Link: https://github.com/SCST-project/scst/issues/395 --- scst/src/dev_handlers/scst_vdisk_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/src/dev_handlers/scst_vdisk_main.c b/scst/src/dev_handlers/scst_vdisk_main.c index da454d624..cd5b09b86 100644 --- a/scst/src/dev_handlers/scst_vdisk_main.c +++ b/scst/src/dev_handlers/scst_vdisk_main.c @@ -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();