Whamcloud - gitweb
LU-9558 llite: user enhanced getattr functionality in newer kernels 15/27715/3
authorJames Simmons <uja.ornl@yahoo.com>
Wed, 21 Jun 2017 21:37:04 +0000 (17:37 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 1 Aug 2017 05:34:34 +0000 (05:34 +0000)
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 <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/27715
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
lustre/autoconf/lustre-core.m4
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/tests/kernel/kinode.c

index 236bd77..bc593c4 100644 (file)
@@ -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 <linux/fs.h>
+],[
+       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
 
        #
index 3a66cab..2607591 100644 (file)
@@ -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);
index 0d709cf..4957a06 100644 (file)
@@ -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
index 0283c8e..26052e7 100644 (file)
@@ -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);