Whamcloud - gitweb
LU-3569 ofd: packing ost_idx in IDIF
[fs/lustre-release.git] / lustre / mdt / mdt_xattr.c
index f7c5f60..1abef7e 100644 (file)
@@ -220,9 +220,9 @@ out:
 
 int mdt_getxattr(struct mdt_thread_info *info)
 {
-        struct ptlrpc_request  *req = mdt_info_req(info);
-        struct mdt_export_data *med = mdt_req2med(req);
-       struct lu_ucred        *uc  = mdt_ucred(info);
+       struct ptlrpc_request  *req = mdt_info_req(info);
+       struct mdt_export_data *med = mdt_req2med(req);
+       struct lu_ucred        *uc  = lu_ucred(info->mti_env);
         struct mdt_body        *reqbody;
         struct mdt_body        *repbody = NULL;
         struct md_object       *next;
@@ -357,8 +357,8 @@ _out:
 int mdt_reint_setxattr(struct mdt_thread_info *info,
                        struct mdt_lock_handle *unused)
 {
-        struct ptlrpc_request   *req = mdt_info_req(info);
-       struct lu_ucred         *uc  = mdt_ucred(info);
+       struct ptlrpc_request   *req = mdt_info_req(info);
+       struct lu_ucred         *uc  = lu_ucred(info->mti_env);
         struct mdt_lock_handle  *lh;
         const struct lu_env     *env  = info->mti_env;
         struct lu_buf           *buf  = &info->mti_buf;
@@ -368,7 +368,7 @@ int mdt_reint_setxattr(struct mdt_thread_info *info,
         struct mdt_object       *obj;
         struct md_object        *child;
         __u64                    valid = attr->la_valid;
-        const char              *xattr_name = rr->rr_name;
+       const char              *xattr_name = rr->rr_name.ln_name;
         int                      xattr_len = rr->rr_eadatalen;
         __u64                    lockpart;
         int                      rc;
@@ -398,29 +398,39 @@ int mdt_reint_setxattr(struct mdt_thread_info *info,
 
                perm = mdt_identity_get_perm(uc->uc_identity, remote,
                                             req->rq_peer.nid);
-                if (!(perm & CFS_RMTACL_PERM))
-                        GOTO(out, rc = err_serious(-EPERM));
-        }
+               if (!(perm & CFS_RMTACL_PERM))
+                       GOTO(out, rc = err_serious(-EPERM));
+       }
 
-        if (strncmp(xattr_name, XATTR_USER_PREFIX,
-                    sizeof(XATTR_USER_PREFIX) - 1) == 0) {
+       if (strncmp(xattr_name, XATTR_USER_PREFIX,
+                   sizeof(XATTR_USER_PREFIX) - 1) == 0) {
                if (!(exp_connect_flags(req->rq_export) & OBD_CONNECT_XATTR))
                        GOTO(out, rc = -EOPNOTSUPP);
-                if (strcmp(xattr_name, XATTR_NAME_LOV) == 0)
-                        GOTO(out, rc = -EACCES);
-                if (strcmp(xattr_name, XATTR_NAME_LMA) == 0)
-                        GOTO(out, rc = 0);
-                if (strcmp(xattr_name, XATTR_NAME_LINK) == 0)
-                        GOTO(out, rc = 0);
-        } else if ((valid & OBD_MD_FLXATTR) &&
-                   (strncmp(xattr_name, XATTR_NAME_ACL_ACCESS,
-                            sizeof(XATTR_NAME_ACL_ACCESS) - 1) == 0 ||
-                    strncmp(xattr_name, XATTR_NAME_ACL_DEFAULT,
-                            sizeof(XATTR_NAME_ACL_DEFAULT) - 1) == 0)) {
-                /* currently lustre limit acl access size */
-                if (xattr_len > LUSTRE_POSIX_ACL_MAX_SIZE)
-                        GOTO(out, -ERANGE);
-        }
+       } else if (strncmp(xattr_name, XATTR_TRUSTED_PREFIX,
+                   sizeof(XATTR_TRUSTED_PREFIX) - 1) == 0) {
+
+               if (!md_capable(mdt_ucred(info), CFS_CAP_SYS_ADMIN))
+                       GOTO(out, rc = -EPERM);
+
+               if (strcmp(xattr_name, XATTR_NAME_LOV) == 0 ||
+                   strcmp(xattr_name, XATTR_NAME_LMA) == 0 ||
+                   strcmp(xattr_name, XATTR_NAME_LMV) == 0 ||
+                   strcmp(xattr_name, XATTR_NAME_LINK) == 0 ||
+                   strcmp(xattr_name, XATTR_NAME_FID) == 0 ||
+                   strcmp(xattr_name, XATTR_NAME_VERSION) == 0 ||
+                   strcmp(xattr_name, XATTR_NAME_SOM) == 0 ||
+                   strcmp(xattr_name, XATTR_NAME_HSM) == 0 ||
+                   strcmp(xattr_name, XATTR_NAME_LFSCK_NAMESPACE) == 0)
+                       GOTO(out, rc = 0);
+       } else if ((valid & OBD_MD_FLXATTR) &&
+                  (strncmp(xattr_name, XATTR_NAME_ACL_ACCESS,
+                           sizeof(XATTR_NAME_ACL_ACCESS) - 1) == 0 ||
+                   strncmp(xattr_name, XATTR_NAME_ACL_DEFAULT,
+                           sizeof(XATTR_NAME_ACL_DEFAULT) - 1) == 0)) {
+               /* currently lustre limit acl access size */
+               if (xattr_len > LUSTRE_POSIX_ACL_MAX_SIZE)
+                       GOTO(out, rc = -ERANGE);
+       }
 
         lockpart = MDS_INODELOCK_UPDATE;
         /* Revoke all clients' lookup lock, since the access
@@ -445,10 +455,10 @@ int mdt_reint_setxattr(struct mdt_thread_info *info,
         if (IS_ERR(obj))
                 GOTO(out, rc =  PTR_ERR(obj));
 
-        info->mti_mos = obj;
-        rc = mdt_version_get_check_save(info, obj, 0);
-        if (rc)
-                GOTO(out_unlock, rc);
+       tgt_vbr_obj_set(env, mdt_obj2dt(obj));
+       rc = mdt_version_get_check_save(info, obj, 0);
+       if (rc)
+               GOTO(out_unlock, rc);
 
        if (unlikely(!(valid & OBD_MD_FLCTIME))) {
                /* This isn't strictly an error, but all current clients