Skip to content

Commit 4ff7da0

Browse files
Eryu Guangregkh
authored andcommitted
ext4: fix fdatasync(2) after fallocate(2) operation
commit c894aa9 upstream. Currently, fallocate(2) with KEEP_SIZE followed by a fdatasync(2) then crash, we'll see wrong allocated block number (stat -c %b), the blocks allocated beyond EOF are all lost. fstests generic/468 exposes this bug. Commit 67a7d5f ("ext4: fix fdatasync(2) after extent manipulation operations") fixed all the other extent manipulation operation paths such as hole punch, zero range, collapse range etc., but forgot the fallocate case. So similarly, fix it by recording the correct journal tid in ext4 inode in fallocate(2) path, so that ext4_sync_file() will wait for the right tid to be committed on fdatasync(2). This addresses the test failure in xfstests test generic/468. Signed-off-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ae0bba6 commit 4ff7da0

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

‎fs/ext4/extents.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4722,6 +4722,7 @@ static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
47224722
EXT4_INODE_EOFBLOCKS);
47234723
}
47244724
ext4_mark_inode_dirty(handle, inode);
4725+
ext4_update_inode_fsync_trans(handle, inode, 1);
47254726
ret2 = ext4_journal_stop(handle);
47264727
if (ret2)
47274728
break;

0 commit comments

Comments
 (0)