summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Battersby <tonyb@cybernetics.com>2014-08-22 15:53:39 -0400
committerJens Axboe <axboe@fb.com>2015-04-02 19:34:54 -0600
commitfdfd40455d621a43858afaf9d72f5775f66a0fcc (patch)
treed9931bc90d7522c7b4d8e9a48010d8cd5a0f8291
parentc8910683a525b79ff0c85e5a87acb542a6aaeb45 (diff)
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>
-rw-r--r--block/blk-core.c1
-rw-r--r--block/blk-mq.c2
-rw-r--r--drivers/scsi/scsi_lib.c1
3 files changed, 2 insertions, 2 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 2a9401f04a2b..b017ce8aabf7 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1275,7 +1275,6 @@ void blk_rq_set_block_pc(struct request *rq)
rq->__sector = (sector_t) -1;
rq->bio = rq->biotail = NULL;
memset(rq->__cmd, 0, sizeof(rq->__cmd));
- rq->cmd = rq->__cmd;
}
EXPORT_SYMBOL(blk_rq_set_block_pc);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1247a2faa61d..a970ef91854c 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -221,6 +221,8 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
/* tag was already set */
rq->errors = 0;
+ rq->cmd = rq->__cmd;
+
rq->extra_len = 0;
rq->sense_len = 0;
rq->resid_len = 0;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 47ef9da53e96..e662a98b400f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1843,7 +1843,6 @@ static int scsi_mq_prep_fn(struct request *req)
cmd->tag = req->tag;
- req->cmd = req->__cmd;
cmd->cmnd = req->cmd;
cmd->prot_op = SCSI_PROT_NORMAL;