From dfa88f7425947658f1989d1f6afac08ca2408caa Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 1 Aug 2022 10:45:57 +0200 Subject: [PATCH] 4.19-stable patches added patches: scsi-core-fix-race-between-handling-sts_resource-and-completion.patch --- ...handling-sts_resource-and-completion.patch | 57 +++++++++++++++++++ queue-4.19/series | 1 + 2 files changed, 58 insertions(+) create mode 100644 queue-4.19/scsi-core-fix-race-between-handling-sts_resource-and-completion.patch diff --git a/queue-4.19/scsi-core-fix-race-between-handling-sts_resource-and-completion.patch b/queue-4.19/scsi-core-fix-race-between-handling-sts_resource-and-completion.patch new file mode 100644 index 00000000000..d517e165098 --- /dev/null +++ b/queue-4.19/scsi-core-fix-race-between-handling-sts_resource-and-completion.patch @@ -0,0 +1,57 @@ +From 673235f915318ced5d7ec4b2bfd8cb909e6a4a55 Mon Sep 17 00:00:00 2001 +From: Ming Lei +Date: Wed, 2 Dec 2020 18:04:19 +0800 +Subject: scsi: core: Fix race between handling STS_RESOURCE and completion + +From: Ming Lei + +commit 673235f915318ced5d7ec4b2bfd8cb909e6a4a55 upstream. + +When queuing I/O request to LLD, STS_RESOURCE may be returned because: + + - Host is in recovery or blocked + + - Target queue throttling or target is blocked + + - LLD rejection + +In these scenarios BLK_STS_DEV_RESOURCE is returned to the block layer to +avoid an unnecessary re-run of the queue. However, all of the requests +queued to this SCSI device may complete immediately after reading +'sdev->device_busy' and BLK_STS_DEV_RESOURCE is returned to block layer. In +that case the current I/O won't get a chance to get queued since it is +invisible at that time for both scsi_run_queue_async() and blk-mq's +RESTART. + +Fix the issue by not returning BLK_STS_DEV_RESOURCE in this situation. + +Link: https://lore.kernel.org/r/20201202100419.525144-1-ming.lei@redhat.com +Fixes: 86ff7c2a80cd ("blk-mq: introduce BLK_STS_DEV_RESOURCE") +Cc: Hannes Reinecke +Cc: Sumit Saxena +Cc: Kashyap Desai +Cc: Bart Van Assche +Cc: Ewan Milne +Cc: Long Li +Reported-by: John Garry +Tested-by: "chenxiang (M)" +Signed-off-by: Ming Lei +Signed-off-by: Martin K. Petersen +Signed-off-by: Yu Kuai +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/scsi_lib.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +--- a/drivers/scsi/scsi_lib.c ++++ b/drivers/scsi/scsi_lib.c +@@ -2157,8 +2157,7 @@ out_put_budget: + case BLK_STS_OK: + break; + case BLK_STS_RESOURCE: +- if (atomic_read(&sdev->device_busy) || +- scsi_device_blocked(sdev)) ++ if (scsi_device_blocked(sdev)) + ret = BLK_STS_DEV_RESOURCE; + break; + default: diff --git a/queue-4.19/series b/queue-4.19/series index adb9bee8e5a..e29a63af51f 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -26,3 +26,4 @@ arm-crypto-comment-out-gcc-warning-that-breaks-clang-builds.patch mt7601u-add-usb-device-id-for-some-versions-of-xiaodu-wifi-dongle.patch fbcon-prevent-that-screen-size-is-smaller-than-font-size.patch fbmem-check-virtual-screen-sizes-in-fb_set_var.patch +scsi-core-fix-race-between-handling-sts_resource-and-completion.patch -- 2.47.3