vfs: plumb i_version handling into struct kstat
authorJeff Layton <jlayton@redhat.com>
Sun, 4 Dec 2016 14:29:46 +0000 (09:29 -0500)
committerJeff Layton <jlayton@kernel.org>
Thu, 26 Jan 2023 12:00:06 +0000 (07:00 -0500)
commita1175d6b1bdaf4f74eda47ab18eb44194f9cb796
tree119118d44cd9bb0ad0b9ac5407b91dac9ec3d3da
parenta3bb710383cbca2a0f1f4e5a1c7ef8dde14eff95
vfs: plumb i_version handling into struct kstat

The NFS server has a lot of special handling for different types of
change attribute access, depending on the underlying filesystem. In
most cases, it's doing a getattr anyway and then fetching that value
after the fact.

Rather that do that, add a new STATX_CHANGE_COOKIE flag that is a
kernel-only symbol (for now). If requested and getattr can implement it,
it can fill out this field. For IS_I_VERSION inodes, add a generic
implementation in vfs_getattr_nosec. Take care to mask
STATX_CHANGE_COOKIE off in requests from userland and in the result
mask.

Since not all filesystems can give the same guarantees of monotonicity,
claim a STATX_ATTR_CHANGE_MONOTONIC flag that filesystems can set to
indicate that they offer an i_version value that can never go backward.

Eventually if we decide to make the i_version available to userland, we
can just designate a field for it in struct statx, and move the
STATX_CHANGE_COOKIE definition to the uapi header.

Reviewed-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
fs/stat.c
include/linux/stat.h