From de5ee1a67d1c3284d65dc69bbbf89664af70b357 Mon Sep 17 00:00:00 2001 From: Joe Gorse Date: Mon, 20 Mar 2017 14:30:46 +0000 Subject: [PATCH] Linux v4.11: getattr takes struct path With Linux commit a528d35e8bfcc521d7cb70aaf03e1bd296c8493f statx: Add a system call to make enhanced file info available The Linux getattr inode operation is altered to take two additional arguments: a u32 request_mask and an unsigned int flags that indicate the synchronisation mode. This change is propagated to the vfs_getattr*() function. - int (*getattr) (struct vfsmount *, struct dentry *, struct kstat *); + int (*getattr) (const struct path *, struct kstat *, + u32 request_mask, unsigned int sync_mode); The first argument, request_mask, indicates which fields of the statx structure are of interest to the userland call. The second argument, flags, currently may take the values defined in include/uapi/linux/fcntl.h and are optionally used for cache coherence: (1) AT_STATX_SYNC_AS_STAT tells statx() to behave as stat() does. (2) AT_STATX_FORCE_SYNC will require a network filesystem to synchronise its attributes with the server - which might require data writeback to occur to get the timestamps correct. (3) AT_STATX_DONT_SYNC will suppress synchronisation with the server in a network filesystem. The resulting values should be considered approximate. This patch provides a new autoconf test and conditional compilation to cope with the changes in our getattr implementation. Change-Id: Ie4206140ae249c00a8906331c57da359c4a372c4 Reviewed-on: https://gerrit.openafs.org/12572 Reviewed-by: Joe Gorse Tested-by: Joe Gorse Tested-by: BuildBot Reviewed-by: Michael Meffie Reviewed-by: Mark Vitale Reviewed-by: Benjamin Kaduk --- acinclude.m4 | 1 + src/afs/LINUX/osi_vnodeops.c | 16 ++++++++++++++-- src/cf/linux-test4.m4 | 12 ++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index c6a669be7f..3d6d8b5178 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1173,6 +1173,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) LINUX_REGISTER_SYSCTL_TABLE_NOFLAG LINUX_HAVE_DCACHE_LOCK LINUX_D_COUNT_IS_INT + LINUX_IOP_GETATTR_TAKES_PATH_STRUCT LINUX_IOP_MKDIR_TAKES_UMODE_T LINUX_IOP_CREATE_TAKES_UMODE_T LINUX_EXPORT_OP_ENCODE_FH_TAKES_INODES diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 2ca0aa152f..8e9a2ef524 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1078,15 +1078,27 @@ out: return afs_convert_code(code); } +#if defined(IOP_GETATTR_TAKES_PATH_STRUCT) +static int +afs_linux_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int sync_mode) +{ + int err = afs_linux_revalidate(path->dentry); + if (!err) { + generic_fillattr(path->dentry->d_inode, stat); + } + return err; +} +#else static int afs_linux_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) { int err = afs_linux_revalidate(dentry); if (!err) { generic_fillattr(dentry->d_inode, stat); + } + return err; } - return err; -} +#endif static afs_uint32 parent_vcache_dv(struct inode *inode, cred_t *credp) diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 index c7c2581c63..a93b51b7d3 100644 --- a/src/cf/linux-test4.m4 +++ b/src/cf/linux-test4.m4 @@ -627,6 +627,18 @@ AC_DEFUN([LINUX_DOP_D_DELETE_TAKES_CONST], [ [-Werror]) ]) +AC_DEFUN([LINUX_IOP_GETATTR_TAKES_PATH_STRUCT], [ + AC_CHECK_LINUX_BUILD([whether 4.11+ inode.i_op->getattr takes a struct path argument], + [ac_cv_linux_iop_getattr_takes_path_struct], + [#include + int _getattr(const struct path *path, struct kstat *stat, u32 request_mask, + unsigned int sync_mode) {return 0;}; + struct inode_operations _i_ops;], + [_i_ops.getattr = _getattr;], + [IOP_GETATTR_TAKES_PATH_STRUCT], + [define if 4.11+ inode.i_op->getattr takes a struct path argument], + [-Werror]) +]) AC_DEFUN([LINUX_IOP_MKDIR_TAKES_UMODE_T], [ AC_CHECK_LINUX_BUILD([whether inode.i_op->mkdir takes a umode_t argument],