Commit bed2213d01de474eb8a6f3891070eec6be6fe772
Committed by
Martin K. Petersen
1 parent
e7008ff5c6
scsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer
Since commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request") struct request and struct scsi_cmnd are adjacent. This means that there is now an alternative to reading req->special to convert a pointer to a prepared request into a SCSI command pointer, namely by using blk_mq_rq_to_pdu(). Make this change where appropriate. Although this patch does not change any functionality, it slightly improves performance and slightly improves readability. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Showing 3 changed files with 11 additions and 11 deletions Side-by-side Diff
drivers/scsi/scsi_error.c
... | ... | @@ -259,7 +259,7 @@ |
259 | 259 | */ |
260 | 260 | enum blk_eh_timer_return scsi_times_out(struct request *req) |
261 | 261 | { |
262 | - struct scsi_cmnd *scmd = req->special; | |
262 | + struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req); | |
263 | 263 | enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED; |
264 | 264 | struct Scsi_Host *host = scmd->device->host; |
265 | 265 |
drivers/scsi/scsi_lib.c
... | ... | @@ -627,7 +627,7 @@ |
627 | 627 | static bool scsi_end_request(struct request *req, blk_status_t error, |
628 | 628 | unsigned int bytes, unsigned int bidi_bytes) |
629 | 629 | { |
630 | - struct scsi_cmnd *cmd = req->special; | |
630 | + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | |
631 | 631 | struct scsi_device *sdev = cmd->device; |
632 | 632 | struct request_queue *q = sdev->request_queue; |
633 | 633 | |
... | ... | @@ -1171,7 +1171,7 @@ |
1171 | 1171 | |
1172 | 1172 | static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req) |
1173 | 1173 | { |
1174 | - struct scsi_cmnd *cmd = req->special; | |
1174 | + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | |
1175 | 1175 | |
1176 | 1176 | /* |
1177 | 1177 | * Passthrough requests may transfer data, in which case they must |
... | ... | @@ -1202,7 +1202,7 @@ |
1202 | 1202 | */ |
1203 | 1203 | static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req) |
1204 | 1204 | { |
1205 | - struct scsi_cmnd *cmd = req->special; | |
1205 | + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | |
1206 | 1206 | |
1207 | 1207 | if (unlikely(sdev->handler && sdev->handler->prep_fn)) { |
1208 | 1208 | int ret = sdev->handler->prep_fn(sdev, req); |
... | ... | @@ -1217,7 +1217,7 @@ |
1217 | 1217 | |
1218 | 1218 | static int scsi_setup_cmnd(struct scsi_device *sdev, struct request *req) |
1219 | 1219 | { |
1220 | - struct scsi_cmnd *cmd = req->special; | |
1220 | + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | |
1221 | 1221 | |
1222 | 1222 | if (!blk_rq_bytes(req)) |
1223 | 1223 | cmd->sc_data_direction = DMA_NONE; |
... | ... | @@ -1354,7 +1354,7 @@ |
1354 | 1354 | |
1355 | 1355 | static void scsi_unprep_fn(struct request_queue *q, struct request *req) |
1356 | 1356 | { |
1357 | - scsi_uninit_cmd(req->special); | |
1357 | + scsi_uninit_cmd(blk_mq_rq_to_pdu(req)); | |
1358 | 1358 | } |
1359 | 1359 | |
1360 | 1360 | /* |
... | ... | @@ -1545,7 +1545,7 @@ |
1545 | 1545 | */ |
1546 | 1546 | static void scsi_kill_request(struct request *req, struct request_queue *q) |
1547 | 1547 | { |
1548 | - struct scsi_cmnd *cmd = req->special; | |
1548 | + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | |
1549 | 1549 | struct scsi_device *sdev; |
1550 | 1550 | struct scsi_target *starget; |
1551 | 1551 | struct Scsi_Host *shost; |
... | ... | @@ -1576,7 +1576,7 @@ |
1576 | 1576 | |
1577 | 1577 | static void scsi_softirq_done(struct request *rq) |
1578 | 1578 | { |
1579 | - struct scsi_cmnd *cmd = rq->special; | |
1579 | + struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); | |
1580 | 1580 | unsigned long wait_for = (cmd->allowed + 1) * rq->timeout; |
1581 | 1581 | int disposition; |
1582 | 1582 | |
... | ... | @@ -1764,8 +1764,8 @@ |
1764 | 1764 | blk_start_request(req); |
1765 | 1765 | |
1766 | 1766 | spin_unlock_irq(q->queue_lock); |
1767 | - cmd = req->special; | |
1768 | - if (unlikely(cmd == NULL)) { | |
1767 | + cmd = blk_mq_rq_to_pdu(req); | |
1768 | + if (cmd != req->special) { | |
1769 | 1769 | printk(KERN_CRIT "impossible request in %s.\n" |
1770 | 1770 | "please mail a stack trace to " |
1771 | 1771 | "linux-scsi@vger.kernel.org\n", |