diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/mgc/mgc_request.c')
-rw-r--r-- | drivers/staging/lustre/lustre/mgc/mgc_request.c | 60 |
1 files changed, 38 insertions, 22 deletions
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 60d2b0f..7947aec 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -95,7 +95,7 @@ int mgc_fsname2resid(char *fsname, struct ldlm_res_id *res_id, int type) } EXPORT_SYMBOL(mgc_fsname2resid); -int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id, int type) +static int mgc_logname2resid(char *logname, struct ldlm_res_id *res_id, int type) { char *name_end; int len; @@ -160,7 +160,7 @@ struct config_llog_data *config_log_find(char *logname, { struct config_llog_data *cld; struct config_llog_data *found = NULL; - void * instance; + void *instance; LASSERT(logname != NULL); @@ -452,10 +452,14 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) { struct obd_device *obd = data; - struct obd_import *imp = obd->u.cli.cl_import; - struct obd_connect_data *ocd = &imp->imp_connect_data; + struct obd_import *imp; + struct obd_connect_data *ocd; struct config_llog_data *cld; + LPROCFS_CLIMP_CHECK(obd); + imp = obd->u.cli.cl_import; + ocd = &imp->imp_connect_data; + seq_printf(m, "imperative_recovery: %s\n", OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED"); seq_printf(m, "client_state:\n"); @@ -470,6 +474,7 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) } spin_unlock(&config_list_lock); + LPROCFS_CLIMP_EXIT(obd); return 0; } #endif @@ -479,9 +484,11 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data) #define RQ_NOW 0x2 #define RQ_LATER 0x4 #define RQ_STOP 0x8 -static int rq_state = 0; +#define RQ_PRECLEANUP 0x10 +static int rq_state; static wait_queue_head_t rq_waitq; static DECLARE_COMPLETION(rq_exit); +static DECLARE_COMPLETION(rq_start); static void do_requeue(struct config_llog_data *cld) { @@ -510,6 +517,8 @@ static void do_requeue(struct config_llog_data *cld) static int mgc_requeue_thread(void *data) { + bool first = true; + CDEBUG(D_MGC, "Starting requeue thread\n"); /* Keep trying failed locks periodically */ @@ -526,13 +535,19 @@ static int mgc_requeue_thread(void *data) rq_state &= ~(RQ_NOW | RQ_LATER); spin_unlock(&config_list_lock); + if (first) { + first = false; + complete(&rq_start); + } + /* Always wait a few seconds to allow the server who caused the lock revocation to finish its setup, plus some random so everyone doesn't try to reconnect at once. */ to = MGC_TIMEOUT_MIN_SECONDS * HZ; to += rand * HZ / 100; /* rand is centi-seconds */ lwi = LWI_TIMEOUT(to, NULL, NULL); - l_wait_event(rq_waitq, rq_state & RQ_STOP, &lwi); + l_wait_event(rq_waitq, rq_state & (RQ_STOP | RQ_PRECLEANUP), + &lwi); /* * iterate & processing through the list. for each cld, process @@ -545,6 +560,7 @@ static int mgc_requeue_thread(void *data) cld_prev = NULL; spin_lock(&config_list_lock); + rq_state &= ~RQ_PRECLEANUP; list_for_each_entry(cld, &config_llog_list, cld_list_chain) { if (!cld->cld_lostlock) @@ -661,24 +677,26 @@ static atomic_t mgc_count = ATOMIC_INIT(0); static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; + int temp; switch (stage) { case OBD_CLEANUP_EARLY: break; case OBD_CLEANUP_EXPORTS: if (atomic_dec_and_test(&mgc_count)) { - int running; + LASSERT(rq_state & RQ_RUNNING); /* stop requeue thread */ - spin_lock(&config_list_lock); - running = rq_state & RQ_RUNNING; - if (running) - rq_state |= RQ_STOP; - spin_unlock(&config_list_lock); - if (running) { - wake_up(&rq_waitq); - wait_for_completion(&rq_exit); - } + temp = RQ_STOP; + } else { + /* wakeup requeue thread to clean our cld */ + temp = RQ_NOW | RQ_PRECLEANUP; } + spin_lock(&config_list_lock); + rq_state |= temp; + spin_unlock(&config_list_lock); + wake_up(&rq_waitq); + if (temp & RQ_STOP) + wait_for_completion(&rq_exit); obd_cleanup_client_import(obd); rc = mgc_llog_fini(NULL, obd); if (rc != 0) @@ -690,8 +708,6 @@ static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) static int mgc_cleanup(struct obd_device *obd) { - int rc; - /* COMPAT_146 - old config logs may have added profiles we don't know about */ if (obd->obd_type->typ_refcnt <= 1) @@ -701,8 +717,7 @@ static int mgc_cleanup(struct obd_device *obd) lprocfs_obd_cleanup(obd); ptlrpcd_decref(); - rc = client_obd_cleanup(obd); - return rc; + return client_obd_cleanup(obd); } static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -740,6 +755,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) } /* rc is the task_struct pointer of mgc_requeue_thread. */ rc = 0; + wait_for_completion(&rq_start); } return rc; @@ -951,7 +967,7 @@ static int mgc_target_register(struct obd_export *exp, return rc; } -int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, +static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp, u32 keylen, void *key, u32 vallen, void *val, struct ptlrpc_request_set *set) { @@ -1727,7 +1743,7 @@ struct obd_ops mgc_obd_ops = { .o_process_config = mgc_process_config, }; -int __init mgc_init(void) +static int __init mgc_init(void) { return class_register_type(&mgc_obd_ops, NULL, NULL, LUSTRE_MGC_NAME, NULL); |