Whamcloud - gitweb
LU-11429 mdt: rename mdt_remote_permission
[fs/lustre-release.git] / lustre / mdt / mdt_reint.c
index cb77f69..69bb85a 100644 (file)
@@ -217,7 +217,7 @@ static int mdt_lookup_version_check(struct mdt_thread_info *info,
 
 }
 
-static inline int mdt_remote_permission_check(struct mdt_thread_info *info)
+static inline int mdt_remote_dir_permission_check(struct mdt_thread_info *info)
 {
        struct lu_ucred *uc  = mdt_ucred(info);
        struct mdt_device *mdt = info->mti_mdt;
@@ -232,7 +232,7 @@ static inline int mdt_remote_permission_check(struct mdt_thread_info *info)
 }
 
 /**
- * mdt_remote_permission: Check whether the remote operation is permitted,
+ * mdt_remote_dir_permission: Check whether the remote operation is permitted,
  *
  * Only sysadmin can create remote directory / striped directory,
  * migrate directory and set default stripedEA on directory, unless
@@ -244,7 +244,7 @@ static inline int mdt_remote_permission_check(struct mdt_thread_info *info)
  * retval      = 0 remote operation is allowed.
  *              < 0 remote operation is denied.
  */
-int mdt_remote_permission(struct mdt_thread_info *info)
+int mdt_remote_dir_permission(struct mdt_thread_info *info)
 {
        struct md_op_spec *spec = &info->mti_spec;
        struct lu_attr *attr = &info->mti_attr.ma_attr;
@@ -252,7 +252,7 @@ int mdt_remote_permission(struct mdt_thread_info *info)
        int rc;
 
        if (info->mti_rr.rr_opcode == REINT_MIGRATE) {
-               rc = mdt_remote_permission_check(info);
+               rc = mdt_remote_dir_permission_check(info);
                if (rc != 0)
                        return rc;
        }
@@ -271,7 +271,7 @@ int mdt_remote_permission(struct mdt_thread_info *info)
                    !mdt_is_striped_client(exp))
                        return -ENOTSUPP;
 
-               rc = mdt_remote_permission_check(info);
+               rc = mdt_remote_dir_permission_check(info);
                if (rc != 0)
                        return rc;
        }
@@ -280,7 +280,7 @@ int mdt_remote_permission(struct mdt_thread_info *info)
                struct md_attr *ma = &info->mti_attr;
 
                if ((ma->ma_valid & MA_LMV)) {
-                       rc = mdt_remote_permission_check(info);
+                       rc = mdt_remote_dir_permission_check(info);
                        if (rc != 0)
                                return rc;
                }
@@ -474,7 +474,7 @@ static int mdt_create(struct mdt_thread_info *info)
        if (unlikely(IS_ERR(child)))
                GOTO(unlock_parent, rc = PTR_ERR(child));
 
-       rc = mdt_remote_permission(info);
+       rc = mdt_remote_dir_permission(info);
        if (rc != 0)
                GOTO(put_child, rc);
 
