public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Initialize mempool and elevator only for request-based dm devices
@ 2009-08-08  4:56 Nikanth Karthikesan
  2009-08-08 16:21 ` Mike Snitzer
  0 siblings, 1 reply; 11+ messages in thread
From: Nikanth Karthikesan @ 2009-08-08  4:56 UTC (permalink / raw)
  To: Jens Axboe, Alasdair G Kergon
  Cc: Kiyoshi Ueda, Hannes Reinecke, dm-devel, linux-kernel

Intialize the request_queue and elevator only when the device is marked as
a request-based device. This avoids unnecessary creation of mempool for
requests. Also we wrongly initialize the elevator even for bio-based devices.
As the /sys/block/dm-*/queue/scheduler is exported for device-mapper devices,
it is possible to confuse with scheduler options for bio-based devices where
scheduler is not at all used.

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>

---

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 8a311ea..b01dfbe 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1749,22 +1749,21 @@ static struct mapped_device *alloc_dev(int minor)
 	INIT_LIST_HEAD(&md->uevent_list);
 	spin_lock_init(&md->uevent_lock);
 
-	md->queue = blk_init_queue(dm_request_fn, NULL);
+	md->queue = blk_alloc_queue(GFP_KERNEL);
 	if (!md->queue)
 		goto bad_queue;
 
 	/*
 	 * Request-based dm devices cannot be stacked on top of bio-based dm
-	 * devices.  The type of this dm device has not been decided yet,
-	 * although we initialized the queue using blk_init_queue().
+	 * devices. The type of this dm device has not been decided yet.
 	 * The type is decided at the first table loading time.
 	 * To prevent problematic device stacking, clear the queue flag
 	 * for request stacking support until then.
 	 *
 	 * This queue is new, so no concurrency on the queue_flags.
 	 */
+	md->queue->queue_flags = QUEUE_FLAG_DEFAULT;
 	queue_flag_clear_unlocked(QUEUE_FLAG_STACKABLE, md->queue);
-	md->saved_make_request_fn = md->queue->make_request_fn;
 	md->queue->queuedata = md;
 	md->queue->backing_dev_info.congested_fn = dm_any_congested;
 	md->queue->backing_dev_info.congested_data = md;
@@ -1772,9 +1771,6 @@ static struct mapped_device *alloc_dev(int minor)
 	blk_queue_bounce_limit(md->queue, BLK_BOUNCE_ANY);
 	md->queue->unplug_fn = dm_unplug_all;
 	blk_queue_merge_bvec(md->queue, dm_merge_bvec);
-	blk_queue_softirq_done(md->queue, dm_softirq_done);
-	blk_queue_prep_rq(md->queue, dm_prep_fn);
-	blk_queue_lld_busy(md->queue, dm_lld_busy);
 
 	md->disk = alloc_disk(1);
 	if (!md->disk)
@@ -2203,7 +2199,25 @@ int dm_swap_table(struct mapped_device *md, struct dm_table *table)
 		goto out;
 	}
 
-	__unbind(md);
+	if (md->map)
+		__unbind(md);
+	else {
+	/* new device is being marked as either request-based or bio-based */
+		if (dm_table_request_based(table)) {
+			/* Initialize queue for request-based dm */
+			r = blk_init_allocated_queue(md->queue, dm_request_fn,
+								 NULL);
+			if (r)
+				goto out;
+			md->saved_make_request_fn = md->queue->make_request_fn;
+			blk_queue_make_request(md->queue, dm_request);
+			blk_queue_softirq_done(md->queue, dm_softirq_done);
+			blk_queue_prep_rq(md->queue, dm_prep_fn);
+			blk_queue_lld_busy(md->queue, dm_lld_busy);
+
+		}
+	}
+
 	r = __bind(md, table, &limits);
 
 out:


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-05-11 16:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-08  4:56 [PATCH 2/2] Initialize mempool and elevator only for request-based dm devices Nikanth Karthikesan
2009-08-08 16:21 ` Mike Snitzer
2009-08-10 10:21   ` Nikanth Karthikesan
2009-08-10 10:48     ` [PATCH-v2 " Nikanth Karthikesan
2009-08-11  8:06       ` Kiyoshi Ueda
2009-08-11  9:05         ` Nikanth Karthikesan
2009-08-11  9:32           ` [PATCH-v3 " Nikanth Karthikesan
2009-08-12  2:15           ` [PATCH-v2 " Kiyoshi Ueda
2009-08-12  8:47             ` Nikanth Karthikesan
2009-08-14  7:01               ` Kiyoshi Ueda
2010-05-11 16:23                 ` Mike Snitzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox