From: John L. Hammond Date: Thu, 8 Mar 2018 21:27:28 +0000 (-0600) Subject: LU-10785 llite: use xattr_handler name for ACLs X-Git-Tag: 2.11.51~39 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a9998927281647f9d9b8bfa50c80b7e15cf05eda;p=fs%2Flustre-release.git LU-10785 llite: use xattr_handler name for ACLs If struct xattr_handler has a name member then use it (rather than prefix) for the ACL xattrs. This avoids a bug where ACL operations failed for some kernels. Signed-off-by: John L. Hammond Change-Id: I28f6c5dbe3cdc4155e93d388d2c413092e02c082 Reviewed-on: https://review.whamcloud.com/31595 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f104079..6ef83ff 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2327,6 +2327,26 @@ key_payload_data_array, [ ]) #LC_HAVE_KEY_PAYLOAD_DATA_ARRAY # +# LC_HAVE_XATTR_HANDLER_NAME +# +# Kernel version 4.4 commit 98e9cb5711c68223f0e4d5201b9a6add255ec550 +# add a name member to struct xattr_handler +# +AC_DEFUN([LC_HAVE_XATTR_HANDLER_NAME], [ +tmp_flags="$EXTRA_KCFLAGS" +EXTRA_KCFLAGS="-Werror" +LB_CHECK_COMPILE([if 'struct xattr_handler' has a name member], +xattr_handler_name, [ + #include +],[ + ((struct xattr_handler *)NULL)->name = NULL; +],[ + AC_DEFINE(HAVE_XATTR_HANDLER_NAME, 1, [xattr_handler has a name member]) +]) +EXTRA_KCFLAGS="$tmp_flags" +]) # LC_HAVE_XATTR_HANDLER_NAME + +# # LC_HAVE_FILE_DENTRY # # 4.5 adds wrapper file_dentry @@ -2913,6 +2933,7 @@ AC_DEFUN([LC_PROG_LINUX], [ # 4.4 LC_HAVE_LOCKS_LOCK_FILE_WAIT LC_HAVE_KEY_PAYLOAD_DATA_ARRAY + LC_HAVE_XATTR_HANDLER_NAME LC_HAVE_BI_CNT LC_HAVE_BI_RW LC_HAVE_SUBMIT_BIO_2ARGS diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index b2c0407..ac1dd91 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -44,17 +44,25 @@ #include "llite_internal.h" +#ifndef HAVE_XATTR_HANDLER_NAME +static inline const char *xattr_prefix(const struct xattr_handler *handler) +{ + return handler->prefix; +} +#endif + const struct xattr_handler *get_xattr_type(const char *name) { - int i = 0; + int i; - while (ll_xattr_handlers[i]) { - size_t len = strlen(ll_xattr_handlers[i]->prefix); + for (i = 0; ll_xattr_handlers[i]; i++) { + const char *prefix = xattr_prefix(ll_xattr_handlers[i]); + size_t prefix_len = strlen(prefix); - if (!strncmp(ll_xattr_handlers[i]->prefix, name, len)) + if (!strncmp(prefix, name, prefix_len)) return ll_xattr_handlers[i]; - i++; } + return NULL; } @@ -143,7 +151,7 @@ static int ll_xattr_set_common(const struct xattr_handler *handler, RETURN(-EPERM); } - fullname = kasprintf(GFP_KERNEL, "%s%s", handler->prefix, name); + fullname = kasprintf(GFP_KERNEL, "%s%s", xattr_prefix(handler), name); if (!fullname) RETURN(-ENOMEM); @@ -453,7 +461,7 @@ static int ll_xattr_get_common(const struct xattr_handler *handler, RETURN(-ENODATA); #endif - fullname = kasprintf(GFP_KERNEL, "%s%s", handler->prefix, name); + fullname = kasprintf(GFP_KERNEL, "%s%s", xattr_prefix(handler), name); if (!fullname) RETURN(-ENOMEM); @@ -764,7 +772,11 @@ static const struct xattr_handler ll_security_xattr_handler = { }; static const struct xattr_handler ll_acl_access_xattr_handler = { +#ifdef HAVE_XATTR_HANDLER_NAME + .name = XATTR_NAME_POSIX_ACL_ACCESS, +#else .prefix = XATTR_NAME_POSIX_ACL_ACCESS, +#endif .flags = XATTR_ACL_ACCESS_T, #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED) .get = ll_xattr_get_common_4_3, @@ -779,7 +791,11 @@ static const struct xattr_handler ll_acl_access_xattr_handler = { }; static const struct xattr_handler ll_acl_default_xattr_handler = { +#ifdef HAVE_XATTR_HANDLER_NAME + .name = XATTR_NAME_POSIX_ACL_DEFAULT, +#else .prefix = XATTR_NAME_POSIX_ACL_DEFAULT, +#endif .flags = XATTR_ACL_DEFAULT_T, #if defined(HAVE_XATTR_HANDLER_SIMPLIFIED) .get = ll_xattr_get_common_4_3,