public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Mingming Cao <cmm@us.ibm.com>
To: linux-ext4@vger.kernel.org
Subject: [PATCH-v2] ext4: Handling preallocated blocks in delayed allocation
Date: Fri, 29 Feb 2008 10:44:35 -0800	[thread overview]
Message-ID: <1204310675.3629.9.camel@localhost.localdomain> (raw)

ext4: Handling preallocated blocks in delayed allocation
From: Mingming Cao <cmm@us.ibm.com>

This patch fix ext4 delayed allocation that allows it
avoid doing delayed allocation handling for blocks that
are already preallocated on disk.

With delayed allocation, at write_begin() time, 
ext4_get_blocks_wrap() now is only doing block map with create = 0.
ext4_get_blocks_wrap() returns 0 if the blocks are not allocated
or preallocated().

If the blocks are prea-allocated, the resulting buffer head
is not mapped marked, but ext4_get_blocks_wrap() returns the number of
blocks are actually being preallocated.

Right now delayed allocation mistream pre-allocated blocks as
un-allocated as the buffer head is unmapped.

This patch fix this by checking the number of blocks
returned by ext4_get_blocks_wrap() rather than checking
if buffer head is mapped or not.

Signed-off-by: Mingming Cao <cmm@us.ibm.com>
---
 fs/ext4/inode.c |   36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

Index: linux-2.6.25-rc3/fs/ext4/inode.c
===================================================================
--- linux-2.6.25-rc3.orig/fs/ext4/inode.c	2008-02-29 10:17:21.000000000 -0800
+++ linux-2.6.25-rc3/fs/ext4/inode.c	2008-02-29 10:40:01.000000000 -0800
@@ -1343,7 +1343,7 @@ static int ext4_journalled_write_end(str
 }
 
 /*
- * this is a special callback for ->prepare_write() only
+ * this is a special callback for ->write_begin() only
  * it's intention is to return mapped block or reserve space
  */
 static int ext4_da_get_block_prep(struct inode *inode, sector_t iblock,
@@ -1354,24 +1354,24 @@ static int ext4_da_get_block_prep(struct
 	BUG_ON(create == 0);
 	BUG_ON(bh_result->b_size != inode->i_sb->s_blocksize);
 
-	/* first, we need to know whether the block is allocated already
-	 * XXX: when the filesystem has a lot of free blocks, we could
-	 * reserve even allocated blocks to save this lookup */
+	/*
+	 * first, we need to know whether the block is allocated already
+	 * preallocated blocks are unmapped but should treated
+	 * the same as allocated blocks.
+	 */
 	ret = ext4_get_blocks_wrap(NULL, inode, iblock, 1,  bh_result, 0, 0);
-	if (ret >= 0) {
-		if (buffer_mapped(bh_result)) {
-			bh_result->b_size = (ret << inode->i_blkbits);
-		} else {
-			/* the block isn't allocated yet, let's reserve space */
-			/* XXX: call reservation here */
-			/*
-			 * XXX: __block_prepare_write() unmaps passed block,
-			 * is it OK?
-			 */
-			map_bh(bh_result, inode->i_sb, 0);
-			set_buffer_new(bh_result);
-			set_buffer_delay(bh_result);
-		}
+	if (ret == 0) {
+		/* the block isn't allocated yet, let's reserve space */
+		/* XXX: call reservation here */
+		/*
+		 * XXX: __block_prepare_write() unmaps passed block,
+		 * is it OK?
+		 */
+		map_bh(bh_result, inode->i_sb, 0);
+		set_buffer_new(bh_result);
+		set_buffer_delay(bh_result);
+	} else if (ret > 0) {
+		bh_result->b_size = (ret << inode->i_blkbits);
 		ret = 0;
 	}
 



                 reply	other threads:[~2008-02-29 18:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1204310675.3629.9.camel@localhost.localdomain \
    --to=cmm@us.ibm.com \
    --cc=linux-ext4@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox