aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_lib.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2014-02-20 17:20:58 -0500
committerJames Bottomley <JBottomley@Parallels.com>2014-03-15 13:19:25 -0400
commit134997a041f70d4aa5434d2833c8a3cf33697899 (patch)
tree786d6f355b26ade2bba828da23327021e0404393 /drivers/scsi/scsi_lib.c
parent27e9e0f12acb5a76c72c3eed31ad3336e1970717 (diff)
[SCSI] remove a useless get/put_device pair in scsi_requeue_command
Avoid a spurious device get/put pair by cleaning up scsi_requeue_command and folding scsi_unprep_request into it. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r--drivers/scsi/scsi_lib.c35
1 files changed, 3 insertions, 32 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index eba8044d0b11..5681c05ac506 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -75,29 +75,6 @@ struct kmem_cache *scsi_sdb_cache;
75 */ 75 */
76#define SCSI_QUEUE_DELAY 3 76#define SCSI_QUEUE_DELAY 3
77 77
78/*
79 * Function: scsi_unprep_request()
80 *
81 * Purpose: Remove all preparation done for a request, including its
82 * associated scsi_cmnd, so that it can be requeued.
83 *
84 * Arguments: req - request to unprepare
85 *
86 * Lock status: Assumed that no locks are held upon entry.
87 *
88 * Returns: Nothing.
89 */
90static void scsi_unprep_request(struct request *req)
91{
92 struct scsi_cmnd *cmd = req->special;
93
94 blk_unprep_request(req);
95 req->special = NULL;
96
97 scsi_put_command(cmd);
98 put_device(&cmd->device->sdev_gendev);
99}
100
101/** 78/**
102 * __scsi_queue_insert - private queue insertion 79 * __scsi_queue_insert - private queue insertion
103 * @cmd: The SCSI command being requeued 80 * @cmd: The SCSI command being requeued
@@ -503,16 +480,10 @@ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
503 struct request *req = cmd->request; 480 struct request *req = cmd->request;
504 unsigned long flags; 481 unsigned long flags;
505 482
506 /*
507 * We need to hold a reference on the device to avoid the queue being
508 * killed after the unlock and before scsi_run_queue is invoked which
509 * may happen because scsi_unprep_request() puts the command which
510 * releases its reference on the device.
511 */
512 get_device(&sdev->sdev_gendev);
513
514 spin_lock_irqsave(q->queue_lock, flags); 483 spin_lock_irqsave(q->queue_lock, flags);
515 scsi_unprep_request(req); 484 blk_unprep_request(req);
485 req->special = NULL;
486 scsi_put_command(cmd);
516 blk_requeue_request(q, req); 487 blk_requeue_request(q, req);
517 spin_unlock_irqrestore(q->queue_lock, flags); 488 spin_unlock_irqrestore(q->queue_lock, flags);
518 489