linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: cmm@us.ibm.com, tytso@mit.edu, sandeen@redhat.com,
	Solofo.Ramangalahy@bull.net, dmonakhov@openvz.org
Cc: linux-ext4@vger.kernel.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space.
Date: Fri, 21 Mar 2008 11:48:57 +0530	[thread overview]
Message-ID: <1206080337-8732-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1206080337-8732-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>

ext4_ext_get_blocks  returns number of blocks allocated with buffer head
unmapped for a read from prealloc space. This is needed so that delayed
allocation doesn't do block reservation for prealloc space since the blocks
are already resevred on disk. Fix ext4_ext_get_blocks to not return greater
than max_blocks and also mark the buffer head unwritten. Some code path tries
to read the block if buffer_head is not new and no uptodate. Marking the buffer
head unwritten avoid this reading.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fs/ext4/extents.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index d6ae40a..edd1bf2 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2600,8 +2600,20 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
 			}
 			if (create == EXT4_CREATE_UNINITIALIZED_EXT)
 				goto out;
-			if (!create)
+			if (!create) {
+				/*
+				 * We have blocks reserved already. We
+				 * return allocated blocks so that delalloc
+				 * won't do block reservation for us. But
+				 * the buffer head will be unmapped so that
+				 * a read from the block return 0
+				 */
+				if (allocated > max_blocks)
+					allocated = max_blocks;
+				/* mark the buffer unwritten */
+				__set_bit(BH_Unwritten, &bh_result->b_state);
 				goto out2;
+			}
 
 			ret = ext4_ext_convert_to_initialized(handle, inode,
 								path, iblock,
-- 
1.5.5.rc0.16.g02b00.dirty


  reply	other threads:[~2008-03-21  6:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-21  6:18 [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation Aneesh Kumar K.V
2008-03-21  6:18 ` Aneesh Kumar K.V [this message]
2008-03-21 22:13   ` [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space Mingming Cao
2008-03-24  8:11     ` Aneesh Kumar K.V
2008-03-24 16:04       ` Mingming Cao
2008-03-21 22:08 ` [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation Mingming Cao

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=1206080337-8732-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=Solofo.Ramangalahy@bull.net \
    --cc=cmm@us.ibm.com \
    --cc=dmonakhov@openvz.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=tytso@mit.edu \
    /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).