Skip to content

Commit 315fcee

Browse files
htejunaxboe
authored andcommitted
block: drop unnecessary blk_get/put_queue() in scsi_cmd_ioctl() and blk_get_tg()
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>
1 parent 75eb6c3 commit 315fcee

2 files changed

Lines changed: 2 additions & 9 deletions

File tree

‎block/blk-throttle.c‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,8 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data *td)
324324
/*
325325
* Need to allocate a group. Allocation of group also needs allocation
326326
* of per cpu stats which in-turn takes a mutex() and can block. Hence
327-
* we need to drop rcu lock and queue_lock before we call alloc
328-
*
329-
* Take the request queue reference to make sure queue does not
330-
* go away once we return from allocation.
327+
* we need to drop rcu lock and queue_lock before we call alloc.
331328
*/
332-
blk_get_queue(q);
333329
rcu_read_unlock();
334330
spin_unlock_irq(q->queue_lock);
335331

@@ -339,13 +335,11 @@ static struct throtl_grp * throtl_get_tg(struct throtl_data *td)
339335
* dead
340336
*/
341337
if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) {
342-
blk_put_queue(q);
343338
if (tg)
344339
kfree(tg);
345340

346341
return ERR_PTR(-ENODEV);
347342
}
348-
blk_put_queue(q);
349343

350344
/* Group allocated and queue is still alive. take the lock */
351345
spin_lock_irq(q->queue_lock);

‎block/scsi_ioctl.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod
565565
{
566566
int err;
567567

568-
if (!q || blk_get_queue(q))
568+
if (!q)
569569
return -ENXIO;
570570

571571
switch (cmd) {
@@ -686,7 +686,6 @@ int scsi_cmd_ioctl(struct request_queue *q, struct gendisk *bd_disk, fmode_t mod
686686
err = -ENOTTY;
687687
}
688688

689-
blk_put_queue(q);
690689
return err;
691690
}
692691
EXPORT_SYMBOL(scsi_cmd_ioctl);

0 commit comments

Comments
 (0)