If a request can't be queued in scsi_queue_rq(), then we error out with a blk_status_t code. Such a scenario may be the scsi_device has its transport offline.
For BLK_STS_RESOURCE or BLK_STS_AGAIN, the request will be requeued in the block layer. For other errors, the block layer ends the request and so we won't see it again (until recycled). Normally when a request completes scmd->flags is cleared in scsi_end_request(). However for the error scenario mentioned above, scsi_end_request() is not called and so scmd->flags is not cleared. As such, when the request is recycled we see the old value in scmd->flags. Fix this issue by clearing scmd->flags in the error scenario mentioned by calling scsi_cleanup_rq(). Signed-off-by: John Garry <[email protected]> --- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index b52b4c5daa42..36bc995e4e25 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1994,8 +1994,8 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, * we hit an error, as we will never see this command * again. */ - if (req->rq_flags & RQF_DONTPREP) - scsi_mq_uninit_cmd(cmd); + scsi_cleanup_rq(req); + scsi_run_queue_async(sdev); break; } -- 2.43.0
