Skip to contentSkip to conversation

ext4: general handling preallocated blocks in delayed allocation

PATCH Superseded Mingming Cao 1 participant 1 message Feb 22, 2008 ext4 file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: general handling preallocated blocks in delayed allocation

With delayed allocation, get_block() is only doing block map at the write_begin() time. If the blocks are prea-allocated, the result bh is not mapped, but the blocks are actually being allocated. delalloc should not treat it as other regular unallocated area, thus mark it as need block allocation later, and doing extra reservation incorrectly.

---
 fs/ext4/inode.c |   26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)
fs/ext4/inode.c +12 -14
Index: linux-2.6.25-rc2/fs/ext4/inode.c
===================================================================
@@ -1401,20 +1401,18 @@ static int ext4_da_get_block_prep(struct
 	 * XXX: when the filesystem has a lot of free blocks, we could
 	 * reserve even allocated blocks to save this lookup */
 	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) && (buffer_mapped(bh_result))) {
+		bh_result->b_size = (ret << inode->i_blkbits);
 		ret = 0;
 	}