Skip to contentSkip to conversation

ext4: fix shared/002 and 004 teacase fail issue in xfstests

PATCH In review Namjae Jeon 2 participants 2 messages Apr 9, 2014 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ext4: fix shared/002 and 004 teacase fail issue in xfstests

From: Namjae Jeon <[email protected]>

When mounting ext4 with data=journal option, xfstest shared/002 and shared/004
are currently failing as checksum computed for testfile does not match with the checksum computed in other journal modes. In case of data=journal mode, a call to filemap_write_and_wait_range will not flush anything to disk as buffers are not marked dirty in write_end. In collapse range this call is followed by a call to truncate_pagecache_range. Due to this, when checksum is
computed, a portion of file is re-read from disk which replace valid data with
NULL bytes and hence the reason for the difference in checksum.

Calling ext4_force_commit before filemap_write_and_wait_range solves the issue
as it will mark the buffers dirty during commit transaction which can be later
synced by a call to filemap_write_and_wait_range.

---
 fs/ext4/extents.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ext4/extents.c +0 -0
index d7a78ed..ec1d9c4 100644
@@ -5112,6 +5112,13 @@ int ext4_collapse_range(struct inode *inode, loff_t

offset, loff_t len)
punch_start = offset >> EXT4_BLOCK_SIZE_BITS(sb); punch_stop = (offset + len) >> EXT4_BLOCK_SIZE_BITS(sb);

+ /* Call ext4_force_commit to flush all data in case of
data=journal.*/
+ if (ext4_should_journal_data(inode)) {
+ ret = ext4_force_commit(inode->i_sb);
+ if (ret)
+ return ret;
+ }
+
/* Write out all dirty pages */
ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1); if (ret)

Signature · 1 line
1.7.11-rc0
#1 lore raw

plz ignore this patch. I will send it again.
Thanks.

2014-04-09 19:23 GMT+09:00, Namjae Jeon <[email protected]>:

Quoted 50 lines

From: Namjae Jeon <[email protected]>

When mounting ext4 with data=journal option, xfstest shared/002 and shared/004
are currently failing as checksum computed for testfile does not match with the checksum computed in other journal modes. In case of data=journal mode, a call to filemap_write_and_wait_range will not flush anything to disk as buffers are not marked dirty in write_end. In collapse range this call is followed by a call to truncate_pagecache_range. Due to this, when checksum is
computed, a portion of file is re-read from disk which replace valid data with
NULL bytes and hence the reason for the difference in checksum.

Calling ext4_force_commit before filemap_write_and_wait_range solves the issue
as it will mark the buffers dirty during commit transaction which can be later
synced by a call to filemap_write_and_wait_range.

---
 fs/ext4/extents.c | 7 +++++++
 1 file changed, 7 insertions(+)
fs/ext4/extents.c +1 -0
index d7a78ed..ec1d9c4 100644
@@ -5112,6 +5112,13 @@ int ext4_collapse_range(struct inode *inode, loff_t
 offset, loff_t len)
 	punch_start = offset >> EXT4_BLOCK_SIZE_BITS(sb);
 	punch_stop = (offset + len) >> EXT4_BLOCK_SIZE_BITS(sb);
 
+	/* Call ext4_force_commit to flush all data in case of

data=journal.*/

fs/ext4/extents.c +6 -1
+	if (ext4_should_journal_data(inode)) {
+		ret = ext4_force_commit(inode->i_sb);
+		if (ret)
+			return ret;
+	}
+
 	/* Write out all dirty pages */
 	ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1);
 	if (ret)
--

1.7.11-rc0