Skip to content

Commit 1ce01c4

Browse files
namjaejeontytso
authored andcommitted
ext4: fix COLLAPSE_RANGE test failure in data journalling mode
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. Signed-off-by: Namjae Jeon <[email protected]> Signed-off-by: Ashish Sangwan <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]>
1 parent 87f7e41 commit 1ce01c4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/ext4/extents.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5383,6 +5383,13 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
53835383
punch_start = offset >> EXT4_BLOCK_SIZE_BITS(sb);
53845384
punch_stop = (offset + len) >> EXT4_BLOCK_SIZE_BITS(sb);
53855385

5386+
/* Call ext4_force_commit to flush all data in case of data=journal. */
5387+
if (ext4_should_journal_data(inode)) {
5388+
ret = ext4_force_commit(inode->i_sb);
5389+
if (ret)
5390+
return ret;
5391+
}
5392+
53865393
/* Write out all dirty pages */
53875394
ret = filemap_write_and_wait_range(inode->i_mapping, offset, -1);
53885395
if (ret)

0 commit comments

Comments
 (0)