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. Signed-off-by: Mingming Cao <cmm@xxxxxxxxxx> --- fs/ext4/inode.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) Index: linux-2.6.25-rc2/fs/ext4/inode.c =================================================================== --- linux-2.6.25-rc2.orig/fs/ext4/inode.c 2008-02-19 14:57:00.000000000 -0800 +++ linux-2.6.25-rc2/fs/ext4/inode.c 2008-02-19 15:04:56.000000000 -0800 @@ -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; } - To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html