Skip to contentSkip to conversation

dm-mpath: Work with blk multi-queue drivers

PATCH In review Keith Busch 5 participants 14 messages Sep 23, 2014 – Sep 30, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm-mpath: Work with blk multi-queue drivers

I'm working with multipathing nvme devices using the blk-mq version of the nvme driver, but dm-mpath only works with the older request based drivers. This patch proposes to enable dm-mpath to work with both types of request queues and is succesfull with my dual ported nvme drives.

I think there may still be fix ups to do around submission side error handling, but I think it's at a decent stopping point to solicit feedback before I pursue taking it further. I hear there may be some resistance to add blk-mq support to dm-mpath anyway, but it seems too easy to add support to not at least try. :)

To work, this has dm allocate requests from the request_queue for the device-mapper type rather than allocate one on its own, so the cloned request is properly allocated and initialized for the device's request_queue. The original request's 'special' now points to the dm_rq_target_io rather than at the cloned request because the clone is allocated later by the block layer rather than by dm, and then all the other back referencing to the original seems to work out. The block layer then inserts the cloned reqest using the appropriate function for the request_queue type rather than just calling q->request_fn().

Compile tested on 3.17-rc6; runtime teseted on Matias Bjorling's linux-collab nvmemq_review using 3.16.

<[email protected]>
Cc: Mike Snitzer <[email protected]>

---
 block/blk-core.c              |    7 ++-
 block/blk-mq.c                |    1 +
 drivers/md/dm-mpath.c         |   15 ++++---
 drivers/md/dm-target.c        |    4 +-
 drivers/md/dm.c               |   96 ++++++++++++++++++-----------------------
 include/linux/device-mapper.h |    4 +-
 6 files changed, 62 insertions(+), 65 deletions(-)
block/blk-core.c +5 -2
index bf930f4..4c5952b 100644
@@ -2031,6 +2031,11 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
 	    should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
 		return -EIO;
 
+	if (q->mq_ops) {
+		blk_mq_insert_request(rq, false, true, true);
+		return 0;
+	}
+
 	spin_lock_irqsave(q->queue_lock, flags);
 	if (unlikely(blk_queue_dying(q))) {
 		spin_unlock_irqrestore(q->queue_lock, flags);
@@ -2928,8 +2933,6 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
 	if (!bs)
 		bs = fs_bio_set;
 
-	blk_rq_init(NULL, rq);
-
 	__rq_for_each_bio(bio_src, rq_src) {
 		bio = bio_clone_bioset(bio_src, gfp_mask, bs);
 		if (!bio)
block/blk-mq.c +1 -0
index 383ea0c..eb53d1c 100644
@@ -172,6 +172,7 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
 #if defined(CONFIG_BLK_DEV_INTEGRITY)
 	rq->nr_integrity_segments = 0;
 #endif
+	rq->bio = NULL;
 	rq->special = NULL;
 	/* tag was already set */
 	rq->errors = 0;
drivers/md/dm-mpath.c +9 -6
index 833d7e7..efdc06b 100644
@@ -11,6 +11,7 @@
 #include "dm-path-selector.h"
 #include "dm-uevent.h"
 
+#include <linux/blkdev.h>
 #include <linux/ctype.h>
 #include <linux/init.h>
 #include <linux/mempool.h>
@@ -376,12 +377,12 @@ static int __must_push_back(struct multipath *m)
 /*
  * Map cloned requests
  */
-static int multipath_map(struct dm_target *ti, struct request *clone,
-			 union map_info *map_context)
+static int multipath_map(struct dm_target *ti, struct request *rq,
+		struct request **clone, union map_info *map_context)
 {
 	struct multipath *m = (struct multipath *) ti->private;
 	int r = DM_MAPIO_REQUEUE;
-	size_t nr_bytes = blk_rq_bytes(clone);
+	size_t nr_bytes = blk_rq_bytes(rq);
 	unsigned long flags;
 	struct pgpath *pgpath;
 	struct block_device *bdev;
@@ -410,9 +411,11 @@ static int multipath_map(struct dm_target *ti, struct request *clone,
 		goto out_unlock;
 
 	bdev = pgpath->path.dev->bdev;
-	clone->q = bdev_get_queue(bdev);
-	clone->rq_disk = bdev->bd_disk;
-	clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
+	*clone = blk_get_request(bdev_get_queue(bdev), rq_data_dir(rq),
+							GFP_KERNEL);
+	if (!(*clone))
+		goto out_unlock;
+	(*clone)->cmd_flags |= REQ_FAILFAST_TRANSPORT;
 	mpio = map_context->ptr;
 	mpio->pgpath = pgpath;
 	mpio->nr_bytes = nr_bytes;
drivers/md/dm-target.c +2 -2
index 242e3ce..2bcbf6e 100644
@@ -131,8 +131,8 @@ static int io_err_map(struct dm_target *tt, struct bio *bio)
 	return -EIO;
 }
 
-static int io_err_map_rq(struct dm_target *ti, struct request *clone,
-			 union map_info *map_context)
+static int io_err_map_rq(struct dm_target *ti, struct request *rq,
+			struct request **clone,  union map_info *map_context)
 {
 	return -EIO;
 }
drivers/md/dm.c +43 -53

223 lines not on this page · raw message

include/linux/device-mapper.h +2 -2
index e1707de..d9ac281 100644
@@ -46,8 +46,8 @@ typedef void (*dm_dtr_fn) (struct dm_target *ti);
  * = 2: The target wants to push back the io
  */
 typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio);
-typedef int (*dm_map_request_fn) (struct dm_target *ti, struct request *clone,
-				  union map_info *map_context);
+typedef int (*dm_map_request_fn) (struct dm_target *ti, struct request *rq,
+			struct request **clone, union map_info *map_context);
 
 /*
  * Returns:
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 21 lines · Keith Busch

I'm working with multipathing nvme devices using the blk-mq version of the nvme driver, but dm-mpath only works with the older request based drivers. This patch proposes to enable dm-mpath to work with both types of request queues and is succesfull with my dual ported nvme drives.

I think there may still be fix ups to do around submission side error handling, but I think it's at a decent stopping point to solicit feedback before I pursue taking it further. I hear there may be some resistance to add blk-mq support to dm-mpath anyway, but it seems too easy to add support to not at least try. :)

To work, this has dm allocate requests from the request_queue for the device-mapper type rather than allocate one on its own, so the cloned request is properly allocated and initialized for the device's request_queue. The original request's 'special' now points to the dm_rq_target_io rather than at the cloned request because the clone is allocated later by the block layer rather than by dm, and then all the other back referencing to the original seems to work out. The block layer then inserts the cloned reqest using the appropriate function for the request_queue type rather than just calling q->request_fn().

Quoted 3 lines

Compile tested on 3.17-rc6; runtime teseted on Matias Bjorling's linux-collab nvmemq_review using 3.16.

The resistance wasn't so much for enabling multipath for block-mq, it was _how_ multipath should be modelled on top of block-mq.

With a simple enabling we actually have two layers of I/O scheduling; once in multipathing to select between the individual queues, and once in block-mq to select the correct hardware context. So we end up with a four-tiered hierarchy:

m priority groups - n pg_paths/request_queues -> o cpus -> p hctx

Giving us a full m * n * p (hctx are tagged per cpu) variety where the I/Os might be send.

Performance wise it might be beneficial to tag a hardware context to a given path, effectively removing I/O scheduling from block-mq. But this would require some substantial update to the current blk-mq design (blocked paths, dynamic reconfiguration).

However, this looks like a good starting point. I'll give it a go and see how far I'll be getting with it.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
#2 lore raw
Quoted 2 lines · Hannes Reinecke

The resistance wasn't so much for enabling multipath for block-mq, it was _how_ multipath should be modelled on top of block-mq.

As well as finding someone to do the work.. We now found Keith, so thanks on that already!

Quoted 5 lines

With a simple enabling we actually have two layers of I/O scheduling; once in multipathing to select between the individual queues, and once in block-mq to select the correct hardware context. So we end up with a four-tiered hierarchy:

Assuming we have multiple queues in the low level driver..

Quoted 2 lines

However, this looks like a good starting point. I'll give it a go and see how far I'll be getting with it.

Yes, the first priority should be to make dm-mpath to work on a blk-mq device at all, which is very important for scsi-mq adoption, which will include a lot of single queue devices. After that come various levels of efficiency optimizations. The first priority should be to get rid of the horrible bio clones by hooking into the right place in the I/O completion, second one would be to revamp the I/O submission path, for example by hooking into ->map_queue. With fairly limited work that does sound doable as long as all paths use the same HBA/driver which is not an unusual limitation in other multipathing implementations.

#3 lore raw
In reply to Keith Busch

block/blk-core.c

Quoted 3 lines

index bf930f4..4c5952b 100644

block/blk-core.c +0 -0

Can you split the block core changes into separate patches in a series?

block/blk-core.c int blk_insert_cloned_request(struct request_queue *q, struct request *rq) · line 2037

Quoted 8 lines
block/blk-core.c +4 -0
@@ -2031,6 +2031,11 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
 	    should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
 		return -EIO;
 
+	if (q->mq_ops) {
+		blk_mq_insert_request(rq, false, true, true);
+		return 0;
+	}

In the case of a torn down queue this one will complete the request, while the !mq case will return an error. Does the upper level code handle that difference fine?

block/blk-core.c int blk_rq_prep_clone(struct request *rq, struct request *rq_src, · line 2932

Quoted 9 lines
block/blk-core.c +0 -2
 	spin_lock_irqsave(q->queue_lock, flags);
 	if (unlikely(blk_queue_dying(q))) {
 		spin_unlock_irqrestore(q->queue_lock, flags);
@@ -2928,8 +2933,6 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
 	if (!bs)
 		bs = fs_bio_set;
 
-	blk_rq_init(NULL, rq);
-

Moving this into the caller in a preparatory patch would be useful, too.

block/blk-mq.c static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx, · line 175

Quoted 9 lines
block/blk-mq.c +1 -0
index 383ea0c..eb53d1c 100644
@@ -172,6 +172,7 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
 #if defined(CONFIG_BLK_DEV_INTEGRITY)
 	rq->nr_integrity_segments = 0;
 #endif
+	rq->bio = NULL;

Jens has been trying to micro-optimize this area and avoid additional overhead for the fast path. It would be better to do this in dm-mpath.

block/blk-mq.c static int multipath_map(struct dm_target *ti, struct request *clone, · line 415

Quoted 12 lines
block/blk-mq.c +2 -3
 	unsigned long flags;
 	struct pgpath *pgpath;
 	struct block_device *bdev;
@@ -410,9 +411,11 @@ static int multipath_map(struct dm_target *ti, struct request *clone,
 		goto out_unlock;
 
 	bdev = pgpath->path.dev->bdev;
-	clone->q = bdev_get_queue(bdev);
-	clone->rq_disk = bdev->bd_disk;
-	clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
+	*clone = blk_get_request(bdev_get_queue(bdev), rq_data_dir(rq),
+							GFP_KERNEL);

I suspect this should be GFP_NOWAIT so that we can push the request back up the stack if none are available.

block/blk-mq.c static int multipath_map(struct dm_target *ti, struct request *clone, · line 417

Quoted 2 lines
block/blk-mq.c +2 -0
+	if (!(*clone))
+		goto out_unlock;

No need for the inner braces.

block/blk-mq.c static int multipath_map(struct dm_target *ti, struct request *clone,

Quoted 13 lines
block/blk-mq.c +2 -5
  * This may be used when the target's map_rq() function fails.
  */
-void dm_kill_unmapped_request(struct request *clone, int error)
+void dm_kill_unmapped_request(struct request *rq, int error)
 {
-	struct dm_rq_target_io *tio = clone->end_io_data;
-	struct request *rq = tio->orig;
-
 	rq->cmd_flags |= REQ_FAILED;
-	dm_complete_request(clone, error);
+	dm_complete_request(rq, error);
 }
 EXPORT_SYMBOL_GPL(dm_kill_unmapped_request);

At this point it might be worth to just kill the
dm_kill_unmapped_request wrapper?

#4 lore raw
Quoted 6 lines · Christoph Hellwig

block/blk-core.c

Quoted 3 lines

index bf930f4..4c5952b 100644

block/blk-core.c +0 -0

Can you split the block core changes into separate patches in a series?

Sounds good, will do. I'll have to follow your later suggestion to move the blk_rq_init() to the caller early in the series so no part of the patch set breaks anything.

Quoted 4 lines
Quoted 4 lines
block/blk-core.c +0 -0
@@ -2031,6 +2031,11 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
 	    should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
 		return -EIO;
 
Quoted 8 lines

block/blk-core.c int blk_insert_cloned_request(struct request_queue *q, struct request *rq) · line 2037

Quoted 4 lines
block/blk-core.c +4 -0
+	if (q->mq_ops) {
+		blk_mq_insert_request(rq, false, true, true);
+		return 0;
+	}

In the case of a torn down queue this one will complete the request, while the !mq case will return an error. Does the upper level code handle that difference fine?

I wasn't entirely sure about all the error handling. After re-examining, I think there is a problem, but maybe a little different than what you're suggesting: if the queue is torn down, blk_get_request() for the clone returns NULL and the original request will be orphaned, so that's no good. Need to somehow distinguish between a torn down queue vs. no request available and requeue/fail as appropriate.

Both mq and !mq appear to work correctly if the queue happens to get taken down after the request is obtained but before it is submitted, but I'll synthesize this error to be sure.

Quoted 6 lines
Quoted 6 lines
block/blk-core.c +0 -0
 	unsigned long flags;
 	struct pgpath *pgpath;
 	struct block_device *bdev;
@@ -410,9 +411,11 @@ static int multipath_map(struct dm_target *ti, struct request *clone,
 		goto out_unlock;
 
Quoted 9 lines

block/blk-core.c static int multipath_map(struct dm_target *ti, struct request *clone, · line 415

Quoted 6 lines
block/blk-core.c +2 -3
 	bdev = pgpath->path.dev->bdev;
-	clone->q = bdev_get_queue(bdev);
-	clone->rq_disk = bdev->bd_disk;
-	clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
+	*clone = blk_get_request(bdev_get_queue(bdev), rq_data_dir(rq),
+							GFP_KERNEL);

I suspect this should be GFP_NOWAIT so that we can push the request back up the stack if none are available.

Aha, nice catch. I'd have hit the BUG_ON() in dm_request_fn() the way I wrote this since irq's could have been re-enabled if a request wasn't immediately available.

Thanks for the feedback!

#5 lore raw
Quoted 2 lines · Keith Busch

I hear there may be some resistance to add blk-mq support to dm-mpath anyway, but it seems too easy to add support to not at least try. :)

Why? Not sure who you heard that from but I'm not opposed to it if it is done properly.

Quoted 5 lines · Keith Busch
Quoted 4 lines · Christoph Hellwig
Quoted 3 lines

index bf930f4..4c5952b 100644

block/blk-core.c +0 -0

...

Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
	unsigned long flags;
	struct pgpath *pgpath;
	struct block_device *bdev;
block/blk-core.c +0 -0
@@ -410,9 +411,11 @@ static int multipath_map(struct dm_target *ti, struct request *clone,
 		goto out_unlock;
 
Quoted 9 lines

block/blk-core.c static int multipath_map(struct dm_target *ti, struct request *clone, · line 415

Quoted 6 lines
block/blk-core.c +2 -3
 	bdev = pgpath->path.dev->bdev;
-	clone->q = bdev_get_queue(bdev);
-	clone->rq_disk = bdev->bd_disk;
-	clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
+	*clone = blk_get_request(bdev_get_queue(bdev), rq_data_dir(rq),
+							GFP_KERNEL);

I suspect this should be GFP_NOWAIT so that we can push the request back up the stack if none are available.

Quoted 5 lines

Aha, nice catch. I'd have hit the BUG_ON() in dm_request_fn() the way I wrote this since irq's could have been re-enabled if a request wasn't immediately available.

Thanks for the feedback!

We have never allowed new memory allocation in a DM target's .map or .map_rq method. The only allocations that are allowed are those backed by a mempool (see md->io_pool usage in alloc_rq_tio, before the clone's struct request was embedded in struct dm_rq_target_io). This was done to allow request-based DM devices to be stacked on each other. Even though nothing ever made use of stacking request-based DM devices; doing so is still a DM design possibility. Could be we can simply say "kill request-based DM device stacking, it isn't needed".. if we went that far then the per-rq-based-device mempool becomes much less important.

But building on this concern, historically each request-based DM device has maintained a reserve for cloning a request (so that forward progress can be ensured even if system memory is unavailable). So AFAICT Christoph's suggestion to switch to GFP_NOWAIT from GFP_KERNEL still doesn't do enough to preserve the higher standards rq-based DM had established for guaranteed ability to clone a request.

Taking a step back, I'm really _not_ liking the duality of the DM core with regard to the cloning of a request. Where a request-based DM target (e.g. mpath) is tasked with calling blk_get_request() but then DM core is left to manage the life-cycle of that clone that the target allocated. If anything a new dm_get_request() wrapper should be added to DM core, subtle difference but then at least one can easily see balanced request management within the DM core?

In general I'd really like to see a bit more care taken to improve the block interface that DM is using for request-based DM. What I mean is, Hannes proposed a series that eliminated request-based DM's cloning of requests (and associated bios), see thread:
http://www.redhat.com/archives/dm-devel/2014-June/msg00023.html

(that series was just a "test balloon" as Hannes put it, but it offered some serious "cleanup" by nuking a lot of fiddly block layer code in DM core)

I never did take the time to properly review Hannes' proposal but now that you're floating this blk-mq support for DM core (and DM mpath) I'm clearly going to have to take this all on in a much more focused way.

Christoph/Hannes/Junichi/Keith/others, can you see a way forward that offers a lighter request-based DM that makes required callouts to (new?) block interfaces that helps us abstract the old request and blk-mq request allocation, etc?

Mike

#6 lore raw
Quoted 9 lines · Mike Snitzer

I never did take the time to properly review Hannes' proposal but now that you're floating this blk-mq support for DM core (and DM mpath) I'm clearly going to have to take this all on in a much more focused way.

Christoph/Hannes/Junichi/Keith/others, can you see a way forward that offers a lighter request-based DM that makes required callouts to (new?) block interfaces that helps us abstract the old request and blk-mq request allocation, etc?

(sorry about replying to myself...)

SO revisiting that thread from above, these posts stand out:
http://www.redhat.com/archives/dm-devel/2014-June/msg00026.html
http://www.redhat.com/archives/dm-devel/2014-June/msg00028.html

I'd love to see us get rid of request-based DM's bio cloning for each cloned request (we never did get an answer from the NEC guys to know _why_ that was done).

http://www.redhat.com/archives/dm-devel/2014-June/msg00029.html

But I now see what Christoph was saying about needing the call blk_get_request() against the low level path... and that completely avoiding request cloning like Hannes did is a non-starter for blk-mq.

So if we could:
1) rip out the rq-based DM's cloning of all bios in a request
2) rebase Keith's approach ontop of 1) then we could go from there
- but happy to put more thought in upfront to avoid busy work; and I'd encourage everyone else to do the same...

#7 lore raw
Quoted 15 lines · Mike Snitzer
Quoted 9 lines · Mike Snitzer

I never did take the time to properly review Hannes' proposal but now that you're floating this blk-mq support for DM core (and DM mpath) I'm clearly going to have to take this all on in a much more focused way.

Christoph/Hannes/Junichi/Keith/others, can you see a way forward that offers a lighter request-based DM that makes required callouts to (new?) block interfaces that helps us abstract the old request and blk-mq request allocation, etc?

(sorry about replying to myself...)

Quoted 7 lines

SO revisiting that thread from above, these posts stand out:
http://www.redhat.com/archives/dm-devel/2014-June/msg00026.html
http://www.redhat.com/archives/dm-devel/2014-June/msg00028.html

I'd love to see us get rid of request-based DM's bio cloning for each cloned request (we never did get an answer from the NEC guys to know _why_ that was done).

Actually, Junichi did respond with why:
http://www.redhat.com/archives/dm-devel/2014-June/msg00033.html

So this needs more review and thought.

#8 lore raw
Quoted 18 lines · Mike Snitzer
Quoted 17 lines · Mike Snitzer
Quoted 8 lines · Mike Snitzer

I never did take the time to properly review Hannes' proposal but now that you're floating this blk-mq support for DM core (and DM mpath) I'm clearly going to have to take this all on in a much more focused way.

Christoph/Hannes/Junichi/Keith/others, can you see a way forward that offers a lighter request-based DM that makes required callouts to (new?) block interfaces that helps us abstract the old request and blk-mq request allocation, etc?

(sorry about replying to myself...)

SO revisiting that thread from above, these posts stand out:
http://www.redhat.com/archives/dm-devel/2014-June/msg00026.html
http://www.redhat.com/archives/dm-devel/2014-June/msg00028.html

Quoted 8 lines
Quoted 3 lines

I'd love to see us get rid of request-based DM's bio cloning for each cloned request (we never did get an answer from the NEC guys to know _why_ that was done).

Actually, Junichi did respond with why:
http://www.redhat.com/archives/dm-devel/2014-June/msg00033.html

So this needs more review and thought.

Thank you for all the background information. This definitely gives me a lot more to think about.

For my part, the goal was to change as little as possible to get basic blk-mq support working safely without regressing, and performance is not even on my radar yet. I purposefully did not try to understand the existing design well enough to propose re-arching. If we can address the 'request' life cycle management duality issue, would this be acceptable as a stopgap for blk-mq support?

#9 lore raw
Quoted 9 lines · Keith Busch

Thank you for all the background information. This definitely gives me a lot more to think about.

For my part, the goal was to change as little as possible to get basic blk-mq support working safely without regressing, and performance is not even on my radar yet. I purposefully did not try to understand the existing design well enough to propose re-arching. If we can address the 'request' life cycle management duality issue, would this be acceptable as a stopgap for blk-mq support?

I fully agree with going for the stop gap for now. I tried going the long way when I gave it a try and got stuck.

If people believe the get_request in the map path is harmful for the old code we might have to make your change conditional just for blk-mq. For blk-mq request allocation never dips into the general purpose memory pool, so it should be fine for that case.

#10 lore raw
In reply to Keith Busch
Quoted 31 lines · Keith Busch
Quoted 18 lines · Mike Snitzer
Quoted 17 lines · Mike Snitzer
Quoted 8 lines · Mike Snitzer

I never did take the time to properly review Hannes' proposal but now that you're floating this blk-mq support for DM core (and DM mpath) I'm clearly going to have to take this all on in a much more focused way.

Christoph/Hannes/Junichi/Keith/others, can you see a way forward that offers a lighter request-based DM that makes required callouts to (new?) block interfaces that helps us abstract the old request and blk-mq request allocation, etc?

(sorry about replying to myself...)

SO revisiting that thread from above, these posts stand out:
http://www.redhat.com/archives/dm-devel/2014-June/msg00026.html
http://www.redhat.com/archives/dm-devel/2014-June/msg00028.html

Quoted 8 lines
Quoted 3 lines

I'd love to see us get rid of request-based DM's bio cloning for each cloned request (we never did get an answer from the NEC guys to know _why_ that was done).

Actually, Junichi did respond with why:
http://www.redhat.com/archives/dm-devel/2014-June/msg00033.html

So this needs more review and thought.

Thank you for all the background information. This definitely gives me a lot more to think about.

Quoted 6 lines

For my part, the goal was to change as little as possible to get basic blk-mq support working safely without regressing, and performance is not even on my radar yet. I purposefully did not try to understand the existing design well enough to propose re-arching. If we can address the 'request' life cycle management duality issue, would this be acceptable as a stopgap for blk-mq support?

We can ignore my desire to cleanup existing request-based DM's bio cloning for now. And yes, resolving the duality issue would need to happen. But your proposed change still has the issue of no longer using a dedicated mempool per rq-based DM device to allocate requests from. If we were to do that I'm pretty sure this new dm.c:dm_get_request() wrapper would need to call blk_get_request() with GFP_ATOMIC.

Either GFP_ATOMIC or I think we _could_ relax to GFP_NOWAIT if and only if we were willing to explicitly disallow stacking request-based DM devices (which nothing uses at this point). So I'd like to get Junichi and Alasdair's feedback on the implications. Junichi and/or Alasdair?

Mike

#11 lore raw
Quoted 16 lines · Mike Snitzer
Quoted 6 lines · Keith Busch

For my part, the goal was to change as little as possible to get basic blk-mq support working safely without regressing, and performance is not even on my radar yet. I purposefully did not try to understand the existing design well enough to propose re-arching. If we can address the 'request' life cycle management duality issue, would this be acceptable as a stopgap for blk-mq support?

We can ignore my desire to cleanup existing request-based DM's bio cloning for now. And yes, resolving the duality issue would need to happen. But your proposed change still has the issue of no longer using a dedicated mempool per rq-based DM device to allocate requests from. If we were to do that I'm pretty sure this new dm.c:dm_get_request() wrapper would need to call blk_get_request() with GFP_ATOMIC.

Quoted 4 lines

Either GFP_ATOMIC or I think we _could_ relax to GFP_NOWAIT if and only if we were willing to explicitly disallow stacking request-based DM devices (which nothing uses at this point). So I'd like to get Junichi and Alasdair's feedback on the implications. Junichi and/or Alasdair?

The problem with "stacking request-based DM devices" is caused by shared mempool (i.e. the pool gets emptied by upper layer and we can't make forward progress). So it should be ok if request has per-device mempool (I think it does.)

However, using blk_get_request() in map function will require more changes in the code as blk_get_request() assumes interrupt-enabled context.

Signature · 1 line
Jun'ichi Nomura, NEC Corporation
#12 lore raw
Quoted 22 lines · Junichi Nomura
Quoted 16 lines · Mike Snitzer
Quoted 6 lines · Keith Busch

For my part, the goal was to change as little as possible to get basic blk-mq support working safely without regressing, and performance is not even on my radar yet. I purposefully did not try to understand the existing design well enough to propose re-arching. If we can address the 'request' life cycle management duality issue, would this be acceptable as a stopgap for blk-mq support?

We can ignore my desire to cleanup existing request-based DM's bio cloning for now. And yes, resolving the duality issue would need to happen. But your proposed change still has the issue of no longer using a dedicated mempool per rq-based DM device to allocate requests from. If we were to do that I'm pretty sure this new dm.c:dm_get_request() wrapper would need to call blk_get_request() with GFP_ATOMIC.

Quoted 4 lines

Either GFP_ATOMIC or I think we _could_ relax to GFP_NOWAIT if and only if we were willing to explicitly disallow stacking request-based DM devices (which nothing uses at this point). So I'd like to get Junichi and Alasdair's feedback on the implications. Junichi and/or Alasdair?

Quoted 5 lines

The problem with "stacking request-based DM devices" is caused by shared mempool (i.e. the pool gets emptied by upper layer and we can't make forward progress). So it should be ok if request has per-device mempool (I think it does.)

Current request-based DM provides a per-device mempool that all cloned requests are allocated from. But Keith's approach to have map_rq call blk_get_request will no longer make use of that DM provided mempool.

But are you referring to the request_queue's use of a mempool that is initialized with blk_init_rl() in blk_init_allocated_queue()?

Quoted 3 lines

However, using blk_get_request() in map function will require more changes in the code as blk_get_request() assumes interrupt-enabled context.

Ah yes, blk_get_request will unconditionally disable interrupts using spin_lock_irq. Not yet looked at the implications though.

#13 lore raw
Quoted 31 lines · Mike Snitzer
Quoted 22 lines · Junichi Nomura
Quoted 16 lines · Mike Snitzer
Quoted 6 lines · Keith Busch

For my part, the goal was to change as little as possible to get basic blk-mq support working safely without regressing, and performance is not even on my radar yet. I purposefully did not try to understand the existing design well enough to propose re-arching. If we can address the 'request' life cycle management duality issue, would this be acceptable as a stopgap for blk-mq support?

We can ignore my desire to cleanup existing request-based DM's bio cloning for now. And yes, resolving the duality issue would need to happen. But your proposed change still has the issue of no longer using a dedicated mempool per rq-based DM device to allocate requests from. If we were to do that I'm pretty sure this new dm.c:dm_get_request() wrapper would need to call blk_get_request() with GFP_ATOMIC.

Quoted 4 lines

Either GFP_ATOMIC or I think we _could_ relax to GFP_NOWAIT if and only if we were willing to explicitly disallow stacking request-based DM devices (which nothing uses at this point). So I'd like to get Junichi and Alasdair's feedback on the implications. Junichi and/or Alasdair?

Quoted 5 lines

The problem with "stacking request-based DM devices" is caused by shared mempool (i.e. the pool gets emptied by upper layer and we can't make forward progress). So it should be ok if request has per-device mempool (I think it does.)

Quoted 6 lines

Current request-based DM provides a per-device mempool that all cloned requests are allocated from. But Keith's approach to have map_rq call blk_get_request will no longer make use of that DM provided mempool.

But are you referring to the request_queue's use of a mempool that is initialized with blk_init_rl() in blk_init_allocated_queue()?

Yes.

Quoted 6 lines
Quoted 3 lines

However, using blk_get_request() in map function will require more changes in the code as blk_get_request() assumes interrupt-enabled context.

Ah yes, blk_get_request will unconditionally disable interrupts using spin_lock_irq. Not yet looked at the implications though.

Actually, early implementation of request-based DM had tried to use blk_get_request() by converting them to irqsave/irqrestore variants. However, since (old, non-mq version of) blk_get_request is designed to be called in process context, such a change could have confused the interface.
As a result, current DM code implements pre-allocation of memory and mapping separately.
I think blk-mq already does pre-allocation of requests internally and mq version of blk_get_request is actually a mapping function in this case.

So, I suspect DM functions for pre-allocation (clone_rq) and mapping (map_request) are good place for containing the duality inside.

Signature · 1 line
Jun'ichi Nomura, NEC Corporation