Re: [block:for-3.14/core] blk-mq: Compile fix for null_blk

From: Jens Axboe
Date: Sat Jan 11 2014 - 09:44:00 EST


On Sat, Jan 11 2014, Linus Torvalds wrote:
> On Fri, Jan 10, 2014 at 3:58 AM, Matias Bjorling <m@xxxxxxxxxxx> wrote:
> >
> > The patch from Ming Lei is missing in -rc6
> >
> > 4af48694451676403188a62385dd1a2849fc05c5
> > block: null_blk: fix queue leak inside removing device
> >
> > Its queued for -rc7. It removes the usage of blk_mq_free_queue in blk_null.
>
> Jens? I'm going to do an rc8 tomorrow, and I haven't seen any pull requests..

Sorry, between jobs and houses, and the two other patches in there were
being evaluated. If you could just apply this one directly, then that'd
be great!

commit 4af48694451676403188a62385dd1a2849fc05c5
Author: Ming Lei <tom.leiming@xxxxxxxxx>
Date: Thu Dec 26 21:31:37 2013 +0800

block: null_blk: fix queue leak inside removing device

When queue_mode is NULL_Q_MQ and null_blk is being removed,
blk_cleanup_queue() isn't called to cleanup queue, so the
queue allocated won't be freed.

This patch calls blk_cleanup_queue() for MQ to drain all
pending requests first and release the reference counter
of queue kobject, then blk_mq_free_queue() will be called
in queue kobject's release handler when queue kobject's
reference counter drops to zero.

Cc: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Ming Lei <tom.leiming@xxxxxxxxx>
Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index a2e69d26266d..83a598ebb65a 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -425,10 +425,7 @@ static void null_del_dev(struct nullb *nullb)
list_del_init(&nullb->list);

del_gendisk(nullb->disk);
- if (queue_mode == NULL_Q_MQ)
- blk_mq_free_queue(nullb->q);
- else
- blk_cleanup_queue(nullb->q);
+ blk_cleanup_queue(nullb->q);
put_disk(nullb->disk);
kfree(nullb);
}
@@ -578,10 +575,7 @@ static int null_add_dev(void)
disk = nullb->disk = alloc_disk_node(1, home_node);
if (!disk) {
queue_fail:
- if (queue_mode == NULL_Q_MQ)
- blk_mq_free_queue(nullb->q);
- else
- blk_cleanup_queue(nullb->q);
+ blk_cleanup_queue(nullb->q);
cleanup_queues(nullb);
err:
kfree(nullb);

--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/