Hi Ted: On Tue, Dec 29, 2009 at 10:53 AM, <tytso@xxxxxxx> wrote: > On Tue, Dec 29, 2009 at 09:56:29AM -0800, Curt Wohlgemuth wrote: >> >> Thanks for pointing out the arithmetic problems in my patch. Yours >> below looks good to me. > > Hi Curt, > > Can you do me a favor and send out a full patch with Aneesh's > correction? Here it is. This is against 2.6.33-rc2, if that makes a difference. Thanks! ==================================================================== This fixes a bug in which new blocks returned from an extent created with ext4_ext_zeroout() can have dirty metadata still associated with them. This patch was originally by Aneesh Kumar <aneesh.kumar@xxxxxxxxxxxxxxxxxx>. Signed-off-by: Curt Wohlgemuth <curtw@xxxxxxxxxx> --- diff -uprN orig/fs/ext4/extents.c new/fs/ext4/extents.c --- orig/fs/ext4/extents.c 2009-12-29 14:59:12.000000000 -0800 +++ new/fs/ext4/extents.c 2009-12-29 15:18:43.000000000 -0800 @@ -3023,6 +3023,14 @@ out: return err; } +static void unmap_underlying_metadata_blocks(struct block_device *bdev, + sector_t block, int count) +{ + int i; + for (i = 0; i < count; i++) + unmap_underlying_metadata(bdev, block + i); +} + static int ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, ext4_lblk_t iblock, unsigned int max_blocks, @@ -3098,6 +3106,18 @@ out: } else allocated = ret; set_buffer_new(bh_result); + /* + * if we allocated more blocks than requested + * we need to make sure we unmap the extra block + * allocated. The actual needed block will get + * unmapped later when we find the buffer_head marked + * new. + */ + if (allocated > max_blocks) { + unmap_underlying_metadata_blocks(inode->i_sb->s_bdev, + newblock + max_blocks, + allocated - max_blocks); + } map_out: set_buffer_mapped(bh_result); out1: -- 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