forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scsi: Use blk_mq_rq_to_pdu() to convert a request to a SCSI command p…
…ointer Since commit e9c787e ("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 <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
- Loading branch information
1 parent
e7008ff
commit bed2213
Showing
3 changed files
with
11 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -627,7 +627,7 @@ static void scsi_release_bidi_buffers(struct scsi_cmnd *cmd) | |
static bool scsi_end_request(struct request *req, blk_status_t error, | ||
unsigned int bytes, unsigned int bidi_bytes) | ||
{ | ||
struct scsi_cmnd *cmd = req->special; | ||
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | ||
struct scsi_device *sdev = cmd->device; | ||
struct request_queue *q = sdev->request_queue; | ||
|
||
|
@@ -1171,7 +1171,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd) | |
|
||
static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req) | ||
{ | ||
struct scsi_cmnd *cmd = req->special; | ||
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | ||
|
||
/* | ||
* Passthrough requests may transfer data, in which case they must | ||
|
@@ -1202,7 +1202,7 @@ static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req) | |
*/ | ||
static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req) | ||
{ | ||
struct scsi_cmnd *cmd = req->special; | ||
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | ||
|
||
if (unlikely(sdev->handler && sdev->handler->prep_fn)) { | ||
int ret = sdev->handler->prep_fn(sdev, req); | ||
|
@@ -1217,7 +1217,7 @@ static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req) | |
|
||
static int scsi_setup_cmnd(struct scsi_device *sdev, struct request *req) | ||
{ | ||
struct scsi_cmnd *cmd = req->special; | ||
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | ||
|
||
if (!blk_rq_bytes(req)) | ||
cmd->sc_data_direction = DMA_NONE; | ||
|
@@ -1354,7 +1354,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req) | |
|
||
static void scsi_unprep_fn(struct request_queue *q, struct request *req) | ||
{ | ||
scsi_uninit_cmd(req->special); | ||
scsi_uninit_cmd(blk_mq_rq_to_pdu(req)); | ||
} | ||
|
||
/* | ||
|
@@ -1545,7 +1545,7 @@ static int scsi_lld_busy(struct request_queue *q) | |
*/ | ||
static void scsi_kill_request(struct request *req, struct request_queue *q) | ||
{ | ||
struct scsi_cmnd *cmd = req->special; | ||
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req); | ||
struct scsi_device *sdev; | ||
struct scsi_target *starget; | ||
struct Scsi_Host *shost; | ||
|
@@ -1576,7 +1576,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q) | |
|
||
static void scsi_softirq_done(struct request *rq) | ||
{ | ||
struct scsi_cmnd *cmd = rq->special; | ||
struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); | ||
unsigned long wait_for = (cmd->allowed + 1) * rq->timeout; | ||
int disposition; | ||
|
||
|
@@ -1764,8 +1764,8 @@ static void scsi_request_fn(struct request_queue *q) | |
blk_start_request(req); | ||
|
||
spin_unlock_irq(q->queue_lock); | ||
cmd = req->special; | ||
if (unlikely(cmd == NULL)) { | ||
cmd = blk_mq_rq_to_pdu(req); | ||
if (cmd != req->special) { | ||
printk(KERN_CRIT "impossible request in %s.\n" | ||
"please mail a stack trace to " | ||
"[email protected]\n", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters