Re: [PATCH 3/4] blk-mq: move request structures into struct blk_mq_tags

2014-04-11 Thread Christoph Hellwig
On Thu, Apr 10, 2014 at 08:42:27PM -0600, Jens Axboe wrote:
 Great. Will you send out an updated patchset?

I was waiting for you to apply the previous series, but I'll just resend my
whole set of outstanding patches, it'll need a bit of rebasing against
your updated tree anyway.

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] blk-mq: move request structures into struct blk_mq_tags

2014-04-11 Thread Jens Axboe

On 04/11/2014 01:33 AM, Christoph Hellwig wrote:

On Thu, Apr 10, 2014 at 08:42:27PM -0600, Jens Axboe wrote:

Great. Will you send out an updated patchset?


I was waiting for you to apply the previous series, but I'll just resend my
whole set of outstanding patches, it'll need a bit of rebasing against
your updated tree anyway.


I'll take a look at the previous series and apply/comment.

--
Jens Axboe

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] blk-mq: move request structures into struct blk_mq_tags

2014-04-10 Thread Christoph Hellwig
On Wed, Apr 09, 2014 at 10:23:32AM -0600, Jens Axboe wrote:
 This should go into block/blk-mq-tag.h.

Ok.

 We might as well leave this, the mtip32xx conversion ends up using it. So 
 if we pull it now, it'll just be reintroduced shortly.

It's back in the latest revision of the patch, just taking a
struct blk_mq_tag pointer now so that it can be used by SCSI as well.

I've also changed an opencode variant of it to use the helper.

Pointer: 
http://git.infradead.org/users/hch/scsi.git/commitdiff/b0f1ed35bbeb6d0177fc0cc0bf5c880c3c5d1817

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] blk-mq: move request structures into struct blk_mq_tags

2014-04-10 Thread Jens Axboe

On 2014-04-10 04:01, Christoph Hellwig wrote:

On Wed, Apr 09, 2014 at 10:23:32AM -0600, Jens Axboe wrote:

This should go into block/blk-mq-tag.h.


Ok.


We might as well leave this, the mtip32xx conversion ends up using it. So
if we pull it now, it'll just be reintroduced shortly.


It's back in the latest revision of the patch, just taking a
struct blk_mq_tag pointer now so that it can be used by SCSI as well.

I've also changed an opencode variant of it to use the helper.


Great. Will you send out an updated patchset?

--
Jens Axboe

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] blk-mq: move request structures into struct blk_mq_tags

2014-04-09 Thread Jens Axboe

On 03/31/2014 08:46 AM, Christoph Hellwig wrote:

diff --git a/block/blk-mq.h b/block/blk-mq.h
index 238379a..eca3a47 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -1,6 +1,24 @@
  #ifndef INT_BLK_MQ_H
  #define INT_BLK_MQ_H

+#include linux/percpu_ida.h
+
+/*
+ * Tag address space map.
+ */
+struct blk_mq_tags {
+   unsigned int nr_tags;
+   unsigned int nr_reserved_tags;
+   unsigned int nr_batch_move;
+   unsigned int nr_max_cache;
+
+   struct percpu_ida free_tags;
+   struct percpu_ida reserved_tags;
+
+   struct request **rqs;
+   struct list_head page_list;
+};
+


This should go into block/blk-mq-tag.h.



-static inline struct request *blk_mq_tag_to_rq(struct blk_mq_hw_ctx *hctx,
-  unsigned int tag)
-{
-   return hctx-rqs[tag];
-}


We might as well leave this, the mtip32xx conversion ends up using it. 
So if we pull it now, it'll just be reintroduced shortly.


--
Jens Axboe

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] blk-mq: move request structures into struct blk_mq_tags

2014-03-31 Thread Christoph Hellwig
This is in preparation for allowing to share the tags, and thus request
allocation between multiple queues.

Also remove blk_mq_tag_to_rq, as it was unused and thus untestable.  If we
need it back it can easil be re-added as a non-inline function.

Note that we also now straight out fail queue initialization if we can't
allocate tags - keeping track of a reduced queue_depth over a more complex
call chain isn't easil possible and this shouldn't happen on an of todays
systems.

Signed-off-by: Christoph Hellwig h...@lst.de
---
 block/blk-mq-tag.c |   13 
 block/blk-mq.c |   84 +---
 block/blk-mq.h |   18 +++
 include/linux/blk-mq.h |8 -
 4 files changed, 61 insertions(+), 62 deletions(-)

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 83ae96c..108f82b 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -7,19 +7,6 @@
 #include blk-mq.h
 #include blk-mq-tag.h
 
-/*
- * Per tagged queue (tag address space) map
- */
-struct blk_mq_tags {
-   unsigned int nr_tags;
-   unsigned int nr_reserved_tags;
-   unsigned int nr_batch_move;
-   unsigned int nr_max_cache;
-
-   struct percpu_ida free_tags;
-   struct percpu_ida reserved_tags;
-};
-
 void blk_mq_wait_for_tags(struct blk_mq_tags *tags)
 {
int tag = blk_mq_get_tag(tags, __GFP_WAIT, false);
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ec0c276..f1b5d52 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -81,7 +81,7 @@ static struct request *__blk_mq_alloc_request(struct 
blk_mq_hw_ctx *hctx,
 
tag = blk_mq_get_tag(hctx-tags, gfp, reserved);
if (tag != BLK_MQ_TAG_FAIL) {
-   rq = hctx-rqs[tag];
+   rq = hctx-tags-rqs[tag];
blk_rq_init(hctx-queue, rq);
rq-tag = tag;
 
@@ -406,7 +406,9 @@ static void blk_mq_timeout_check(void *__data, unsigned 
long *free_tags)
if (tag = hctx-queue_depth)
break;
 
-   rq = hctx-rqs[tag++];
+   rq = hctx-tags-rqs[tag++];
+   if (rq-q != hctx-queue)
+   continue;
 
if (!test_bit(REQ_ATOM_STARTED, rq-atomic_flags))
continue;
@@ -993,7 +995,7 @@ static int blk_mq_init_hw_commands(struct blk_mq_hw_ctx 
*hctx,
int ret = 0;
 
for (i = 0; i  hctx-queue_depth; i++) {
-   struct request *rq = hctx-rqs[i];
+   struct request *rq = hctx-tags-rqs[i];
 
ret = init(data, hctx, rq, i);
if (ret)
@@ -1030,7 +1032,7 @@ static void blk_mq_free_hw_commands(struct blk_mq_hw_ctx 
*hctx,
unsigned int i;
 
for (i = 0; i  hctx-queue_depth; i++) {
-   struct request *rq = hctx-rqs[i];
+   struct request *rq = hctx-tags-rqs[i];
 
free(data, hctx, rq, i);
}
@@ -1049,20 +1051,19 @@ void blk_mq_free_commands(struct request_queue *q,
 }
 EXPORT_SYMBOL(blk_mq_free_commands);
 
-static void blk_mq_free_rq_map(struct blk_mq_hw_ctx *hctx)
+static void blk_mq_free_rq_map(struct blk_mq_tags *tags)
 {
struct page *page;
 
-   while (!list_empty(hctx-page_list)) {
-   page = list_first_entry(hctx-page_list, struct page, lru);
+   while (!list_empty(tags-page_list)) {
+   page = list_first_entry(tags-page_list, struct page, lru);
list_del_init(page-lru);
__free_pages(page, page-private);
}
 
-   kfree(hctx-rqs);
+   kfree(tags-rqs);
 
-   if (hctx-tags)
-   blk_mq_free_tags(hctx-tags);
+   blk_mq_free_tags(tags);
 }
 
 static size_t order_to_size(unsigned int order)
@@ -1075,28 +1076,35 @@ static size_t order_to_size(unsigned int order)
return ret;
 }
 
-static int blk_mq_init_rq_map(struct blk_mq_hw_ctx *hctx,
- unsigned int reserved_tags, int node)
+static struct blk_mq_tags *blk_mq_init_rq_map(unsigned int total_tags,
+   unsigned int reserved_tags, unsigned int cmd_size, int node)
 {
+   struct blk_mq_tags *tags;
unsigned int i, j, entries_per_page, max_order = 4;
size_t rq_size, left;
 
-   INIT_LIST_HEAD(hctx-page_list);
+   tags = blk_mq_init_tags(total_tags, reserved_tags, node);
+   if (!tags)
+   return NULL;
+
+   INIT_LIST_HEAD(tags-page_list);
 
-   hctx-rqs = kmalloc_node(hctx-queue_depth * sizeof(struct request *),
+   tags-rqs = kmalloc_node(total_tags * sizeof(struct request *),
GFP_KERNEL, node);
-   if (!hctx-rqs)
-   return -ENOMEM;
+   if (!tags-rqs) {
+   blk_mq_free_tags(tags);
+   return NULL;
+   }
 
/*
 * rq_size is the size of the request plus driver payload, rounded
 * to the cacheline size
 */
-   rq_size = round_up(sizeof(struct