All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: dm-devel@redhat.com
Cc: Kiyoshi Ueda <k-ueda@ct.jp.nec.com>, Alasdair Kergon <agk@redhat.com>
Subject: [PATCH 3/2] dm: table load must always try dm_setup_md_queue
Date: Fri, 4 Jun 2010 16:15:25 -0400	[thread overview]
Message-ID: <20100604201524.GC4917@redhat.com> (raw)
In-Reply-To: <1274964469-22289-3-git-send-email-snitzer@redhat.com>

A DM device's first table_load will establish the immutable md->type.
But md->queue initialization, based on md->type, may fail at that time
(if blk_init_allocated_queue cannot allocate memory).

Therefore any subsequent table_load must (re)try dm_setup_md_queue
independent of establishing md->type.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 drivers/md/dm-ioctl.c |   18 +++++++++---------
 drivers/md/dm.c       |    3 ++-
 2 files changed, 11 insertions(+), 10 deletions(-)

NOTE: coping with blk_init_allocated_queue failure was mistakenly
"optimized" away during review of the patch that introduced
dm_setup_md_queue:
https://www.redhat.com/archives/dm-devel/2010-May/msg00173.html

Index: linux-2.6/drivers/md/dm-ioctl.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-ioctl.c
+++ linux-2.6/drivers/md/dm-ioctl.c
@@ -1181,15 +1181,6 @@ static int table_load(struct dm_ioctl *p
 	if (dm_get_md_type(md) == DM_TYPE_NONE) {
 		/* initial table load, set md's type based on table's type */
 		dm_set_md_type(md, dm_table_get_type(t));
-
-		/* setup md->queue to reflect md's type (may block) */
-		r = dm_setup_md_queue(md);
-		if (r) {
-			DMWARN("unable to setup device queue for this table.");
-			dm_table_destroy(t);
-			dm_unlock_md_type(md);
-			goto out;
-		}
 	} else if (dm_get_md_type(md) != dm_table_get_type(t)) {
 		DMWARN("can't change device type after initial table load.");
 		dm_table_destroy(t);
@@ -1197,6 +1188,15 @@ static int table_load(struct dm_ioctl *p
 		r = -EINVAL;
 		goto out;
 	}
+
+	/* setup md->queue to reflect md's type (may block) */
+	r = dm_setup_md_queue(md);
+	if (r) {
+		DMWARN("unable to setup device queue for this table.");
+		dm_table_destroy(t);
+		dm_unlock_md_type(md);
+		goto out;
+	}
 	dm_unlock_md_type(md);
 
 	/* stage inactive table */
Index: linux-2.6/drivers/md/dm.c
===================================================================
--- linux-2.6.orig/drivers/md/dm.c
+++ linux-2.6/drivers/md/dm.c
@@ -2164,7 +2164,8 @@ static int dm_init_request_based_queue(s
 {
 	struct request_queue *q = NULL;
 
-	BUG_ON(md->queue->elevator);
+	if (unlikely(md->queue->elevator))
+		return 1;
 
 	/* Fully initialize the queue */
 	q = blk_init_allocated_queue(md->queue, dm_request_fn, NULL);

  reply	other threads:[~2010-06-04 20:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27 12:47 [PATCH v4 0/2] dm: restrict conflicting table loads and improve queue initialization Mike Snitzer
2010-05-27 12:47 ` [PATCH v4 1/2] dm: prevent table type changes after initial table load Mike Snitzer
2010-06-29 11:40   ` Alasdair G Kergon
2010-06-29 13:52     ` Mike Snitzer
2010-06-29 14:19       ` Alasdair G Kergon
2010-06-29 15:07         ` Mike Snitzer
2010-05-27 12:47 ` [PATCH v4 2/2 "v11"] dm: only initialize full request_queue for request-based device Mike Snitzer
2010-06-04 20:15   ` Mike Snitzer [this message]
2010-06-09  5:38     ` [PATCH 3/2] dm: table load must always try dm_setup_md_queue Kiyoshi Ueda
2010-06-09  8:53       ` Mike Snitzer
2010-06-10  2:54         ` Kiyoshi Ueda

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=20100604201524.GC4917@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=k-ueda@ct.jp.nec.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.