Re: [PATCH 3/5] ext4_zero_range: fix incorect journal credits reservation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 25, 2014 at 11:19:39AM +0400, Dmitry Monakhov wrote:
> Yes, but ext4_index_trans_blocks is statically defined in inode.c,
> but since zero_range works only for extent based
> ext4_ext_index_trans_blocks is sufficient. Also we must reserve 2 block
> for data. So final calculation looks like follows:
> credits =  ext4_ext_index_trans_blocks(inode, 2) + 2

It turns out this wasn't enough.  This was causing test failures in
the data=journal case for tests generic/008, generic/091, generic/127,
and generic/263, due to not reserving enough credits.  After taking a
closer look at the code, and the requirements of ext4_zero_range, I
believe this is the correct fix.

       	       	   	   	   	   - Ted

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0d531d1..0e9de23 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -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);
--
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




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux