static int mdt_rename_lock(struct mdt_thread_info *info,
struct lustre_handle *lh)
{
- struct ldlm_namespace *ns = info->mti_mdt->mdt_namespace;
- ldlm_policy_data_t *policy = &info->mti_policy;
- struct ldlm_res_id *res_id = &info->mti_res_id;
- __u64 flags = 0;
- struct seq_server_site *ss;
- int rc;
- ENTRY;
+ struct ldlm_namespace *ns = info->mti_mdt->mdt_namespace;
+ ldlm_policy_data_t *policy = &info->mti_policy;
+ struct ldlm_res_id *res_id = &info->mti_res_id;
+ __u64 flags = 0;
+ int rc;
+ ENTRY;
- ss = mdt_seq_site(info->mti_mdt);
fid_build_reg_res_name(&LUSTRE_BFL_FID, res_id);
- memset(policy, 0, sizeof *policy);
- policy->l_inodebits.bits = MDS_INODELOCK_UPDATE;
-
- if (ss->ss_control_exp == NULL) {
- flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
-
- /*
- * Current node is controller, that is mdt0, where we should
- * take BFL lock.
- */
- 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);
- } else {
- struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_EX,
- ldlm_blocking_ast, ldlm_completion_ast, NULL, NULL, NULL };
-
- /*
- * This is the case mdt0 is remote node, issue DLM lock like
- * other clients.
- */
- rc = ldlm_cli_enqueue(ss->ss_control_exp, NULL, &einfo, res_id,
- policy, &flags, NULL, 0, LVB_T_NONE, lh,
- 0);
- }
-
+ memset(policy, 0, sizeof *policy);
+ policy->l_inodebits.bits = MDS_INODELOCK_UPDATE;
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 4, 53, 0)
+ /* In phase I, we will not do cross-rename, so local BFL lock would
+ * be enough
+ */
+ flags = LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB;
+ /*
+ * Current node is controller, that is mdt0, where we should
+ * take BFL lock.
+ */
+ 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);
+#else
+#warning "Local rename lock is invalid for DNE phase II."
+#endif
RETURN(rc);
}
PFID(rr->rr_fid1), rr->rr_name,
PFID(rr->rr_fid2), rr->rr_tgt);
- rc = mdt_rename_lock(info, &rename_lh);
- if (rc) {
- CERROR("Can't lock FS for rename, rc %d\n", rc);
- RETURN(rc);
- }
+ if (!lu_fid_eq(rr->rr_fid1, rr->rr_fid2)) {
+ rc = mdt_rename_lock(info, &rename_lh);
+ if (rc) {
+ CERROR("Can't lock FS for rename, rc %d\n", rc);
+ RETURN(rc);
+ }
+ }
lh_newp = &info->mti_lh[MDT_LH_NEW];
out_unlock_source:
mdt_object_unlock_put(info, msrcdir, lh_srcdirp, rc);
out_rename_lock:
- mdt_rename_unlock(&rename_lh);
- return rc;
+ if (lustre_handle_is_used(&rename_lh))
+ mdt_rename_unlock(&rename_lh);
+ return rc;
}
typedef int (*mdt_reinter)(struct mdt_thread_info *info,