diff mbox series

[v2,RESEND] scsi: code: always send batch on reset or error handling command

Message ID 20231215121008.2881653-1-alexander.atanasov@virtuozzo.com (mailing list archive)
State Accepted
Headers show
Series [v2,RESEND] scsi: code: always send batch on reset or error handling command | expand

Commit Message

Alexander Atanasov Dec. 15, 2023, 12:10 p.m. UTC
In commit 8930a6c20791 ("scsi: core: add support for request batching")
blk-mq last flags was mapped to SCMD_LAST and used as an indicator to
send the batch for the drivers that implement it but the error handling
code was not updated.

scsi_send_eh_cmnd(...) is used to send error handling commands and
request sense. The problem is that request sense comes as a single
command that gets into the batch queue and times out.  As result
device goes offline after several failed resets. This was observed
on virtio_scsi device resize operation.

[  496.316946] sd 0:0:4:0: [sdd] tag#117 scsi_eh_0: requesting sense
[  506.786356] sd 0:0:4:0: [sdd] tag#117 scsi_send_eh_cmnd timeleft: 0
[  506.787981] sd 0:0:4:0: [sdd] tag#117 abort

To fix this always set SCMD_LAST flag in scsi_send_eh_cmnd and
scsi_reset_ioctl(...).

Fixes: 8930a6c20791 ("scsi: core: add support for request batching")
Signed-off-by: Alexander Atanasov <alexander.atanasov@virtuozzo.com>
---
 drivers/scsi/scsi_error.c | 2 ++
 1 file changed, 2 insertions(+)

v1->v2: fix it globally not only for virtio_scsi, as suggested by
Paolo Bonzini, to avoid reintroducing the same bug.


RESEND -> add linux-scsi, remove stable

Comments

Ming Lei Dec. 18, 2023, 2:41 p.m. UTC | #1
On Fri, Dec 15, 2023 at 8:10 PM Alexander Atanasov
<alexander.atanasov@virtuozzo.com> wrote:
>
> In commit 8930a6c20791 ("scsi: core: add support for request batching")
> blk-mq last flags was mapped to SCMD_LAST and used as an indicator to
> send the batch for the drivers that implement it but the error handling
> code was not updated.
>
> scsi_send_eh_cmnd(...) is used to send error handling commands and
> request sense. The problem is that request sense comes as a single
> command that gets into the batch queue and times out.  As result
> device goes offline after several failed resets. This was observed
> on virtio_scsi device resize operation.
>
> [  496.316946] sd 0:0:4:0: [sdd] tag#117 scsi_eh_0: requesting sense
> [  506.786356] sd 0:0:4:0: [sdd] tag#117 scsi_send_eh_cmnd timeleft: 0
> [  506.787981] sd 0:0:4:0: [sdd] tag#117 abort
>
> To fix this always set SCMD_LAST flag in scsi_send_eh_cmnd and
> scsi_reset_ioctl(...).
>
> Fixes: 8930a6c20791 ("scsi: core: add support for request batching")
> Signed-off-by: Alexander Atanasov <alexander.atanasov@virtuozzo.com>

Reviewed-by: Ming Lei <ming.lei@redhat.com>
Martin K. Petersen Dec. 19, 2023, 2:19 a.m. UTC | #2
On Fri, 15 Dec 2023 14:10:08 +0200, Alexander Atanasov wrote:

> In commit 8930a6c20791 ("scsi: core: add support for request batching")
> blk-mq last flags was mapped to SCMD_LAST and used as an indicator to
> send the batch for the drivers that implement it but the error handling
> code was not updated.
> 
> scsi_send_eh_cmnd(...) is used to send error handling commands and
> request sense. The problem is that request sense comes as a single
> command that gets into the batch queue and times out.  As result
> device goes offline after several failed resets. This was observed
> on virtio_scsi device resize operation.
> 
> [...]

Applied to 6.7/scsi-fixes, thanks!

[1/1] scsi: code: always send batch on reset or error handling command
      https://git.kernel.org/mkp/scsi/c/066c5b46b6ea
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index c67cdcdc3ba8..1223d34c04da 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1152,6 +1152,7 @@  static enum scsi_disposition scsi_send_eh_cmnd(struct scsi_cmnd *scmd,
 
 	scsi_log_send(scmd);
 	scmd->submitter = SUBMITTED_BY_SCSI_ERROR_HANDLER;
+	scmd->flags |= SCMD_LAST;
 
 	/*
 	 * Lock sdev->state_mutex to avoid that scsi_device_quiesce() can
@@ -2459,6 +2460,7 @@  scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
 	scsi_init_command(dev, scmd);
 
 	scmd->submitter = SUBMITTED_BY_SCSI_RESET_IOCTL;
+	scmd->flags |= SCMD_LAST;
 	memset(&scmd->sdb, 0, sizeof(scmd->sdb));
 
 	scmd->cmd_len			= 0;