Commit 99da954f authored by Jan Kara's avatar Jan Kara Committed by Ben Hutchings

ext4: fix fdatasync(2) after extent manipulation operations

commit 67a7d5f5 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: a4bb6b64Signed-off-by: default avatarJan Kara <jack@suse.cz>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
[bwh: Backported to 3.2: Only the punch-hole operation is supported, and
 it's in extents.c.]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 793736b1
...@@ -5023,6 +5023,8 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length) ...@@ -5023,6 +5023,8 @@ int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)
ext4_orphan_del(handle, inode); ext4_orphan_del(handle, inode);
inode->i_mtime = inode->i_ctime = ext4_current_time(inode); inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
ext4_mark_inode_dirty(handle, inode); ext4_mark_inode_dirty(handle, inode);
if (err >= 0)
ext4_update_inode_fsync_trans(handle, inode, 1);
ext4_journal_stop(handle); ext4_journal_stop(handle);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment