All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] dio: add a mempool for the unaligned block structures
Date: Mon,  8 Nov 2010 18:40:23 +1100	[thread overview]
Message-ID: <1289202023-15102-4-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1289202023-15102-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

We need the zero block tracking structure allocation to succeed.
Silently failing and potentially allowing data corruption is not an
option. Add a mempool to ensure this allocation will always succeed.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/direct-io.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 353ac52..f8d7f6d 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -161,12 +161,22 @@ struct dio_zero_block_head {
 static struct dio_zero_block_head dio_zero_blocks[DIO_ZERO_BLOCK_NR];
 #define to_dio_zero_head(zb)	(&dio_zero_blocks[zb % DIO_ZERO_BLOCK_NR])
 
+/* a small mempool just to guarantee progress. */
+#define DIO_ZERO_BLOCK_ENTRIES	2
+static mempool_t *dio_zero_block_pool;
+
 
 static int __init
 dio_init_zero_block(void)
 {
 	int i;
 
+	dio_zero_block_pool = mempool_create_kmalloc_pool(
+					DIO_ZERO_BLOCK_ENTRIES,
+					sizeof(struct dio_zero_block));
+	if (!dio_zero_block_pool)
+		panic("dio: can't create zero block pool");
+
 	for (i = 0; i < DIO_ZERO_BLOCK_NR; i++) {
 		spin_lock_init(&dio_zero_blocks[i].lock);
 		INIT_LIST_HEAD(&dio_zero_blocks[i].list);
@@ -184,9 +194,7 @@ dio_start_zero_block(struct dio *dio, sector_t zero_block)
 	struct dio_zero_block_head *zbh = to_dio_zero_head(zero_block);
 	struct dio_zero_block *zb;
 
-	zb = kmalloc(sizeof(*zb), GFP_NOIO);
-	if (!zb)
-		return;
+	zb = mempool_alloc(dio_zero_block_pool, GFP_NOIO);
 	INIT_LIST_HEAD(&zb->dio_list);
 	init_waitqueue_head(&zb->wq);
 	zb->zero_block = zero_block;
-- 
1.7.2.3


  parent reply	other threads:[~2010-11-08  7:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-08  7:40 [REPOST, PATCH 0/3] dio: serialise unaligned direct IO Dave Chinner
2010-11-08  7:40 ` [PATCH 1/3] dio: track and " Dave Chinner
2010-11-08 15:28   ` Jeff Moyer
2010-11-08 22:55     ` Dave Chinner
2010-11-08  7:40 ` [PATCH 2/3] dio: scale unaligned IO tracking via multiple lists Dave Chinner
2010-11-08 15:36   ` Jeff Moyer
2010-11-08 23:12     ` Dave Chinner
2010-11-09 21:04       ` Jeff Moyer
2010-11-09 23:06         ` Dave Chinner
2010-11-11 15:32           ` Jeff Moyer
2010-11-08  7:40 ` Dave Chinner [this message]
2010-11-08 15:40   ` [PATCH 3/3] dio: add a mempool for the unaligned block structures Jeff Moyer
  -- strict thread matches above, loose matches on Subject: below --
2010-08-03  7:23 [PATCH 0/3] dio: serialise unaligned direct IO V3 Dave Chinner
2010-08-03  7:23 ` [PATCH 3/3] dio: add a mempool for the unaligned block structures Dave Chinner
2010-08-03  7:23   ` Dave Chinner

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=1289202023-15102-4-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.