linux_dsm_epyc7002/fs/ext4
Jan Kara 90e775b71a ext4: fix lost truncate due to race with writeback
The following race can lead to a loss of i_disksize update from truncate
thus resulting in a wrong inode size if the inode size isn't updated
again before inode is reclaimed:

ext4_setattr()				mpage_map_and_submit_extent()
  EXT4_I(inode)->i_disksize = attr->ia_size;
  ...					  ...
					  disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT
					  /* False because i_size isn't
					   * updated yet */
					  if (disksize > i_size_read(inode))
					  /* True, because i_disksize is
					   * already truncated */
					  if (disksize > EXT4_I(inode)->i_disksize)
					    /* Overwrite i_disksize
					     * update from truncate */
					    ext4_update_i_disksize()
  i_size_write(inode, attr->ia_size);

For other places updating i_disksize such race cannot happen because
i_mutex prevents these races. Writeback is the only place where we do
not hold i_mutex and we cannot grab it there because of lock ordering.

We fix the race by doing both i_disksize and i_size update in truncate
atomically under i_data_sem and in mpage_map_and_submit_extent() we move
the check against i_size under i_data_sem as well.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
2013-08-17 10:09:31 -04:00
..
acl.c
acl.h fs: take the ACL checks to common code 2011-07-25 14:30:23 -04:00
balloc.c
bitmap.c ext4: Checksum the block bitmap properly with bigalloc enabled 2012-10-22 00:34:32 -04:00
block_validity.c
dir.c [readdir] convert ext4 2013-06-29 12:56:40 +04:00
ext4_extents.h ext4: mext_insert_extents should update extent block checksum 2013-04-19 14:04:12 -04:00
ext4_jbd2.c
ext4_jbd2.h ext4: use transaction reservation for extent conversion in ext4_end_io 2013-06-04 13:21:11 -04:00
ext4.h ext4: fix lost truncate due to race with writeback 2013-08-17 10:09:31 -04:00
extents_status.c ext4: add support for extent pre-caching 2013-08-16 22:05:14 -04:00
extents_status.h ext4: cache all of an extent tree's leaf block upon reading 2013-08-16 21:23:41 -04:00
extents.c ext4: fix warning in ext4_da_update_reserve_space() 2013-08-17 09:36:54 -04:00
file.c
fsync.c
hash.c
ialloc.c ext4: avoid reusing recently deleted inodes in no journal mode 2013-08-16 22:06:55 -04:00
indirect.c
inline.c
inode.c ext4: fix lost truncate due to race with writeback 2013-08-17 10:09:31 -04:00
ioctl.c ext4: add support for extent pre-caching 2013-08-16 22:05:14 -04:00
Kconfig
Makefile
mballoc.c ext4: fix warning in ext4_da_update_reserve_space() 2013-08-17 09:36:54 -04:00
mballoc.h ext4: use module parameters instead of debugfs for mballoc_debug 2013-02-09 16:28:20 -05:00
migrate.c ext4: cache all of an extent tree's leaf block upon reading 2013-08-16 21:23:41 -04:00
mmp.c ext4: mark all metadata I/O with REQ_META 2013-04-20 15:46:17 -04:00
move_extent.c ext4: cache all of an extent tree's leaf block upon reading 2013-08-16 21:23:41 -04:00
namei.c ext4: allocate delayed allocation blocks before rename 2013-08-16 22:06:53 -04:00
page-io.c
resize.c
super.c ext4: fix mount/remount error messages for incompatible mount options 2013-08-08 23:02:24 -04:00
symlink.c ext4: Remove CONFIG_EXT4_FS_XATTR 2012-12-10 16:30:43 -05:00
truncate.h ext4: move common truncate functions to header file 2011-06-27 19:16:04 -04:00
xattr_security.c
xattr_trusted.c
xattr_user.c
xattr.c
xattr.h