Whamcloud - gitweb
LU-9558 llite: user enhanced getattr functionality in newer kernels 15/27715/2
authorJames Simmons <uja.ornl@yahoo.com>
Wed, 21 Jun 2017 21:37:04 +0000 (17:37 -0400)
committerJames Simmons <uja.ornl@yahoo.com>
Wed, 21 Jun 2017 21:37:04 +0000 (17:37 -0400)
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>
lustre/autoconf/lustre-core.m4
lustre/llite/file.c
lustre/llite/llite_internal.h
lustre/tests/kernel/kinode.c

index f1ed50a..b0be846 100644 (file)
@@ -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 <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
@@ -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
 
        #
index d6591f5..a1b2c56 100644 (file)
@@ -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);
index 4737a27..fedeea0 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);
 int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
               const char *name, int namelen);
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);