From: Jeff Mahoney Date: Wed, 20 Mar 2013 21:33:17 +0000 (-0400) Subject: LU-2850 compat: posix_acl_{to,from}_xattr take user_namespace X-Git-Tag: 2.4.51~40 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=357de3461d95f693d416e380dd4963533f44ea25 LU-2850 compat: posix_acl_{to,from}_xattr take user_namespace 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 Change-Id: I558a06941b364f241fd4423720957beeaf1d3cea Reviewed-on: http://review.whamcloud.com/5768 Tested-by: Hudson Reviewed-by: Alexey Shvetsov Reviewed-by: Peng Tao Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons --- diff --git a/libcfs/include/libcfs/darwin/darwin-fs.h b/libcfs/include/libcfs/darwin/darwin-fs.h index 998823b..9f71d6a 100644 --- a/libcfs/include/libcfs/darwin/darwin-fs.h +++ b/libcfs/include/libcfs/darwin/darwin-fs.h @@ -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) diff --git a/libcfs/include/libcfs/linux/linux-fs.h b/libcfs/include/libcfs/linux/linux-fs.h index 53975ab..fa4e4d4 100644 --- a/libcfs/include/libcfs/linux/linux-fs.h +++ b/libcfs/include/libcfs/linux/linux-fs.h @@ -53,6 +53,7 @@ #include #include #include +#include #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 diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 8f92859..067090f 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -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 + #include +],[ + 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]) diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index b93d805..ad88587 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -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) { diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 8772b74..a08c58a 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -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); } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index c9df432..6534511 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -41,6 +41,7 @@ # include # include # include +# include #else # include #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);