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; int rc; ENTRY; fid_build_reg_res_name(&LUSTRE_BFL_FID, res_id); 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); }
void mgs_revoke_lock(struct obd_device *obd, struct fs_db *fsdb, int type) { ldlm_completion_callback cp = NULL; struct lustre_handle lockh = { 0 }; struct ldlm_res_id res_id; int flags = LDLM_FL_ATOMIC_CB; int rc; ENTRY; LASSERT(fsdb->fsdb_name[0] != '\0'); rc = mgc_fsname2resid(fsdb->fsdb_name, &res_id, type); LASSERT(rc == 0); switch (type) { case CONFIG_T_CONFIG: cp = mgs_completion_ast_config; if (cfs_test_and_set_bit(FSDB_REVOKING_LOCK, &fsdb->fsdb_flags)) rc = -EALREADY; break; case CONFIG_T_RECOVER: cp = mgs_completion_ast_ir; default: break; } if (!rc) { LASSERT(cp != NULL); rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_PLAIN, NULL, LCK_EX, &flags, ldlm_blocking_ast, cp, NULL, fsdb, 0, NULL, &lockh); if (rc != ELDLM_OK) { CERROR("can't take cfg lock for "LPX64"/"LPX64"(%d)\n", le64_to_cpu(res_id.name[0]), le64_to_cpu(res_id.name[1]), rc); if (type == CONFIG_T_CONFIG) cfs_clear_bit(FSDB_REVOKING_LOCK, &fsdb->fsdb_flags); } /* lock has been cancelled in completion_ast. */ } RETURN_EXIT; }
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; struct md_site *ms; int rc; ENTRY; ms = mdt_md_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 (ms->ms_control_exp == NULL) { int 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, &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 }; int flags = 0; /* * This is the case mdt0 is remote node, issue DLM lock like * other clients. */ rc = ldlm_cli_enqueue(ms->ms_control_exp, NULL, &einfo, res_id, policy, &flags, NULL, 0, lh, 0); } RETURN(rc); }