return rc;
}
-static int mgs_completion_ast_config(struct ldlm_lock *lock, __u64 flags,
- void *cbdata)
+enum ast_type {
+ AST_CONFIG = 1,
+ AST_PARAMS = 2,
+ AST_IR = 3
+};
+
+static int mgs_completion_ast_generic(struct ldlm_lock *lock, __u64 flags,
+ void *cbdata, enum ast_type type)
{
ENTRY;
if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
LDLM_FL_BLOCK_CONV))) {
- struct fs_db *fsdb;
+ struct fs_db *fsdb;
/* l_ast_data is used as a marker to avoid cancel ldlm lock
* twice. See LU-2317. */
if (fsdb != NULL) {
struct lustre_handle lockh;
- /* clear the bit before lock put */
- clear_bit(FSDB_REVOKING_LOCK, &fsdb->fsdb_flags);
+ switch(type) {
+ case AST_CONFIG:
+ /* clear the bit before lock put */
+ clear_bit(FSDB_REVOKING_LOCK,
+ &fsdb->fsdb_flags);
+ break;
+ case AST_PARAMS:
+ clear_bit(FSDB_REVOKING_PARAMS,
+ &fsdb->fsdb_flags);
+ break;
+ case AST_IR:
+ mgs_ir_notify_complete(fsdb);
+ break;
+ default:
+ LBUG();
+ }
ldlm_lock2handle(lock, &lockh);
ldlm_lock_decref_and_cancel(&lockh, LCK_EX);
RETURN(ldlm_completion_ast(lock, flags, cbdata));
}
-static int mgs_completion_ast_ir(struct ldlm_lock *lock, __u64 flags,
- void *cbdata)
+static int mgs_completion_ast_config(struct ldlm_lock *lock, __u64 flags,
+ void *cbdata)
{
- ENTRY;
-
- if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
- LDLM_FL_BLOCK_CONV))) {
- struct fs_db *fsdb;
-
- /* l_ast_data is used as a marker to avoid cancel ldlm lock
- * twice. See LU-1259. */
- lock_res_and_lock(lock);
- fsdb = (struct fs_db *)lock->l_ast_data;
- lock->l_ast_data = NULL;
- unlock_res_and_lock(lock);
-
- if (fsdb != NULL) {
- struct lustre_handle lockh;
-
- mgs_ir_notify_complete(fsdb);
+ return mgs_completion_ast_generic(lock, flags, cbdata, AST_CONFIG);
+}
- ldlm_lock2handle(lock, &lockh);
- ldlm_lock_decref_and_cancel(&lockh, LCK_EX);
- }
- }
+static int mgs_completion_ast_params(struct ldlm_lock *lock, __u64 flags,
+ void *cbdata)
+{
+ return mgs_completion_ast_generic(lock, flags, cbdata, AST_PARAMS);
+}
- RETURN(ldlm_completion_ast(lock, flags, cbdata));
+static int mgs_completion_ast_ir(struct ldlm_lock *lock, __u64 flags,
+ void *cbdata)
+{
+ return mgs_completion_ast_generic(lock, flags, cbdata, AST_IR);
}
void mgs_revoke_lock(struct mgs_device *mgs, struct fs_db *fsdb, int type)
{
- ldlm_completion_callback cp = NULL;
- struct lustre_handle lockh = { 0 };
- struct ldlm_res_id res_id;
+ ldlm_completion_callback cp = NULL;
+ struct lustre_handle lockh = { 0 };
+ struct ldlm_res_id res_id;
__u64 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);
+ int rc;
+ ENTRY;
- switch (type) {
- case CONFIG_T_CONFIG:
- cp = mgs_completion_ast_config;
+ 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 (test_and_set_bit(FSDB_REVOKING_LOCK, &fsdb->fsdb_flags))
- rc = -EALREADY;
- break;
- case CONFIG_T_RECOVER:
- cp = mgs_completion_ast_ir;
- default:
- break;
- }
+ rc = -EALREADY;
+ break;
+ case CONFIG_T_PARAMS:
+ cp = mgs_completion_ast_params;
+ if (test_and_set_bit(FSDB_REVOKING_PARAMS, &fsdb->fsdb_flags))
+ rc = -EALREADY;
+ break;
+ case CONFIG_T_RECOVER:
+ cp = mgs_completion_ast_ir;
+ default:
+ break;
+ }
- if (!rc) {
- LASSERT(cp != NULL);
+ if (!rc) {
+ LASSERT(cp != NULL);
rc = ldlm_cli_enqueue_local(mgs->mgs_obd->obd_namespace,
&res_id, LDLM_PLAIN, NULL, LCK_EX,
&flags, ldlm_blocking_ast, cp,
NULL, fsdb, 0, LVB_T_NONE, 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 (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)
+ if (type == CONFIG_T_CONFIG)
clear_bit(FSDB_REVOKING_LOCK,
- &fsdb->fsdb_flags);
- }
- /* lock has been cancelled in completion_ast. */
- }
+ &fsdb->fsdb_flags);
- RETURN_EXIT;
+ if (type == CONFIG_T_PARAMS)
+ clear_bit(FSDB_REVOKING_PARAMS,
+ &fsdb->fsdb_flags);
+ }
+ /* lock has been cancelled in completion_ast. */
+ }
+
+ RETURN_EXIT;
}
/* rc=0 means ok
RETURN(rc);
}
-/*
- * sec context handlers
- */
-/* XXX: Implement based on mdt_sec_ctx_handle()? */
-static int mgs_sec_ctx_handle(struct tgt_session_info *tsi)
-{
- return 0;
-}
-
static inline int mgs_init_export(struct obd_export *exp)
{
struct mgs_export_data *data = &exp->u.eu_mgs_data;
};
static struct tgt_handler mgs_dlm_handlers[] = {
-TGT_DLM_HDL(HABEO_CLAVIS, LDLM_ENQUEUE, tgt_enqueue),
+[LDLM_ENQUEUE - LDLM_FIRST_OPC] = {
+ .th_name = "LDLM_ENQUEUE",
+ /* don't use th_fail_id for MGS to don't interfere with MDS tests.
+ * * There are no tests for MGS with OBD_FAIL_LDLM_ENQUEUE_NET so it
+ * * is safe. If such tests will be needed we have to distinguish
+ * * MDS and MGS fail ids, e.g use OBD_FAIL_MGS_ENQUEUE_NET for MGS
+ * * instead of common OBD_FAIL_LDLM_ENQUEUE_NET */
+ .th_fail_id = 0,
+ .th_opc = LDLM_ENQUEUE,
+ .th_flags = HABEO_CLAVIS,
+ .th_act = tgt_enqueue,
+ .th_fmt = &RQF_LDLM_ENQUEUE,
+ .th_version = LUSTRE_DLM_VERSION,
+ },
};
static struct tgt_handler mgs_llog_handlers[] = {
TGT_LLOG_HDL (0, LLOG_ORIGIN_HANDLE_PREV_BLOCK, tgt_llog_prev_block),
};
-static struct tgt_handler mgs_sec_ctx_handlers[] = {
-TGT_SEC_HDL_VAR(0, SEC_CTX_INIT, mgs_sec_ctx_handle),
-TGT_SEC_HDL_VAR(0, SEC_CTX_INIT_CONT, mgs_sec_ctx_handle),
-TGT_SEC_HDL_VAR(0, SEC_CTX_FINI, mgs_sec_ctx_handle),
-};
-
static struct tgt_opc_slice mgs_common_slice[] = {
{
.tos_opc_start = MGS_FIRST_OPC,
{
.tos_opc_start = SEC_FIRST_OPC,
.tos_opc_end = SEC_LAST_OPC,
- .tos_hs = mgs_sec_ctx_handlers
+ .tos_hs = tgt_sec_ctx_handlers
},
{
.tos_hs = NULL