public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Thornber <joe@fib011235813.fsnet.co.uk>
To: Joe Thornber <joe@fib011235813.fsnet.co.uk>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: 8/19
Date: Mon, 16 Dec 2002 10:11:13 +0000	[thread overview]
Message-ID: <20021216101113.GI7407@reti> (raw)
In-Reply-To: <20021216100457.GA7407@reti>

Give each device its own io mempool to avoid a potential
deadlock with stacked devices.  [HM + EJT]
--- diff/drivers/md/dm.c	2002-12-16 09:40:44.000000000 +0000
+++ source/drivers/md/dm.c	2002-12-16 09:40:58.000000000 +0000
@@ -58,11 +58,15 @@
 	 * The current mapping.
 	 */
 	struct dm_table *map;
+
+	/*
+	 * io objects are allocated from here.
+	 */
+	mempool_t *io_pool;
 };
 
 #define MIN_IOS 256
 static kmem_cache_t *_io_cache;
-static mempool_t *_io_pool;
 
 static __init int local_init(void)
 {
@@ -74,18 +78,10 @@
 	if (!_io_cache)
 		return -ENOMEM;
 
-	_io_pool = mempool_create(MIN_IOS, mempool_alloc_slab,
-				  mempool_free_slab, _io_cache);
-	if (!_io_pool) {
-		kmem_cache_destroy(_io_cache);
-		return -ENOMEM;
-	}
-
 	_major = major;
 	r = register_blkdev(_major, _name, &dm_blk_dops);
 	if (r < 0) {
 		DMERR("register_blkdev failed");
-		mempool_destroy(_io_pool);
 		kmem_cache_destroy(_io_cache);
 		return r;
 	}
@@ -98,7 +94,6 @@
 
 static void local_exit(void)
 {
-	mempool_destroy(_io_pool);
 	kmem_cache_destroy(_io_cache);
 
 	if (unregister_blkdev(_major, _name) < 0)
@@ -178,14 +173,14 @@
 	return 0;
 }
 
-static inline struct dm_io *alloc_io(void)
+static inline struct dm_io *alloc_io(struct mapped_device *md)
 {
-	return mempool_alloc(_io_pool, GFP_NOIO);
+	return mempool_alloc(md->io_pool, GFP_NOIO);
 }
 
-static inline void free_io(struct dm_io *io)
+static inline void free_io(struct mapped_device *md, struct dm_io *io)
 {
-	mempool_free(io, _io_pool);
+	mempool_free(io, md->io_pool);
 }
 
 static inline struct deferred_io *alloc_deferred(void)
@@ -254,7 +249,7 @@
 			wake_up(&io->md->wait);
 
 		bio_endio(io->bio, io->error ? 0 : io->bio->bi_size, io->error);
-		free_io(io);
+		free_io(io->md, io);
 	}
 }
 
@@ -419,7 +414,7 @@
 
 	ci.md = md;
 	ci.bio = bio;
-	ci.io = alloc_io();
+	ci.io = alloc_io(md);
 	ci.io->error = 0;
 	atomic_set(&ci.io->io_count, 1);
 	ci.io->bio = bio;
@@ -558,8 +553,17 @@
 	md->queue.queuedata = md;
 	blk_queue_make_request(&md->queue, dm_request);
 
+	md->io_pool = mempool_create(MIN_IOS, mempool_alloc_slab,
+				     mempool_free_slab, _io_cache);
+	if (!md->io_pool) {
+		free_minor(md->disk->first_minor);
+		kfree(md);
+		return NULL;
+	}
+
 	md->disk = alloc_disk(1);
 	if (!md->disk) {
+		mempool_destroy(md->io_pool);
 		free_minor(md->disk->first_minor);
 		kfree(md);
 		return NULL;
@@ -581,6 +585,7 @@
 static void free_dev(struct mapped_device *md)
 {
 	free_minor(md->disk->first_minor);
+	mempool_destroy(md->io_pool);
 	del_gendisk(md->disk);
 	put_disk(md->disk);
 	kfree(md);

  parent reply	other threads:[~2002-12-16 10:05 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-10 22:03 [PATCH] dm.c - device-mapper I/O path fixes Kevin Corry
2002-12-11 12:17 ` Joe Thornber
2002-12-11 12:19   ` Joe Thornber
2002-12-11 18:19     ` Denis Vlasenko
2002-12-11 13:16       ` Kevin Corry
2002-12-11 14:18         ` Joe Thornber
2002-12-11 19:24           ` Denis Vlasenko
2002-12-11 14:06             ` Kevin Corry
2002-12-11 21:12               ` Paul Mackerras
2002-12-12 12:30                 ` Kevin Corry
2002-12-11 19:19         ` Denis Vlasenko
2002-12-11 14:02           ` Kevin Corry
2002-12-11 15:12             ` [lvm-devel] " Joe Thornber
2002-12-11 14:58           ` Joe Thornber
2002-12-11 12:19   ` Joe Thornber
2002-12-11 12:20   ` Joe Thornber
2002-12-11 12:21   ` Joe Thornber
2002-12-11 12:52   ` [lvm-devel] " Kevin Corry
2002-12-16  0:50   ` Linus Torvalds
2002-12-16 10:04     ` Joe Thornber
2002-12-16 10:06       ` 1/19 Joe Thornber
2002-12-16 17:07         ` 1/19 Linus Torvalds
2002-12-16 10:06       ` 2/19 Joe Thornber
2002-12-16 10:07       ` 3/19 Joe Thornber
2002-12-16 10:08       ` 4/19 Joe Thornber
2002-12-16 10:09       ` 5/19 Joe Thornber
2002-12-16 10:09       ` 6/19 Joe Thornber
2002-12-16 10:35         ` 6/19 Tomas Szepe
2002-12-16 10:38           ` 6/19 Tomas Szepe
2002-12-16 10:10       ` 7/19 Joe Thornber
2002-12-16 10:11       ` Joe Thornber [this message]
2002-12-16 10:11       ` 9/19 Joe Thornber
2002-12-16 10:12       ` 10/19 Joe Thornber
2002-12-16 10:13       ` 11/19 Joe Thornber
2002-12-16 10:14       ` 12/19 Joe Thornber
2002-12-16 10:14       ` 13/19 Joe Thornber
2002-12-16 10:15       ` 14/19 Joe Thornber
2002-12-16 10:16       ` 15/19 Joe Thornber
2002-12-16 10:16       ` 16/19 Joe Thornber
2002-12-16 10:17       ` 17/19 Joe Thornber
2002-12-16 10:18       ` 18/19 Joe Thornber
2002-12-16 10:19       ` 19/19 Joe Thornber

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=20021216101113.GI7407@reti \
    --to=joe@fib011235813.fsnet.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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