From 9e31c0dcfc351c76b22dcde05087857484859124 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 21 Jun 2017 17:37:04 -0400 Subject: [PATCH] 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 Reviewed-on: https://review.whamcloud.com/27715 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Dmitry Eremin Reviewed-by: Bob Glossman --- lustre/autoconf/lustre-core.m4 | 21 +++++++++++++++++++++ lustre/llite/file.c | 8 ++++++++ lustre/llite/llite_internal.h | 5 +++++ lustre/tests/kernel/kinode.c | 4 +++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 236bd77..bc593c4 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2633,6 +2633,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 @@ -2872,6 +2892,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 3a66cab..2607591 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -3785,8 +3785,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 0d709cf..4957a06 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); #ifdef HAVE_IOP_SET_ACL #ifdef CONFIG_FS_POSIX_ACL 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); -- 1.8.3.1