ovl: copy up sync/noatime fileattr flags
authorAmir Goldstein <amir73il@gmail.com>
Sat, 19 Jun 2021 09:26:18 +0000 (12:26 +0300)
committerMiklos Szeredi <mszeredi@redhat.com>
Tue, 17 Aug 2021 09:47:43 +0000 (11:47 +0200)
commit72db82115d2bdfbfba8b15a92d91872cfe1b40c6
treeca2bf80ebd0806f50185fddda46d323459f15635
parenta0c236b11706cc223252ad97e80871a18d9ee812
ovl: copy up sync/noatime fileattr flags

When a lower file has sync/noatime fileattr flags, the behavior of
overlayfs post copy up is inconsistent.

Immediately after copy up, ovl inode still has the S_SYNC/S_NOATIME
inode flags copied from lower inode, so vfs code still treats the ovl
inode as sync/noatime.  After ovl inode evict or mount cycle,
the ovl inode does not have these inode flags anymore.

To fix this inconsistency, try to copy the fileattr flags on copy up
if the upper fs supports the fileattr_set() method.

This gives consistent behavior post copy up regardless of inode eviction
from cache.

We cannot copy up the immutable/append-only inode flags in a similar
manner, because immutable/append-only inodes cannot be linked and because
overlayfs will not be able to set overlay.* xattr on the upper inodes.

Those flags will be addressed by a followup patch.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/copy_up.c
fs/overlayfs/inode.c
fs/overlayfs/overlayfs.h