Whamcloud - gitweb
LU-14121 nodemap: do not force fsuid/fsgid squashing
[fs/lustre-release.git] / lustre / mdt / mdt_lib.c
index 24bc1e8..be2531a 100644 (file)
@@ -214,9 +214,6 @@ static int new_init_ucred(struct mdt_thread_info *info, ucred_init_type_t type,
                        RETURN(-EACCES);
                }
 
-               ucred->uc_fsuid = nodemap->nm_squash_uid;
-               ucred->uc_fsgid = nodemap->nm_squash_gid;
-               ucred->uc_cap = 0;
                ucred->uc_suppgids[0] = -1;
                ucred->uc_suppgids[1] = -1;
        }
@@ -318,13 +315,18 @@ static int new_init_ucred(struct mdt_thread_info *info, ucred_init_type_t type,
 
        ucred->uc_uid = pud->pud_uid;
        ucred->uc_gid = pud->pud_gid;
+
+       if (nodemap && ucred->uc_o_uid == nodemap->nm_squash_uid) {
+               ucred->uc_cap = 0;
+       } else {
+               ucred->uc_cap = pud->pud_cap;
+       }
        ucred->uc_fsuid = pud->pud_fsuid;
        ucred->uc_fsgid = pud->pud_fsgid;
 
        /* process root_squash here. */
        mdt_root_squash(info, peernid);
 
-       ucred->uc_cap = pud->pud_cap;
        ucred->uc_valid = UCRED_NEW;
        ucred_set_jobid(info, ucred);
        ucred_set_nid(info, ucred);
@@ -469,8 +471,6 @@ static int old_init_ucred_common(struct mdt_thread_info *info,
                if (nodemap->nmf_deny_unknown)
                        RETURN(-EACCES);
 
-               uc->uc_fsuid = nodemap->nm_squash_uid;
-               uc->uc_fsgid = nodemap->nm_squash_gid;
                uc->uc_cap = 0;
                uc->uc_suppgids[0] = -1;
                uc->uc_suppgids[1] = -1;
@@ -1884,29 +1884,6 @@ static int mdt_fids_different_target(struct mdt_thread_info *info,
        return index1 != index2;
 }
 
-static bool mdt_object_is_shard(struct mdt_thread_info *info,
-                               struct mdt_object *obj)
-{
-       struct lmv_mds_md_v1 *lmv = (struct lmv_mds_md_v1 *)info->mti_xattr_buf;
-       struct lu_buf buf;
-       int rc;
-
-       if (!mdt_object_exists(obj))
-               return false;
-
-       if (!S_ISDIR(lu_object_attr(&obj->mot_obj)))
-               return false;
-
-       buf.lb_buf = lmv;
-       buf.lb_len = sizeof(*lmv);
-       rc = mo_xattr_get(info->mti_env, mdt_object_child(obj), &buf,
-                         XATTR_NAME_LMV);
-       if (rc < 0)
-               return false;
-
-       return lmv->lmv_magic == cpu_to_le32(LMV_MAGIC_STRIPE);
-}
-
 /**
  * Check whether \a child is remote object on \a parent.
  *
@@ -1939,14 +1916,8 @@ int mdt_is_remote_object(struct mdt_thread_info *info,
                RETURN(0);
 
        if (likely(parent != child)) {
-               if (mdt_object_remote(parent) ^ mdt_object_remote(child)) {
-                       /* don't treat shard as remote object, otherwise client
-                        * need to revalidate shards all the time.
-                        */
-                       if (mdt_object_is_shard(info, child))
-                               RETURN(0);
+               if (mdt_object_remote(parent) ^ mdt_object_remote(child))
                        RETURN(1);
-               }
 
                if (!mdt_object_remote(parent) && !mdt_object_remote(child))
                        RETURN(0);