Whamcloud - gitweb
LU-12043 llite: switch to use ll_fsname directly
[fs/lustre-release.git] / lustre / llite / xattr.c
index b2c0407..3958dd6 100644 (file)
 
 #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);
 
@@ -335,7 +343,6 @@ int ll_xattr_list(struct inode *inode, const char *name, int type, void *buffer,
        struct ll_inode_info *lli = ll_i2info(inode);
         struct ll_sb_info *sbi = ll_i2sbi(inode);
         struct ptlrpc_request *req = NULL;
-        struct mdt_body *body;
         void *xdata;
        int rc;
        ENTRY;
@@ -367,30 +374,20 @@ getxattr_nocache:
                if (rc < 0)
                        GOTO(out_xattr, rc);
 
-               body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
-               LASSERT(body);
-
                /* only detect the xattr size */
                if (size == 0)
-                       GOTO(out, rc = body->mbo_eadatasize);
+                       GOTO(out, rc);
 
-               if (size < body->mbo_eadatasize) {
-                       CERROR("server bug: replied size %u > %u\n",
-                               body->mbo_eadatasize, (int)size);
+               if (size < rc)
                        GOTO(out, rc = -ERANGE);
-               }
-
-               if (body->mbo_eadatasize == 0)
-                       GOTO(out, rc = -ENODATA);
 
                /* do not need swab xattr data */
                xdata = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA,
-                                                       body->mbo_eadatasize);
+                                                    rc);
                if (!xdata)
-                       GOTO(out, rc = -EFAULT);
+                       GOTO(out, rc = -EPROTO);
 
-               memcpy(buffer, xdata, body->mbo_eadatasize);
-               rc = body->mbo_eadatasize;
+               memcpy(buffer, xdata, rc);
        }
 
        EXIT;
@@ -398,8 +395,8 @@ getxattr_nocache:
 out_xattr:
        if (rc == -EOPNOTSUPP && type == XATTR_USER_T) {
                LCONSOLE_INFO("%s: disabling user_xattr feature because "
-                               "it is not supported on the server: rc = %d\n",
-                               ll_get_fsname(inode->i_sb, NULL, 0), rc);
+                             "it is not supported on the server: rc = %d\n",
+                             sbi->ll_fsname, rc);
                sbi->ll_flags &= ~LL_SBI_USER_XATTR;
        }
 out:
@@ -453,7 +450,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 +761,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 +780,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,