Skip to contentSkip to conversation

scsi-mq: fix 'BUG_ON(count > sdb->table.nents)' in scsi_init_sgtable().

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

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 5/6 scsi-mq: fix 'BUG_ON(count > sdb->table.nents)' in scsi_init_sgtable().

Test cdrom on intel ahci, it will trigger this condition. This is because scsi-mq don' test 'q->dma_drain_size && blk_rq_bytes(rq)' like in blk_peek_request().

---
 drivers/scsi/scsi-mq.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/scsi/scsi-mq.c +10 -0
index 933ba0f..78b05c1 100644
@@ -35,6 +35,16 @@ static int scsi_mq_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
 	sc->device = sdev;
 	sc->sense_buffer = sense_buf;
 	sc->mq_sgl = sg;
+
+	if (q->dma_drain_size && blk_rq_bytes(rq)) {
+		/*
+		 * make sure space for the drain appears we
+		 * know we can do this because max_hw_segments
+		 * has been adjusted to be one fewer than the
+		 * device can handle
+		 */
+		rq->nr_phys_segments++;
+	}
 	/*
 	 * Mark the end of the pre-allocated SGL based upon the
 	 * incoming number of physical segments from blk-mq
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 9 lines · majianpeng

Test cdrom on intel ahci, it will trigger this condition. This is because scsi-mq don' test 'q->dma_drain_size && blk_rq_bytes(rq)' like in blk_peek_request().

---
 drivers/scsi/scsi-mq.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

Applied, + squashed into current target-pending/scsi-mq code.

Thanks Jianpeng!

--nab

Quoted 21 lines
drivers/scsi/scsi-mq.c +10 -0
index 933ba0f..78b05c1 100644
@@ -35,6 +35,16 @@ static int scsi_mq_queue_rq(struct blk_mq_hw_ctx *hctx, struct request *rq)
 	sc->device = sdev;
 	sc->sense_buffer = sense_buf;
 	sc->mq_sgl = sg;
+
+	if (q->dma_drain_size && blk_rq_bytes(rq)) {
+		/*
+		 * make sure space for the drain appears we
+		 * know we can do this because max_hw_segments
+		 * has been adjusted to be one fewer than the
+		 * device can handle
+		 */
+		rq->nr_phys_segments++;
+	}
 	/*
 	 * Mark the end of the pre-allocated SGL based upon the
 	 * incoming number of physical segments from blk-mq