Messages in this thread Patch in this message | | | From | Ben Hutchings <> | Date | Sat, 09 Sep 2017 22:47:14 +0100 | Subject | [PATCH 3.16 098/233] ext4: fix fdatasync(2) after extent manipulation operations |
| |
3.16.48-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <jack@suse.cz>
commit 67a7d5f561f469ad2fa5154d2888258ab8e6df7c upstream.
Currently, extent manipulation operations such as hole punch, range zeroing, or extent shifting do not record the fact that file data has changed and thus fdatasync(2) has a work to do. As a result if we crash e.g. after a punch hole and fdatasync, user can still possibly see the punched out data after journal replay. Test generic/392 fails due to these problems.
Fix the problem by properly marking that file data has changed in these operations.
Fixes: a4bb6b64e39abc0e41ca077725f2a72c868e7622 Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu> [bwh: Backported to 3.16: drop change in ext4_insert_range()] Signed-off-by: Ben Hutchings <ben@decadent.org.uk> --- --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -4883,6 +4883,8 @@ static long ext4_zero_range(struct file /* Zero out partial block at the edges of the range */ ret = ext4_zero_partial_blocks(handle, inode, offset, len); + if (ret >= 0) + ext4_update_inode_fsync_trans(handle, inode, 1); if (file->f_flags & O_SYNC) ext4_handle_sync(handle); @@ -5505,6 +5507,7 @@ int ext4_collapse_range(struct inode *in ext4_handle_sync(handle); inode->i_mtime = inode->i_ctime = ext4_current_time(inode); ext4_mark_inode_dirty(handle, inode); + ext4_update_inode_fsync_trans(handle, inode, 1); out_stop: ext4_journal_stop(handle); --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3781,6 +3781,8 @@ int ext4_punch_hole(struct inode *inode, inode->i_mtime = inode->i_ctime = ext4_current_time(inode); ext4_mark_inode_dirty(handle, inode); + if (ret >= 0) + ext4_update_inode_fsync_trans(handle, inode, 1); out_stop: ext4_journal_stop(handle); out_dio:
| |