Skip to content

Commit 6f4a162

Browse files
abattersbyaxboe
authored andcommitted
scsi-mq: fix requests that use a separate CDB buffer
This patch fixes code such as the following with scsi-mq enabled: rq = blk_get_request(...); blk_rq_set_block_pc(rq); rq->cmd = my_cmd_buffer; /* separate CDB buffer */ blk_execute_rq_nowait(...); Code like this appears in e.g. sg_start_req() in drivers/scsi/sg.c (for large CDBs only). Without this patch, scsi_mq_prep_fn() will set rq->cmd back to rq->__cmd, causing the wrong CDB to be sent to the device. Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent a57821c commit 6f4a162

3 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎block/blk-core.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,6 @@ void blk_rq_set_block_pc(struct request *rq)
12521252
rq->__sector = (sector_t) -1;
12531253
rq->bio = rq->biotail = NULL;
12541254
memset(rq->__cmd, 0, sizeof(rq->__cmd));
1255-
rq->cmd = rq->__cmd;
12561255
}
12571256
EXPORT_SYMBOL(blk_rq_set_block_pc);
12581257

‎block/blk-mq.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
176176
/* tag was already set */
177177
rq->errors = 0;
178178

179+
rq->cmd = rq->__cmd;
180+
179181
rq->extra_len = 0;
180182
rq->sense_len = 0;
181183
rq->resid_len = 0;

‎drivers/scsi/scsi_lib.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,6 @@ static int scsi_mq_prep_fn(struct request *req)
18081808

18091809
cmd->tag = req->tag;
18101810

1811-
req->cmd = req->__cmd;
18121811
cmd->cmnd = req->cmd;
18131812
cmd->prot_op = SCSI_PROT_NORMAL;
18141813

0 commit comments

Comments
 (0)