]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
block: drop unnecessary blk_get/put_queue() in scsi_cmd_ioctl() and blk_get_tg()
authorTejun Heo <tj@kernel.org>
Wed, 19 Oct 2011 12:31:25 +0000 (14:31 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 19 Oct 2011 12:31:25 +0000 (14:31 +0200)
blk_get/put_queue() in scsi_cmd_ioctl() and throtl_get_tg() are
completely bogus.  The caller must have a reference to the queue on
entry and taking an extra reference doesn't change anything.

For scsi_cmd_ioctl(), the only effect is that it ends up checking
QUEUE_FLAG_DEAD on entry; however, this is bogus as queue can die
right after blk_get_queue().  Dead queue should be and is handled in
request issue path (it's somewhat broken now but that's a separate
problem and doesn't affect this one much).

throtl_get_tg() incorrectly assumes that q is rcu freed.  Also, it
doesn't check return value of blk_get_queue().  If the queue is
already dead, it ends up doing an extra put.

Drop them.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-throttle.c
block/scsi_ioctl.c

index f3f495ea4eeb94c54f80e064f3b038ce75078762..ecba5fcef201f46e5d9741a484b69299cf4fd22c 100644 (file)
@@ -324,12 +324,8 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data *td)
        /*
         * Need to allocate a group. Allocation of group also needs allocation
         * of per cpu stats which in-turn takes a mutex() and can block. Hence
-        * we need to drop rcu lock and queue_lock before we call alloc
-        *
-        * Take the request queue reference to make sure queue does not
-        * go away once we return from allocation.
+        * we need to drop rcu lock and queue_lock before we call alloc.
         */
-       blk_get_queue(q);
        rcu_read_unlock();
        spin_unlock_irq(q->queue_lock);
 
@@ -339,13 +335,11 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data *td)
         * dead
         */
        if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
-               blk_put_queue(q);
                if (tg)
                        kfree(tg);
 
                return ERR_PTR(-ENODEV);
        }
-       blk_put_queue(q);
 
        /* Group allocated and queue is still alive. take the lock */
        spin_lock_irq(q->queue_lock);
index 4f4230b79bb6ee3c8164e462e40d4bdea3dc1fcd..fbdf0d802ec43e5320d74c2279bd20cb37546a1c 100644 (file)
@@ -565,7 +565,7 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod
 {
        int err;
 
-       if (!q || blk_get_queue(q))
+       if (!q)
                return -ENXIO;
 
        switch (cmd) {
@@ -686,7 +686,6 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod
                        err = -ENOTTY;
        }
 
-       blk_put_queue(q);
        return err;
 }
 EXPORT_SYMBOL(scsi_cmd_ioctl);