aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-05-29 13:24:55 -0400
committerTheodore Ts'o <tytso@mit.edu>2017-05-29 13:24:55 -0400
commit67a7d5f561f469ad2fa5154d2888258ab8e6df7c (patch)
treeaa5b273ba62c4a0301dae73d13978a5e8217e16c
parenta056bdaae7a181f7dcc876cfab2f94538e508709 (diff)
ext4: fix fdatasync(2) after extent manipulation operations
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. CC: stable@vger.kernel.org Fixes: a4bb6b64e39abc0e41ca077725f2a72c868e7622 Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r--fs/ext4/extents.c5
-rw-r--r--fs/ext4/inode.c2
2 files changed, 7 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 83a513efc824..3e36508610b7 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4877,6 +4877,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
4877 4877
4878 /* Zero out partial block at the edges of the range */ 4878 /* Zero out partial block at the edges of the range */
4879 ret = ext4_zero_partial_blocks(handle, inode, offset, len); 4879 ret = ext4_zero_partial_blocks(handle, inode, offset, len);
4880 if (ret >= 0)
4881 ext4_update_inode_fsync_trans(handle, inode, 1);
4880 4882
4881 if (file->f_flags & O_SYNC) 4883 if (file->f_flags & O_SYNC)
4882 ext4_handle_sync(handle); 4884 ext4_handle_sync(handle);
@@ -5563,6 +5565,7 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len)
5563 ext4_handle_sync(handle); 5565 ext4_handle_sync(handle);
5564 inode->i_mtime = inode->i_ctime = current_time(inode); 5566 inode->i_mtime = inode->i_ctime = current_time(inode);
5565 ext4_mark_inode_dirty(handle, inode); 5567 ext4_mark_inode_dirty(handle, inode);
5568 ext4_update_inode_fsync_trans(handle, inode, 1);
5566 5569
5567out_stop: 5570out_stop:
5568 ext4_journal_stop(handle); 5571 ext4_journal_stop(handle);
@@ -5736,6 +5739,8 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
5736 up_write(&EXT4_I(inode)->i_data_sem); 5739 up_write(&EXT4_I(inode)->i_data_sem);
5737 if (IS_SYNC(inode)) 5740 if (IS_SYNC(inode))
5738 ext4_handle_sync(handle); 5741 ext4_handle_sync(handle);
5742 if (ret >= 0)
5743 ext4_update_inode_fsync_trans(handle, inode, 1);
5739 5744
5740out_stop: 5745out_stop:
5741 ext4_journal_stop(handle); 5746 ext4_journal_stop(handle);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 657a98fa80b6..5cf82d03968c 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4218,6 +4218,8 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
4218 4218
4219 inode->i_mtime = inode->i_ctime = current_time(inode); 4219 inode->i_mtime = inode->i_ctime = current_time(inode);
4220 ext4_mark_inode_dirty(handle, inode); 4220 ext4_mark_inode_dirty(handle, inode);
4221 if (ret >= 0)
4222 ext4_update_inode_fsync_trans(handle, inode, 1);
4221out_stop: 4223out_stop:
4222 ext4_journal_stop(handle); 4224 ext4_journal_stop(handle);
4223out_dio: 4225out_dio: