[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1382954409-30789-2-git-send-email-m@bjorling.me>
Date: Mon, 28 Oct 2013 11:00:08 +0100
From: Matias Bjorling <m@...rling.me>
To: axboe@...nel.dk
Cc: linux-kernel@...r.kernel.org, Matias Bjorling <m@...rling.me>
Subject: [PATCH 1/2] blk-mq: allow request queues to share tags map
Some devices, such as NVMe, initializes a limited number of queues. These are
shared by all the block devices. Allow a driver to tap into the tags
structure and decide if an existing tag structure should be used.
Signed-off-by: Matias Bjorling <m@...rling.me>
---
block/blk-mq-tag.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index d64a02f..fae78fd 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -1,4 +1,5 @@
#include <linux/kernel.h>
+#include <linux/kref.h>
#include <linux/module.h>
#include <linux/percpu_ida.h>
@@ -18,6 +19,8 @@ struct blk_mq_tags {
struct percpu_ida free_tags;
struct percpu_ida reserved_tags;
+
+ struct kref ref_count;
};
void blk_mq_wait_for_tags(struct blk_mq_tags *tags)
@@ -116,6 +119,12 @@ void blk_mq_tag_busy_iter(struct blk_mq_tags *tags,
kfree(tag_map);
}
+void blk_mq_get_tags(struct blk_mq_tags *tags)
+{
+ kref_get(&tags->ref_count);
+}
+EXPORT_SYMBOL(blk_mq_get_tags);
+
struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
unsigned int reserved_tags, int node)
{
@@ -145,6 +154,8 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
tags->nr_max_cache = nr_cache;
tags->nr_batch_move = max(1u, nr_cache / 2);
+ kref_init(&tags->ref_count);
+
ret = __percpu_ida_init(&tags->free_tags, tags->nr_tags -
tags->nr_reserved_tags,
tags->nr_max_cache,
@@ -171,14 +182,23 @@ err_free_tags:
kfree(tags);
return NULL;
}
+EXPORT_SYMBOL(blk_mq_init_tags);
-void blk_mq_free_tags(struct blk_mq_tags *tags)
+static void __blk_mq_free_tags(struct kref *kref)
{
+ struct blk_mq_tags *tags = container_of(kref, struct blk_mq_tags,
+ ref_count);
+
percpu_ida_destroy(&tags->free_tags);
percpu_ida_destroy(&tags->reserved_tags);
kfree(tags);
}
+void blk_mq_free_tags(struct blk_mq_tags *tags)
+{
+ kref_put(&tags->ref_count, __blk_mq_free_tags);
+}
+
ssize_t blk_mq_tag_sysfs_show(struct blk_mq_tags *tags, char *page)
{
char *orig_page = page;
--
1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists