]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ext4: fix i_version handling in ext4
authorJeff Layton <jlayton@kernel.org>
Thu, 8 Sep 2022 17:24:42 +0000 (13:24 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Oct 2022 07:56:55 +0000 (09:56 +0200)
commitc2ddd16160de40a21e31a961b9e1df5036464461
treebfb56a17b9ee29633b9ff48dd3fc2e08339974ba
parentc839f6b1e8a68a381702c9ea123d17c3be60b779
ext4: fix i_version handling in ext4

commit a642c2c0827f5604a93f9fa1e5701eecdce4ae22 upstream.

ext4 currently updates the i_version counter when the atime is updated
during a read. This is less than ideal as it can cause unnecessary cache
invalidations with NFSv4 and unnecessary remeasurements for IMA.

The increment in ext4_mark_iloc_dirty is also problematic since it can
corrupt the i_version counter for ea_inodes. We aren't bumping the file
times in ext4_mark_iloc_dirty, so changing the i_version there seems
wrong, and is the cause of both problems.

Remove that callsite and add increments to the setattr, setxattr and
ioctl codepaths, at the same times that we update the ctime. The
i_version bump that already happens during timestamp updates should take
care of the rest.

In ext4_move_extents, increment the i_version on both inodes, and also
add in missing ctime updates.

[ Some minor updates since we've already enabled the i_version counter
  unconditionally already via another patch series. -- TYT ]

Cc: stable@kernel.org
Cc: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20220908172448.208585-3-jlayton@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/inode.c
fs/ext4/ioctl.c
fs/ext4/xattr.c