From: Mike Snitzer <snitzer@redhat.com>
To: dm-devel@redhat.com
Cc: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>,
Kiyoshi Ueda <k-ueda@ct.jp.nec.com>,
linux-kernel@vger.kernel.org, Vivek Goyal <vgoyal@redhat.com>,
Jens Axboe <jens.axboe@oracle.com>,
Nikanth Karthikesan <knikanth@suse.de>
Subject: [PATCH 2/2 v2] dm: only initialize full request_queue for request-based device
Date: Thu, 13 May 2010 00:31:09 -0400 [thread overview]
Message-ID: <20100513043108.GB25523@redhat.com> (raw)
In-Reply-To: <1273532139-23043-2-git-send-email-snitzer@redhat.com>
Revert back to only allocating a minimalist request_queue structure
initially (needed for both bio and request-based DM). Initialization of
a full request_queue (request_fn, elevator, etc) is deferred until it is
known that the DM device is request-based.
dm_init_request_based_queue is now called at the end of a request-based
DM device's table load.
Otherwise bio-based DM devices will have an elevator, request_fn, etc.
As a result bio-based DM devices had an 'iosched/' tree as well as a
'scheduler' other than "none" in sysfs.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
drivers/md/dm-table.c | 5 ++++
drivers/md/dm.c | 64 +++++++++++++++++++++++++++++++++++-------------
drivers/md/dm.h | 2 +
3 files changed, 53 insertions(+), 18 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 9924ea2..64a8578 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -829,6 +829,11 @@ int dm_table_set_type(struct dm_table *t)
return -EINVAL;
}
+ if (!dm_init_request_based_queue(t->md)) {
+ DMWARN("Cannot initialize queue for Request-based dm");
+ return -EINVAL;
+ }
+
t->type = DM_TYPE_REQUEST_BASED;
return 0;
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index d21e128..b2171be 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1886,22 +1886,10 @@ 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().
- * 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.
- */
- 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;
@@ -1909,11 +1897,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);
- blk_queue_ordered(md->queue, QUEUE_ORDERED_DRAIN_FLUSH,
- dm_rq_prepare_flush);
md->disk = alloc_disk(1);
if (!md->disk)
@@ -1968,6 +1951,51 @@ bad_module_get:
return NULL;
}
+/*
+ * Fully initialize the request_queue (elevator, ->request_fn, etc).
+ */
+int dm_init_request_based_queue(struct mapped_device *md)
+{
+ struct request_queue *q = NULL;
+
+ if (!md->queue)
+ return 0;
+
+ /*
+ * Avoid re-initializing the queue (and leaking the existing
+ * elevator) if dm_init_request_based_queue() was already used.
+ */
+ if (!md->queue->elevator) {
+ /* Fully initialize the queue */
+ q = blk_init_allocated_queue(md->queue, dm_request_fn, NULL);
+ if (!q)
+ return 0;
+ md->queue = q;
+ md->saved_make_request_fn = md->queue->make_request_fn;
+ blk_queue_make_request(md->queue, dm_request);
+ elv_register_queue(md->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.
+ * 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.
+ */
+ queue_flag_clear_unlocked(QUEUE_FLAG_STACKABLE, md->queue);
+
+ 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);
+ blk_queue_ordered(md->queue, QUEUE_ORDERED_DRAIN_FLUSH,
+ dm_rq_prepare_flush);
+
+ return 1;
+}
+
static void unlock_fs(struct mapped_device *md);
static void free_dev(struct mapped_device *md)
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index bad1724..489feba 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -113,6 +113,8 @@ void dm_sysfs_exit(struct mapped_device *md);
struct kobject *dm_kobject(struct mapped_device *md);
struct mapped_device *dm_get_from_kobject(struct kobject *kobj);
+int dm_init_request_based_queue(struct mapped_device *md);
+
/*
* Targets for linear and striped mappings
*/
next prev parent reply other threads:[~2010-05-13 4:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-10 22:55 [RFC PATCH 1/2] block: allow initialization of previously allocated request_queue Mike Snitzer
2010-05-10 22:55 ` [RFC PATCH 2/2] dm: only initialize full request_queue for request-based device Mike Snitzer
2010-05-11 4:23 ` Kiyoshi Ueda
2010-05-11 13:15 ` Mike Snitzer
2010-05-12 8:23 ` Kiyoshi Ueda
2010-05-13 3:57 ` Mike Snitzer
2010-05-14 8:06 ` Kiyoshi Ueda
2010-05-14 14:08 ` Mike Snitzer
2010-05-17 9:27 ` Kiyoshi Ueda
2010-05-17 17:27 ` Mike Snitzer
2010-05-18 8:32 ` Kiyoshi Ueda
2010-05-18 13:46 ` Mike Snitzer
2010-05-19 5:57 ` Kiyoshi Ueda
2010-05-19 12:01 ` Mike Snitzer
2010-05-19 14:39 ` Mike Snitzer
2010-05-19 14:45 ` Mike Snitzer
2010-05-20 11:21 ` Kiyoshi Ueda
2010-05-20 17:07 ` Mike Snitzer
2010-05-21 8:32 ` Kiyoshi Ueda
2010-05-21 13:34 ` Mike Snitzer
2010-05-24 9:58 ` Kiyoshi Ueda
2010-05-19 21:51 ` Mike Snitzer
2010-05-13 4:31 ` Mike Snitzer [this message]
2010-05-13 5:02 ` [RFC PATCH 3/2] dm: bio-based device must not register elevator in sysfs Mike Snitzer
2010-05-13 22:14 ` [PATCH 3/2 v2] " Mike Snitzer
2010-05-11 6:55 ` [RFC PATCH 1/2] block: allow initialization of previously allocated request_queue Jens Axboe
2010-05-11 13:18 ` Mike Snitzer
2010-05-11 13:21 ` Jens Axboe
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=20100513043108.GB25523@redhat.com \
--to=snitzer@redhat.com \
--cc=dm-devel@redhat.com \
--cc=j-nomura@ce.jp.nec.com \
--cc=jens.axboe@oracle.com \
--cc=k-ueda@ct.jp.nec.com \
--cc=knikanth@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=vgoyal@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).