Skip to contentSkip to conversation

scsi-mq: add operations about device_busy/target_busy/host_busy in scsi_mq_queue_rq().

PATCH Applied majianpeng 2 participants 2 messages Nov 29, 2013 – Dec 23, 2013 SCSI

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 2/6 scsi-mq: add operations about device_busy/target_busy/host_busy in scsi_mq_queue_rq().

To make the scsi-mq work, add those operations in scsi_mq_queue_rq().

---
 drivers/scsi/scsi-mq.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/scsi/scsi-mq.c +8 -0
index 918b443..eccdbd5 100644
@@ -20,8 +20,10 @@ static int scsi_mq_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
 	struct scsi_device *sdev = q->queuedata;
 	struct scsi_cmnd *sc = rq->special;
 	struct scatterlist *sg = sc->mq_sgl;
+	struct Scsi_Host *shost = sdev->host;
 	unsigned char *sense_buf = sc->sense_buffer;
 	int rc;
+
 	/*
 	 * With blk-mq rq->special pre-allocation, scsi_get_cmd_from_req()
 	 * is using the hardware context *sc descriptor
@@ -66,6 +68,12 @@ static int scsi_mq_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
 	if (sdev->host->hostt->cmd_size)
 		sc->SCp.ptr = blk_mq_rq_to_pdu(rq) + sizeof(struct scsi_cmnd);
 
+	spin_lock_irq(shost->host_lock);
+	sdev->device_busy++;
+	scsi_target(sdev)->target_busy++;
+	shost->host_busy++;
+	spin_unlock_irq(shost->host_lock);
+
 	rc = scsi_dispatch_cmd(sc);
 	switch (rc) {
 	case 0:
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 25 lines · majianpeng

To make the scsi-mq work, add those operations in scsi_mq_queue_rq().

---
 drivers/scsi/scsi-mq.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/scsi/scsi-mq.c +2 -0
index 918b443..eccdbd5 100644
@@ -20,8 +20,10 @@ static int scsi_mq_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
 	struct scsi_device *sdev = q->queuedata;
 	struct scsi_cmnd *sc = rq->special;
 	struct scatterlist *sg = sc->mq_sgl;
+	struct Scsi_Host *shost = sdev->host;
 	unsigned char *sense_buf = sc->sense_buffer;
 	int rc;
+
 	/*
 	 * With blk-mq rq->special pre-allocation, scsi_get_cmd_from_req()
 	 * is using the hardware context *sc descriptor
@@ -66,6 +68,12 @@ static int scsi_mq_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
 	if (sdev->host->hostt->cmd_size)
 		sc->SCp.ptr = blk_mq_rq_to_pdu(rq) + sizeof(struct scsi_cmnd);

drivers/scsi/scsi-mq.c static int scsi_mq_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq) · line 79

Quoted 10 lines
drivers/scsi/scsi-mq.c +6 -0
 
+	spin_lock_irq(shost->host_lock);
+	sdev->device_busy++;
+	scsi_target(sdev)->target_busy++;
+	shost->host_busy++;
+	spin_unlock_irq(shost->host_lock);
+
 	rc = scsi_dispatch_cmd(sc);
 	switch (rc) {
 	case 0:

Same with this patch, it doesn't seem to be strictly required for the QEMU AHCI + TYPE_ROM test case to function with v3.13-rc3 code.

I've been avoiding legacy host_lock access in the fast-path thus far, and would not like to give that away just yet unless it's absolutely required for prototype scsi-mq code to function.

--nab