@@ -4831,8 +4831,13 @@ static long ext4_zero_range(struct file *file, loff_t offset,
if (ret)
goto out_dio;
}
- /* In worst case we have to writeout two nonadjacent unwritten blocks */
- credits = ext4_ext_index_trans_blocks(inode, 2) + 2;
+ /*
+ * In worst case we have to writeout two nonadjacent unwritten
+ * blocks and update the inode
+ */
+ credits = (2 * ext4_ext_index_trans_blocks(inode, 2)) + 1;
+ if (ext4_should_journal_data(inode))
+ credits += 2;
handle = ext4_journal_start(inode, EXT4_HT_MISC, credits);
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);