@@ -638,6 +638,8 @@ out_unlock:
 int mdt_add_dirty_flag(struct mdt_thread_info *info, struct mdt_object *mo,
                        struct md_attr *ma)
 {
+       struct lu_ucred *uc = mdt_ucred(info);
+       cfs_cap_t cap_saved;
        int rc;
        ENTRY;
 
@@ -655,7 +657,12 @@ int mdt_add_dirty_flag(struct mdt_thread_info *info, struct mdt_object *mo,
            && !(ma->ma_hsm.mh_flags & (HS_DIRTY|HS_RELEASED))) {
                ma->ma_hsm.mh_flags |= HS_DIRTY;
 
+               /* Bump cap so that closes from non-owner writers can
+                * set the HSM state to dirty. */
+               cap_saved = uc->uc_cap;
+               uc->uc_cap |= MD_CAP_TO_MASK(CFS_CAP_FOWNER);
                rc = mdt_hsm_attr_set(info, mo, &ma->ma_hsm);
+               uc->uc_cap = cap_saved;
                if (rc)
                        CERROR("file attribute change error for "DFID": %d\n",
                                PFID(mdt_object_fid(mo)), rc);
@@ -752,7 +759,7 @@ static int mdt_reint_setattr(struct mdt_thread_info *info,
                struct lu_buf *buf  = &info->mti_buf;
                struct mdt_lock_handle  *lh;
 
-               rc = mdt_remote_permission(info);
+               rc = mdt_remote_dir_permission(info);
                if (rc < 0)
                        GOTO(out_put, rc);
 
@@ -1243,8 +1250,9 @@ static int mdt_pdir_hash_lock(struct mdt_thread_info *info,
         * going to be sent to client. If it is - mdt_intent_policy() path will
         * fix it up and turn FL_LOCAL flag off.
         */
-       rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy,
-                         res, dlmflags, &info->mti_exp->exp_handle.h_cookie);
+       rc = mdt_fid_lock(info->mti_env, ns, &lh->mlh_reg_lh, lh->mlh_reg_mode,
+                         policy, res, dlmflags,
+                         &info->mti_exp->exp_handle.h_cookie);
        return rc;
 }
 
@@ -1284,12 +1292,13 @@ static int mdt_rename_lock(struct mdt_thread_info *info,
                memset(policy, 0, sizeof *policy);
                policy->l_inodebits.bits = MDS_INODELOCK_UPDATE;
                flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
-               rc = ldlm_cli_enqueue_local(ns, res_id, LDLM_IBITS, policy,
-                                          LCK_EX, &flags, ldlm_blocking_ast,
-                                          ldlm_completion_ast, NULL, NULL, 0,
-                                          LVB_T_NONE,
-                                          &info->mti_exp->exp_handle.h_cookie,
-                                          lh);
+               rc = ldlm_cli_enqueue_local(info->mti_env, ns, res_id,
+                                           LDLM_IBITS, policy, LCK_EX, &flags,
+                                           ldlm_blocking_ast,
+                                           ldlm_completion_ast, NULL, NULL, 0,
+                                           LVB_T_NONE,
+                                           &info->mti_exp->exp_handle.h_cookie,
+                                           lh);
                RETURN(rc);
        }
        RETURN(rc);
@@ -1355,8 +1364,9 @@ static int mdt_revoke_remote_lookup_lock(struct mdt_thread_info *info,
                fid_build_reg_res_name(mdt_object_fid(obj), res);
                memset(policy, 0, sizeof(*policy));
                policy->l_inodebits.bits = MDS_INODELOCK_LOOKUP;
-               rc = mdt_fid_lock(info->mti_mdt->mdt_namespace, &lh->mlh_reg_lh,
-                                 LCK_EX, policy, res, dlmflags, NULL);
+               rc = mdt_fid_lock(info->mti_env, info->mti_mdt->mdt_namespace,
+                                 &lh->mlh_reg_lh, LCK_EX, policy, res,
+                                 dlmflags, NULL);
        }
 
        if (rc != ELDLM_OK)
@@ -1982,7 +1992,7 @@ static int mdt_reint_migrate_internal(struct mdt_thread_info *info)
        if (lu_name_is_dot_or_dotdot(&rr->rr_name))
                RETURN(-EBUSY);
 
-       rc = mdt_remote_permission(info);
+       rc = mdt_remote_dir_permission(info);
        if (rc)
                RETURN(rc);
 
@@ -2661,7 +2671,7 @@ static int mdt_reint_resync(struct mdt_thread_info *info,
        if (mdt_object_remote(mo))
                GOTO(out_obj, rc = -EREMOTE);
 
-       lease = ldlm_handle2lock(rr->rr_handle);
+       lease = ldlm_handle2lock(rr->rr_lease_handle);
        if (lease == NULL)
                GOTO(out_obj, rc = -ESTALE);