From: James Simmons Date: Wed, 21 Jun 2017 21:37:04 +0000 (-0400) Subject: LU-9558 llite: user enhanced getattr functionality in newer kernels X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F15%2F27715%2F2;p=fs%2Flustre-release.git LU-9558 llite: user enhanced getattr functionality in newer kernels Starting with the linux kernel 4.11 a new system call was added to enhance the file info available. This new functionality has changed the getattr functions in the linux kernel. This patch only provides the most basic support for now. Linux-commit: a528d35e8bfcc521d7cb70aaf03e1bd296c8493f Change-Id: Iee1b02bb94dab05a3197866af9eedd6f35cac7c5 Signed-off-by: James Simmons --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f1ed50a..b0be846 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2492,6 +2492,26 @@ vm_fault_address, [ ]) # LC_HAVE_VM_FAULT_ADDRESS # +# LC_INODEOPS_ENHANCED_GETATTR +# +# Kernel version 4.11 commit a528d35e8bfcc521d7cb70aaf03e1bd296c8493f +# expanded getattr to be able to get more stat information. +# +AC_DEFUN([LC_INODEOPS_ENHANCED_GETATTR], [ +LB_CHECK_COMPILE([if 'inode_operations' getattr member can gather advance stats], +getattr_path, [ + #include +],[ + struct path path; + + ((struct inode_operations *)1)->getattr(&path, NULL, 0, 0); +],[ + AC_DEFINE(HAVE_INODEOPS_ENHANCED_GETATTR, 1, + [inode_operations .getattr member function can gather advance stats]) +]) +]) # LC_INODEOPS_ENHANCED_GETATTR + +# # LC_VM_OPERATIONS_REMOVE_VMF_ARG # # Kernel version 4.11 commit 11bac80004499ea59f361ef2a5516c84b6eab675 @@ -2723,6 +2743,7 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_HAVE_VM_FAULT_ADDRESS # 4.11 + LC_INODEOPS_ENHANCED_GETATTR LC_VM_OPERATIONS_REMOVE_VMF_ARG # diff --git a/lustre/llite/file.c b/lustre/llite/file.c index d6591f5..a1b2c56 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -3796,8 +3796,16 @@ static inline dev_t ll_compat_encode_dev(dev_t dev) return MKDEV(MAJOR(dev) & 0xff, MINOR(dev) & 0xff); } +#ifdef HAVE_INODEOPS_ENHANCED_GETATTR +int ll_getattr(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int flags) + +{ + struct dentry *de = path->dentry; +#else int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat) { +#endif struct inode *inode = de->d_inode; struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_inode_info *lli = ll_i2info(inode); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 4737a27..fedeea0 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -822,7 +822,12 @@ int ll_md_real_close(struct inode *inode, fmode_t fmode); extern void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid, struct ll_file_data *file, loff_t pos, size_t count, int rw); +#ifdef HAVE_INODEOPS_ENHANCED_GETATTR +int ll_getattr(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int flags); +#else int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat); +#endif struct posix_acl *ll_get_acl(struct inode *inode, int type); int ll_migrate(struct inode *parent, struct file *file, int mdtidx, const char *name, int namelen); diff --git a/lustre/tests/kernel/kinode.c b/lustre/tests/kernel/kinode.c index 0283c8e..26052e7 100644 --- a/lustre/tests/kernel/kinode.c +++ b/lustre/tests/kernel/kinode.c @@ -63,7 +63,9 @@ static int stat_file(struct kstat *stbuf) return -EIO; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) +#ifdef HAVE_INODEOPS_ENHANCED_GETATTR + rc = vfs_getattr(&fd->f_path, stbuf, STATX_INO, AT_STATX_SYNC_AS_STAT); +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0) rc = vfs_getattr(&fd->f_path, stbuf); #else rc = vfs_getattr(fd->f_path.mnt, fd->f_path.dentry, stbuf);