From: Ming Lei <tom.leiming@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, linux-kernel@vger.kernel.org
Cc: Ming Lei <tom.leiming@gmail.com>
Subject: [PATCH 3/4] block: null_blk: fix queue leak inside removing device
Date: Tue, 24 Dec 2013 00:18:58 +0800 [thread overview]
Message-ID: <1387815539-12257-4-git-send-email-tom.leiming@gmail.com> (raw)
In-Reply-To: <1387815539-12257-1-git-send-email-tom.leiming@gmail.com>
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@kernel.dk>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/block/null_blk.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index a2e69d2..83a598e 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);
--
1.7.9.5
next prev parent reply other threads:[~2013-12-23 16:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-23 16:18 [PATCH 0/4] block: blk-mq: support blk_cleanup_queue on mq Ming Lei
2013-12-23 16:18 ` [PATCH 1/4] block: blk-mq: support draining mq queue Ming Lei
2013-12-23 16:24 ` Christoph Hellwig
2013-12-24 3:30 ` Ming Lei
2013-12-26 9:45 ` Christoph Hellwig
2013-12-26 10:12 ` Ming Lei
2013-12-26 10:53 ` Christoph Hellwig
2013-12-23 16:18 ` [PATCH 2/4] block: blk-mq: make blk_sync_queue support mq Ming Lei
2013-12-23 16:25 ` Christoph Hellwig
2013-12-24 3:35 ` Ming Lei
2013-12-23 16:18 ` Ming Lei [this message]
2013-12-23 16:26 ` [PATCH 3/4] block: null_blk: fix queue leak inside removing device Christoph Hellwig
2013-12-23 16:18 ` [PATCH 4/4] block: blk-mq: don't export blk_mq_free_queue() Ming Lei
2013-12-23 16:27 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387815539-12257-4-git-send-email-tom.leiming@gmail.com \
--to=tom.leiming@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®