Whamcloud - gitweb
LU-2850 compat: posix_acl_{to,from}_xattr take user_namespace
authorJeff Mahoney <jeffm@suse.com>
Wed, 20 Mar 2013 21:33:17 +0000 (17:33 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 7 Jun 2013 04:00:35 +0000 (00:00 -0400)
Commit 5f3a4a28 (v3.7) added a struct user_namespace argument to
posix_acl_{to,from}_xattr. Pretty much every caller just uses
&init_user_ns. We mask it off in user mode so we don't need to
create a fake structure only to ignore it.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Change-Id: I558a06941b364f241fd4423720957beeaf1d3cea
Reviewed-on: http://review.whamcloud.com/5768
Tested-by: Hudson
Reviewed-by: Alexey Shvetsov <alexxy@gentoo.org>
Reviewed-by: Peng Tao <bergwolf@gmail.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
libcfs/include/libcfs/darwin/darwin-fs.h
libcfs/include/libcfs/linux/linux-fs.h
lustre/autoconf/lustre-core.m4
lustre/include/liblustre.h
lustre/llite/xattr.c
lustre/mdc/mdc_request.c

index 998823b..9f71d6a 100644 (file)
@@ -171,11 +171,13 @@ struct posix_acl {
 };
 
 struct posix_acl *posix_acl_alloc(int count, int flags);
-static inline struct posix_acl *posix_acl_from_xattr(const void *value, 
+static inline struct posix_acl *posix_acl_from_xattr(const void *value,
                                                      size_t size)
-{ 
+{
         return posix_acl_alloc(0, 0);
 }
+#define posix_acl_from_xattr(a,b,c) posix_acl_from_xattr(b,c)
+
 static inline void posix_acl_release(struct posix_acl *acl) {};
 static inline int posix_acl_valid(const struct posix_acl *acl) { return 0; }
 static inline struct posix_acl * posix_acl_dup(struct posix_acl *acl) 
index 53975ab..fa4e4d4 100644 (file)
@@ -53,6 +53,7 @@
 #include <linux/stat.h>
 #include <linux/mount.h>
 #include <linux/backing-dev.h>
+#include <linux/posix_acl_xattr.h>
 
 #define filp_size(f)                                   \
        (i_size_read((f)->f_dentry->d_inode))
@@ -102,4 +103,13 @@ ssize_t filp_user_write(struct file *filp, const void *buf, size_t count,
 #define DTTOIF(dirtype)                ((dirtype) << IFSHIFT)
 #endif
 
+#ifndef HAVE_POSIXACL_USER_NS
+/*
+ * Mask out &init_user_ns so we don't jump
+ * through hoops to define it somehow only
+ * to have it ignored anyway.
+ */
+#define posix_acl_from_xattr(a,b,c)    posix_acl_from_xattr(b,c)
+#define posix_acl_to_xattr(a,b,c,d)    posix_acl_to_xattr(b,c,d)
+#endif
 #endif
index 8f92859..067090f 100644 (file)
@@ -2233,6 +2233,25 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# 3.7 posix_acl_{to,from}_xattr take struct user_namespace
+#
+AC_DEFUN([LC_HAVE_POSIXACL_USER_NS],
+[AC_MSG_CHECKING([if posix_acl_to_xattr takes struct user_namespace])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/fs.h>
+       #include <linux/posix_acl_xattr.h>
+],[
+       posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
+],[
+       AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
+                 [posix_acl_to_xattr takes struct user_namespace])
+       AC_MSG_RESULT([yes])
+],[
+       AC_MSG_RESULT([no])
+])
+])
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2414,6 +2433,8 @@ AC_DEFUN([LC_PROG_LINUX],
         LC_DENTRY_OPEN_USE_PATH
         LC_HAVE_IOP_ATOMIC_OPEN
 
+        # 3.7
+        LC_HAVE_POSIXACL_USER_NS
         #
         if test x$enable_server = xyes ; then
                AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
index b93d805..ad88587 100644 (file)
@@ -458,6 +458,10 @@ struct posix_acl * posix_acl_from_xattr(const void *value, size_t size)
         return NULL;
 }
 
+/* The kernel version takes 3 arguments, so strip that off first. */
+#define posix_acl_from_xattr(a,b,c)    posix_acl_from_xattr(b,c)
+#define posix_acl_to_xattr(a,b,c)      posix_acl_to_xattr(b,c)
+
 static inline
 int posix_acl_valid(const struct posix_acl *acl)
 {
index 8772b74..a08c58a 100644 (file)
@@ -345,7 +345,7 @@ int ll_getxattr_common(struct inode *inode, const char *name,
                 if (!acl)
                         RETURN(-ENODATA);
 
-                rc = posix_acl_to_xattr(acl, buffer, size);
+                rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
                 posix_acl_release(acl);
                 RETURN(rc);
         }
index c9df432..6534511 100644 (file)
@@ -41,6 +41,7 @@
 # include <linux/pagemap.h>
 # include <linux/miscdevice.h>
 # include <linux/init.h>
+# include <linux/utsname.h>
 #else
 # include <liblustre.h>
 #endif
@@ -470,7 +471,7 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
         if (!buf)
                 RETURN(-EPROTO);
 
-        acl = posix_acl_from_xattr(buf, body->aclsize);
+        acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize);
         if (IS_ERR(acl)) {
                 rc = PTR_ERR(acl);
                 CERROR("convert xattr to acl: %d\n", rc);