]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ata: libata-scsi: Return residual for emulated SCSI commands
authorDamien Le Moal <dlemoal@kernel.org>
Tue, 22 Oct 2024 02:45:37 +0000 (11:45 +0900)
committerNiklas Cassel <cassel@kernel.org>
Fri, 25 Oct 2024 08:09:49 +0000 (10:09 +0200)
commit5251ae224d8d3caa21b28d12408062b6e75cffad
tree3927ad3c19173889f51e86b491a27b2c3a93a298
parent2365278e03916b6b9a65df91e9f7c7afe5a6cf2e
ata: libata-scsi: Return residual for emulated SCSI commands

The function ata_scsi_rbuf_fill() used to fill the reply buffer of
emulated SCSI commands always copies the ATA reply buffer
(ata_scsi_rbuf) up to the size of the SCSI command buffer (the transfer
length for the command), even if the reply is shorter than the SCSI
command buffer. This leads to issuers of the SCSI command to always get
a result without any residual (resid is always 0) despite the
potentially shorter reply for the command.

Modify all fill actors used by ata_scsi_rbuf_fill() to return the number
of bytes filled for the reply and 0 in case of error. Using this value,
add a call to scsi_set_resid() in ata_scsi_rbuf_fill() to set the
correct residual for the SCSI command when the reply length is shorter
than the command buffer.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20241022024537.251905-7-dlemoal@kernel.org
Signed-off-by: Niklas Cassel <cassel@kernel.org>
drivers/ata/libata-scsi.c