This patch should be merged with ext4-online-defrag-alloc-contiguous-blks.patch It originally came from ext4_journal_credits_fix_for_writepages.patch, but was split off when this patch was moved into the stable part of the patch queue. Cc: Akira Fujita Cc: Takashi Sato Signed-off-by: Mingming Cao Signed-off-by: "Theodore Ts'o" --- Index: linux-2.6.26-git6/fs/ext4/defrag.c =================================================================== --- linux-2.6.26-git6.orig/fs/ext4/defrag.c 2008-07-25 17:39:23.000000000 -0700 +++ linux-2.6.26-git6/fs/ext4/defrag.c 2008-07-25 17:39:52.000000000 -0700 @@ -1385,7 +1385,8 @@ ext4_defrag_alloc_blocks(handle_t *handl struct buffer_head *bh = NULL; int err, i, credits = 0; - credits = ext4_ext_calc_credits_for_insert(dest_inode, dest_path); + credits = ext4_ext_calc_credits_for_single_extent(dest_inode, dest_path) + + 4; err = ext4_ext_journal_restart(handle, credits + EXT4_TRANS_META_BLOCKS); if (err)