Whamcloud - gitweb
LU-506 kernel: FC15 - generic_permission() need 4 arguments.
authoryangsheng <ys@whamcloud.com>
Wed, 31 Aug 2011 15:27:32 +0000 (23:27 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 29 Dec 2011 15:43:57 +0000 (10:43 -0500)
generic_permission() add a new parameter flags to determine
if in rcu-walk case. it will return -ECHILD when rcu-walk
request cannot be satisfied. check_acl callback also changed
for this intention. So we don't need check it separately.

Change-Id: I15e0660f47c5db414dbb920f68177f310a185e4d
Signed-off-by: Yang Sheng <ys@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1843
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Lai Siyao <laisiyao@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/llite/file.c
lustre/llite/llite_internal.h

index 69371f7..2611478 100644 (file)
@@ -1659,18 +1659,19 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
 ])
 ])
 
-# 2.6.27
 
 
+#
+# 2.6.27
+#
 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
 [AC_MSG_CHECKING([inode_operations->permission has two args])
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
 ],[
         struct inode *inode;
 AC_DEFUN([LC_INODE_PERMISION_2ARGS],
 [AC_MSG_CHECKING([inode_operations->permission has two args])
 LB_LINUX_TRY_COMPILE([
         #include <linux/fs.h>
 ],[
         struct inode *inode;
-
-        inode->i_op->permission(NULL,0);
+        inode->i_op->permission(NULL, 0);
 ],[
 ],[
-        AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1, 
+        AC_DEFINE(HAVE_INODE_PERMISION_2ARGS, 1,
                   [inode_operations->permission has two args])
         AC_MSG_RESULT([yes])
 ],[
                   [inode_operations->permission has two args])
         AC_MSG_RESULT([yes])
 ],[
@@ -2125,7 +2126,26 @@ LB_LINUX_TRY_COMPILE([
         memset(rq.unplug_fn, 0, sizeof(rq.unplug_fn));
 ],[
         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
         memset(rq.unplug_fn, 0, sizeof(rq.unplug_fn));
 ],[
         AC_DEFINE(HAVE_REQUEST_QUEUE_UNPLUG_FN, 1,
-                  [request_queue has unplug_fn field]),
+                  [request_queue has unplug_fn field])
+        AC_MSG_RESULT([yes])
+],[
+        AC_MSG_RESULT([no])
+])
+])
+
+#
+# 2.6.38 generic_permission taken 4 paremater.
+# in fact, it means rcu-walk aware permission bring.
+#
+AC_DEFUN([LC_GENERIC_PERMISSION],
+[AC_MSG_CHECKING([if generic_permission take 4 arguments])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/fs.h>
+],[
+        generic_permission(NULL, 0, 0, NULL);
+],[
+        AC_DEFINE(HAVE_GENERIC_PERMISSION_4ARGS, 1,
+                  [generic_permission taken 4 arguments])
         AC_MSG_RESULT([yes])
 ],[
         AC_MSG_RESULT([no])
         AC_MSG_RESULT([yes])
 ],[
         AC_MSG_RESULT([no])
@@ -2240,9 +2260,9 @@ AC_DEFUN([LC_PROG_LINUX],
          LC_VM_OP_FAULT
          LC_PROCFS_USERS
          LC_EXPORTFS_DECODE_FH
          LC_VM_OP_FAULT
          LC_PROCFS_USERS
          LC_EXPORTFS_DECODE_FH
-  
-        # 2.6.24
-        LC_HAVE_MMTYPES_H
+
+         # 2.6.24
+         LC_HAVE_MMTYPES_H
          LC_BIO_ENDIO_2ARG
          LC_FH_TO_DENTRY
          LC_PROCFS_DELETED
          LC_BIO_ENDIO_2ARG
          LC_FH_TO_DENTRY
          LC_PROCFS_DELETED
@@ -2250,7 +2270,7 @@ AC_DEFUN([LC_PROG_LINUX],
 
          #2.6.25
          LC_MAPPING_CAP_WRITEBACK_DIRTY
 
          #2.6.25
          LC_MAPPING_CAP_WRITEBACK_DIRTY
-  
+
          # 2.6.26
          LC_FS_STRUCT_USE_PATH
 
          # 2.6.26
          LC_FS_STRUCT_USE_PATH
 
@@ -2290,6 +2310,7 @@ AC_DEFUN([LC_PROG_LINUX],
 
          # 2.6.38
          LC_BLKDEV_GET_BY_DEV
 
          # 2.6.38
          LC_BLKDEV_GET_BY_DEV
+         LC_GENERIC_PERMISSION
 
          # 2.6.39
          LC_REQUEST_QUEUE_UNPLUG_FN
 
          # 2.6.39
          LC_REQUEST_QUEUE_UNPLUG_FN
index ecaa8eb..8324e20 100644 (file)
@@ -197,6 +197,14 @@ do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
 #define ll_permission(inode,mask,nd)    permission(inode,mask,nd)
 #endif
 
 #define ll_permission(inode,mask,nd)    permission(inode,mask,nd)
 #endif
 
+#ifdef HAVE_GENERIC_PERMISSION_4ARGS
+#define ll_generic_permission(inode, mask, flags, check_acl) \
+        generic_permission(inode, mask, flags, check_acl)
+#else
+#define ll_generic_permission(inode, mask, flags, check_acl) \
+        generic_permission(inode, mask, check_acl)
+#endif
+
 #define ll_pgcache_lock(mapping)          cfs_spin_lock(&mapping->page_lock)
 #define ll_pgcache_unlock(mapping)        cfs_spin_unlock(&mapping->page_lock)
 #define ll_call_writepage(inode, page)  \
 #define ll_pgcache_lock(mapping)          cfs_spin_lock(&mapping->page_lock)
 #define ll_pgcache_unlock(mapping)        cfs_spin_unlock(&mapping->page_lock)
 #define ll_call_writepage(inode, page)  \
index 0f2f8d3..d8ba5c9 100644 (file)
@@ -2440,8 +2440,12 @@ int ll_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 #endif
 
 
 #endif
 
 
-static
-int lustre_check_acl(struct inode *inode, int mask)
+static int
+#ifdef HAVE_GENERIC_PERMISSION_4ARGS
+lustre_check_acl(struct inode *inode, int mask, unsigned int flags)
+#else
+lustre_check_acl(struct inode *inode, int mask)
+#endif
 {
 #ifdef CONFIG_FS_POSIX_ACL
         struct ll_inode_info *lli = ll_i2info(inode);
 {
 #ifdef CONFIG_FS_POSIX_ACL
         struct ll_inode_info *lli = ll_i2info(inode);
@@ -2449,6 +2453,10 @@ int lustre_check_acl(struct inode *inode, int mask)
         int rc;
         ENTRY;
 
         int rc;
         ENTRY;
 
+#ifdef HAVE_GENERIC_PERMISSION_4ARGS
+        if (flags & IPERM_FLAG_RCU)
+                return -ECHILD;
+#endif
         cfs_spin_lock(&lli->lli_lock);
         acl = posix_acl_dup(lli->lli_posix_acl);
         cfs_spin_unlock(&lli->lli_lock);
         cfs_spin_lock(&lli->lli_lock);
         acl = posix_acl_dup(lli->lli_posix_acl);
         cfs_spin_unlock(&lli->lli_lock);
@@ -2465,11 +2473,14 @@ int lustre_check_acl(struct inode *inode, int mask)
 #endif
 }
 
 #endif
 }
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
-#ifndef HAVE_INODE_PERMISION_2ARGS
-int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
+#ifdef HAVE_GENERIC_PERMISSION_4ARGS
+int ll_inode_permission(struct inode *inode, int mask, unsigned int flags)
 #else
 #else
+# ifdef HAVE_INODE_PERMISION_2ARGS
 int ll_inode_permission(struct inode *inode, int mask)
 int ll_inode_permission(struct inode *inode, int mask)
+# else
+int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
+# endif
 #endif
 {
         int rc = 0;
 #endif
 {
         int rc = 0;
@@ -2494,61 +2505,10 @@ int ll_inode_permission(struct inode *inode, int mask)
                 return lustre_check_remote_perm(inode, mask);
 
         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1);
                 return lustre_check_remote_perm(inode, mask);
 
         ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1);
-        rc = generic_permission(inode, mask, lustre_check_acl);
+        rc = ll_generic_permission(inode, mask, flags, lustre_check_acl);
 
         RETURN(rc);
 }
 
         RETURN(rc);
 }
-#else
-int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd)
-{
-        int mode = inode->i_mode;
-        int rc;
-
-        CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p), mask %o\n",
-               inode->i_ino, inode->i_generation, inode, mask);
-
-        if (ll_i2sbi(inode)->ll_flags & LL_SBI_RMT_CLIENT)
-                return lustre_check_remote_perm(inode, mask);
-
-        ll_stats_ops_tally(ll_i2sbi(inode), LPROC_LL_INODE_PERM, 1);
-
-        if ((mask & MAY_WRITE) && IS_RDONLY(inode) &&
-            (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)))
-                return -EROFS;
-        if ((mask & MAY_WRITE) && IS_IMMUTABLE(inode))
-                return -EACCES;
-        if (cfs_curproc_fsuid() == inode->i_uid) {
-                mode >>= 6;
-        } else if (1) {
-                if (((mode >> 3) & mask & S_IRWXO) != mask)
-                        goto check_groups;
-                rc = lustre_check_acl(inode, mask);
-                if (rc == -EAGAIN)
-                        goto check_groups;
-                if (rc == -EACCES)
-                        goto check_capabilities;
-                return rc;
-        } else {
-check_groups:
-                if (cfs_curproc_is_in_groups(inode->i_gid))
-                        mode >>= 3;
-        }
-        if ((mode & mask & S_IRWXO) == mask)
-                return 0;
-
-check_capabilities:
-        if (!(mask & MAY_EXEC) ||
-            (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode))
-                if (cfs_capable(CFS_CAP_DAC_OVERRIDE))
-                        return 0;
-
-        if (cfs_capable(CFS_CAP_DAC_READ_SEARCH) && ((mask == MAY_READ) ||
-            (S_ISDIR(inode->i_mode) && !(mask & MAY_WRITE))))
-                return 0;
-
-        return -EACCES;
-}
-#endif
 
 #ifdef HAVE_FILE_READV
 #define READ_METHOD readv
 
 #ifdef HAVE_FILE_READV
 #define READ_METHOD readv
index 7b89ca9..a3274ec 100644 (file)
@@ -675,10 +675,14 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
                struct lookup_intent *it, struct kstat *stat);
 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
 struct ll_file_data *ll_file_data_get(void);
                struct lookup_intent *it, struct kstat *stat);
 int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
 struct ll_file_data *ll_file_data_get(void);
-#ifndef HAVE_INODE_PERMISION_2ARGS
-int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
+#ifdef HAVE_GENERIC_PERMISSION_4ARGS
+int ll_inode_permission(struct inode *inode, int mask, unsigned int flags);
 #else
 #else
+# ifndef HAVE_INODE_PERMISION_2ARGS
+int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
+# else
 int ll_inode_permission(struct inode *inode, int mask);
 int ll_inode_permission(struct inode *inode, int mask);
+# endif
 #endif
 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
                              int flags, struct lov_user_md *lum,
 #endif
 int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
                              int flags, struct lov_user_md *lum,