Commit f8b8bfcf authored by Alexander Atanasov's avatar Alexander Atanasov Committed by Li Lingfeng
Browse files

scsi: core: Always send batch on reset or error handling command

stable inclusion
from stable-v5.10.207
commit a7fd5c7ba4b95be7c83a6e6805b8eb4e111d9ae7
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I8ZD3X
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.10.207&id=a7fd5c7ba4b95be7c83a6e6805b8eb4e111d9ae7



-------------------------

commit 066c5b46b6eaf2f13f80c19500dbb3b84baabb33 upstream.

In commit 8930a6c2 ("scsi: core: add support for request batching") the
block layer bd->last flag was mapped to SCMD_LAST and used as an indicator
to send the batch for the drivers that implement this feature. However, the
error handling code was not updated accordingly.

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 a result the device goes
offline after several failed resets. This was observed on virtio_scsi
during a 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: 8930a6c2 ("scsi: core: add support for request batching")
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAlexander Atanasov <alexander.atanasov@virtuozzo.com>
Link: https://lore.kernel.org/r/20231215121008.2881653-1-alexander.atanasov@virtuozzo.com


Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
parent 5e8bbb49
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1069,6 +1069,7 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,

	scsi_log_send(scmd);
	scmd->scsi_done = scsi_eh_done;
	scmd->flags |= SCMD_LAST;

	/*
	 * Lock sdev->state_mutex to avoid that scsi_device_quiesce() can
@@ -2361,6 +2362,7 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
	scsi_init_command(dev, scmd);
	scmd->request = rq;
	scmd->cmnd = scsi_req(rq)->cmd;
	scmd->flags |= SCMD_LAST;

	scmd->scsi_done		= scsi_reset_provider_done_command;
	memset(&scmd->sdb, 0, sizeof(scmd->sdb));