All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Ming Lei <ming.lei@redhat.com>, Hannes Reinecke <hare@suse.com>,
	Sumit Saxena <sumit.saxena@broadcom.com>,
	Kashyap Desai <kashyap.desai@broadcom.com>,
	Bart Van Assche <bvanassche@acm.org>,
	Ewan Milne <emilne@redhat.com>, Long Li <longli@microsoft.com>,
	"chenxiang (M)" <chenxiang66@hisilicon.com>,
	John Garry <john.garry@huawei.com>
Subject: [PATCH] scsi: core: fix race between handling STS_RESOURCE and completion
Date: Wed,  2 Dec 2020 18:04:19 +0800	[thread overview]
Message-ID: <20201202100419.525144-1-ming.lei@redhat.com> (raw)

When queuing IO request to LLD, STS_RESOURCE may be returned because:

- host in recovery or blocked
- target queue throttling or blocked
- LLD rejection

Any one of the above doesn't happen frequently enough.

BLK_STS_DEV_RESOURCE is returned to block layer for avoiding unnecessary
re-run queue, and it is just one small optimization. However, all
in-flight requests originated from this scsi device may be completed
just after reading 'sdev->device_busy', so BLK_STS_DEV_RESOURCE is
returned to block layer. And the current failed IO won't get chance
to be queued any more, since it is invisible at that time for either
scsi_run_queue_async() or blk-mq's RESTART.

Fix the issue by not returning BLK_STS_DEV_RESOURCE in this situation.

Cc: Hannes Reinecke <hare@suse.com>
Cc: Sumit Saxena <sumit.saxena@broadcom.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Ewan Milne <emilne@redhat.com>
Cc: Long Li <longli@microsoft.com>
Tested-by: "chenxiang (M)" <chenxiang66@hisilicon.com>
Reported-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 drivers/scsi/scsi_lib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 60c7a7d74852..03c6d0620bfd 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1703,8 +1703,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
 		break;
 	case BLK_STS_RESOURCE:
 	case BLK_STS_ZONE_RESOURCE:
-		if (atomic_read(&sdev->device_busy) ||
-		    scsi_device_blocked(sdev))
+		if (scsi_device_blocked(sdev))
 			ret = BLK_STS_DEV_RESOURCE;
 		break;
 	default:
-- 
2.28.0


             reply	other threads:[~2020-12-02 10:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 10:04 Ming Lei [this message]
2020-12-02 18:10 ` [PATCH] scsi: core: fix race between handling STS_RESOURCE and completion Bart Van Assche
2020-12-03  1:03   ` Ming Lei
2020-12-07  3:32     ` chenxiang (M)
2020-12-07  7:51       ` Ming Lei
2020-12-08  4:56 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201202100419.525144-1-ming.lei@redhat.com \
    --to=ming.lei@redhat.com \
    --cc=bvanassche@acm.org \
    --cc=chenxiang66@hisilicon.com \
    --cc=emilne@redhat.com \
    --cc=hare@suse.com \
    --cc=john.garry@huawei.com \
    --cc=kashyap.desai@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=martin.petersen@oracle.com \
    --cc=sumit.saxena@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.