]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: core: save/restore command resid for error handling
authorDamien Le Moal <damien.lemoal@wdc.com>
Tue, 1 Oct 2019 07:48:39 +0000 (16:48 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 4 Oct 2019 01:43:04 +0000 (21:43 -0400)
commitfc70e814f4c9607acb8ca288e3f855afcb6e1288
treeaf87e52b880a31b3cce215eb4aba8888cd369cbe
parenta657408f46733c37a1dd7551667926f5bcbcd6a0
scsi: core: save/restore command resid for error handling

When a non-passthrough command is terminated with CHECK CONDITION, request
sense is executed by hijacking the command descriptor. Since
scsi_eh_prep_cmnd() and scsi_eh_restore_cmnd() do not save/restore the
original command resid, the value returned on failure of the original
command is lost and replaced with the value set by the execution of the
request sense command. This value may in many instances be unaligned to the
device sector size, causing sd_done() to print a warning message about the
incorrect unaligned resid before the command is retried.

Fix this problem by saving the original command residual in struct
scsi_eh_save using scsi_eh_prep_cmnd() and restoring it in
scsi_eh_restore_cmnd(). In addition, to make sure that the request sense
command is executed with a correctly initialized command structure, also
reset the residual to 0 in scsi_eh_prep_cmnd() after saving the original
command value in struct scsi_eh_save.

Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20191001074839.1994-1-damien.lemoal@wdc.com
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_error.c
include/scsi/scsi_eh.h