diff mbox

[2/6] scsi: ensure that a request is valid when returning it from scsi_find_tag()

Message ID 1428427120-20971-3-git-send-email-axboe@fb.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jens Axboe April 7, 2015, 5:18 p.m. UTC
For the scsi-mq case, ensure that the request has been started before
returning it from scsi_find_tag(). This is akin to the ->special
check for the non-mq case, it ensures that the request has been setup
and issued.

Signed-off-by: Jens Axboe <axboe@fb.com>
---
 include/scsi/scsi_tcq.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig April 13, 2015, 9:47 a.m. UTC | #1
On Tue, Apr 07, 2015 at 11:18:36AM -0600, Jens Axboe wrote:
> For the scsi-mq case, ensure that the request has been started before
> returning it from scsi_find_tag(). This is akin to the ->special
> check for the non-mq case, it ensures that the request has been setup
> and issued.
> 
> Signed-off-by: Jens Axboe <axboe@fb.com>

Shouldn't this be done in blk_mq_tag_to_rq?  In general when a driver
looks for an active tag it wants an active tag, so working around
this in the driver seems like a bad idea.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index b27977e8aaed..8634cab61aeb 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -35,8 +35,15 @@  static inline struct scsi_cmnd *scsi_find_tag(struct scsi_device *sdev, int tag)
         struct request *req;
 
         if (tag != SCSI_NO_TAG) {
-		if (shost_use_blk_mq(sdev->host))
-			return scsi_mq_find_tag(sdev->host, tag);
+		if (shost_use_blk_mq(sdev->host)) {
+			struct scsi_cmnd *scmd;
+
+			scmd = scsi_mq_find_tag(sdev->host, tag);
+			if (blk_mq_request_started(scmd->request))
+				return scmd;
+
+			return NULL;
+		}
 
 		req = blk_queue_find_tag(sdev->request_queue, tag);
 	        return req ? (struct scsi_cmnd *)req->special : NULL;