]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
[SCSI] remove a useless get/put_device pair in scsi_request_fn
authorBart Van Assche <bvanassche@acm.org>
Thu, 20 Feb 2014 22:20:56 +0000 (14:20 -0800)
committerJames Bottomley <JBottomley@Parallels.com>
Sat, 15 Mar 2014 17:19:25 +0000 (10:19 -0700)
SCSI devices may only be removed by calling scsi_remove_device().
That function must invoke blk_cleanup_queue() before the final put
of sdev->sdev_gendev. Since blk_cleanup_queue() waits for the
block queue to drain and then tears it down, scsi_request_fn cannot
be active anymore after blk_cleanup_queue() has returned and hence
the get_device()/put_device() pair in scsi_request_fn is unnecessary.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/scsi_lib.c

index 007e979fa4372e4fb345193e058554275732efbf..f8a8765a7979d1d2566c8c7123e89ee4bdcc40f4 100644 (file)
@@ -1565,16 +1565,14 @@ static void scsi_softirq_done(struct request *rq)
  * Lock status: IO request lock assumed to be held when called.
  */
 static void scsi_request_fn(struct request_queue *q)
+       __releases(q->queue_lock)
+       __acquires(q->queue_lock)
 {
        struct scsi_device *sdev = q->queuedata;
        struct Scsi_Host *shost;
        struct scsi_cmnd *cmd;
        struct request *req;
 
-       if(!get_device(&sdev->sdev_gendev))
-               /* We must be tearing the block queue down already */
-               return;
-
        /*
         * To start with, we keep looping until the queue is empty, or until
         * the host is no longer able to accept any more requests.
@@ -1663,7 +1661,7 @@ static void scsi_request_fn(struct request_queue *q)
                        goto out_delay;
        }
 
-       goto out;
+       return;
 
  not_ready:
        spin_unlock_irq(shost->host_lock);
@@ -1682,12 +1680,6 @@ static void scsi_request_fn(struct request_queue *q)
 out_delay:
        if (sdev->device_busy == 0)
                blk_delay_queue(q, SCSI_QUEUE_DELAY);
-out:
-       /* must be careful here...if we trigger the ->remove() function
-        * we cannot be holding the q lock */
-       spin_unlock_irq(q->queue_lock);
-       put_device(&sdev->sdev_gendev);
-       spin_lock_irq(q->queue_lock);
 }
 
 u64 scsi_calculate_bounce_limit(struct Scsi_Host *shost)