}
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;
}
/********************** config llog list **********************/
-static CFS_LIST_HEAD(config_llog_list);
+static struct list_head config_llog_list = LIST_HEAD_INIT(config_llog_list);
static DEFINE_SPINLOCK(config_list_lock);
/* Take a reference to a config log */
/* spinlock to make sure no item with 0 refcount in the list */
if (atomic_dec_and_lock(&cld->cld_refcount, &config_list_lock)) {
- cfs_list_del(&cld->cld_list_chain);
+ list_del(&cld->cld_list_chain);
spin_unlock(&config_list_lock);
CDEBUG(D_MGC, "dropping config log %s\n", cld->cld_logname);
instance = cfg ? cfg->cfg_instance : NULL;
spin_lock(&config_list_lock);
- cfs_list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
+ list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
/* check if instance equals */
if (instance != cld->cld_cfg.cfg_instance)
continue;
rc = mgc_logname2resid(logname, &cld->cld_resid, type);
spin_lock(&config_list_lock);
- cfs_list_add(&cld->cld_list_chain, &config_llog_list);
+ list_add(&cld->cld_list_chain, &config_llog_list);
spin_unlock(&config_list_lock);
if (rc) {
*ptr = 0;
}
else {
- CERROR("sptlrpc log name not correct: %s", seclogname);
+ CERROR("%s: sptlrpc log name not correct, %s: "
+ "rc = %d\n", obd->obd_name, seclogname, -EINVAL);
config_log_put(cld);
RETURN(-EINVAL);
}
#ifdef LPROCFS
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 config_llog_data *cld;
- ENTRY;
+ struct obd_device *obd = data;
+ struct obd_import *imp;
+ struct obd_connect_data *ocd;
+ struct config_llog_data *cld;
+ ENTRY;
+
+ LASSERT(obd != NULL);
+ 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");
spin_lock(&config_list_lock);
- cfs_list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
+ list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
if (cld->cld_recover == NULL)
continue;
seq_printf(m, " - { client: %s, nidtbl_version: %u }\n",
}
spin_unlock(&config_list_lock);
+ LPROCFS_CLIMP_EXIT(obd);
RETURN(0);
}
#endif
/* reenqueue any lost locks */
-#define RQ_RUNNING 0x1
-#define RQ_NOW 0x2
-#define RQ_LATER 0x4
-#define RQ_STOP 0x8
+#define RQ_RUNNING 0x1
+#define RQ_NOW 0x2
+#define RQ_LATER 0x4
+#define RQ_STOP 0x8
+#define RQ_PRECLEANUP 0x10
static int rq_state = 0;
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)
{
static int mgc_requeue_thread(void *data)
{
- int rc = 0;
- ENTRY;
+ int rc = 0;
+ bool first = true;
+ ENTRY;
- CDEBUG(D_MGC, "Starting requeue thread\n");
+ CDEBUG(D_MGC, "Starting requeue thread\n");
- /* Keep trying failed locks periodically */
+ /* Keep trying failed locks periodically */
spin_lock(&config_list_lock);
rq_state |= RQ_RUNNING;
while (1) {
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 */
+ to = msecs_to_jiffies(MGC_TIMEOUT_MIN_SECONDS * MSEC_PER_SEC);
+ /* rand is centi-seconds */
+ to += msecs_to_jiffies(rand * MSEC_PER_SEC / 100);
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
cld_prev = NULL;
spin_lock(&config_list_lock);
- cfs_list_for_each_entry(cld, &config_llog_list,
+ rq_state &= ~RQ_PRECLEANUP;
+ list_for_each_entry(cld, &config_llog_list,
cld_list_chain) {
if (!cld->cld_lostlock)
continue;
/* The mgc fs exclusion mutex. Only one fs can be setup at a time. */
mutex_lock(&cli->cl_mgc_mutex);
- cfs_cleanup_group_info();
-
/* Setup the configs dir */
rc = lu_env_init(env, LCT_MG_THREAD);
if (rc)
static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
{
int rc = 0;
+ int temp;
ENTRY;
switch (stage) {
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)
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
- int rc;
+ struct task_struct *task;
+ int rc;
ENTRY;
rc = ptlrpcd_addref();
#ifdef LPROCFS
obd->obd_vars = lprocfs_mgc_obd_vars;
- lprocfs_seq_obd_setup(obd);
+ lprocfs_obd_setup(obd);
#endif
sptlrpc_lprocfs_cliobd_attach(obd);
init_waitqueue_head(&rq_waitq);
/* start requeue thread */
- rc = PTR_ERR(kthread_run(mgc_requeue_thread, NULL,
- "ll_cfg_requeue"));
- if (IS_ERR_VALUE(rc)) {
- CERROR("%s: Cannot start requeue thread (%d),"
- "no more log updates!\n",
+ task = kthread_run(mgc_requeue_thread, NULL, "ll_cfg_requeue");
+ if (IS_ERR(task)) {
+ rc = PTR_ERR(task);
+ CERROR("%s: cannot start requeue thread: rc = %d; "
+ "no more log updates\n",
obd->obd_name, rc);
GOTO(err_cleanup, rc);
}
/* rc is the task_struct pointer of mgc_requeue_thread. */
rc = 0;
+ wait_for_completion(&rq_start);
}
RETURN(rc);
}
/* Not sure where this should go... */
-#define MGC_ENQUEUE_LIMIT 50
+/* This is the timeout value for MGS_CONNECT request plus a ping interval, such
+ * that we can have a chance to try the secondary MGS if any. */
+#define MGC_ENQUEUE_LIMIT (INITIAL_CONNECT_TIMEOUT + (AT_OFF ? 0 : at_min) \
+ + PING_INTERVAL)
#define MGC_TARGET_REG_LIMIT 10
#define MGC_SEND_PARAM_LIMIT 10
RETURN(rc);
}
-int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
- obd_count keylen, void *key, obd_count vallen,
- void *val, struct ptlrpc_request_set *set)
+static int mgc_set_info_async(const struct lu_env *env, struct obd_export *exp,
+ obd_count keylen, void *key, obd_count vallen,
+ void *val, struct ptlrpc_request_set *set)
{
int rc = -EINVAL;
ENTRY;
while (datalen > 0) {
int entry_len = sizeof(*entry);
- int is_ost;
+ int is_ost, i;
struct obd_device *obd;
char *obdname;
char *cname;
continue;
}
- /* TODO: iterate all nids to find one */
- /* find uuid by nid */
- rc = client_import_find_conn(obd->u.cli.cl_import,
- entry->u.nids[0],
- (struct obd_uuid *)uuid);
+ /* iterate all nids to find one */
+ /* find uuid by nid */
+ rc = -ENOENT;
+ for (i = 0; i < entry->mne_nid_count; i++) {
+ rc = client_import_find_conn(obd->u.cli.cl_import,
+ entry->u.nids[i],
+ (struct obd_uuid *)uuid);
+ if (rc == 0)
+ break;
+ }
+
up_read(&obd->u.cli.cl_sem);
if (rc < 0) {
CERROR("mgc: cannot find uuid by nid %s\n",
lustre_cfg_bufs_set_string(&bufs, 1, params);
- rc = -ENOMEM;
- lcfg = lustre_cfg_new(LCFG_PARAM, &bufs);
- if (lcfg == NULL) {
- CERROR("mgc: cannot allocate memory\n");
- break;
- }
+ lcfg = lustre_cfg_new(LCFG_PARAM, &bufs);
+ if (lcfg == NULL) {
+ rc = -ENOMEM;
+ break;
+ }
CDEBUG(D_INFO, "ir apply logs "LPD64"/"LPD64" for %s -> %s\n",
prev_version, max_version, obdname, params);
GOTO(out, rc = ealen);
if (ealen > nrpages << PAGE_CACHE_SHIFT)
- GOTO(out, rc = -EINVAL);
+ GOTO(out, rc = -EINVAL);
- if (ealen == 0) { /* no logs transferred */
- if (!eof)
- rc = -EINVAL;
- GOTO(out, rc);
- }
+ if (ealen == 0) { /* no logs transferred */
+ if (!eof)
+ rc = -EINVAL;
+ GOTO(out, rc);
+ }
mne_swab = !!ptlrpc_rep_need_swab(req);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 2, 50, 0)
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
/* This import flag means the server did an extra swab of IR MNE
* records (fixed in LU-1252), reverse it here if needed. LU-1644 */
if (unlikely(req->rq_import->imp_need_mne_swab))
mne_swab = !mne_swab;
-#else
-#warning "LU-1644: Remove old OBD_CONNECT_MNE_SWAB fixup and imp_need_mne_swab"
#endif
- for (i = 0; i < nrpages && ealen > 0; i++) {
- int rc2;
- void *ptr;
+ for (i = 0; i < nrpages && ealen > 0; i++) {
+ int rc2;
+ void *ptr;
ptr = kmap(pages[i]);
rc2 = mgc_apply_recover_logs(obd, cld, res->mcr_offset, ptr,
rc = mgc_llog_local_copy(env, mgc, ctxt, lctxt,
cld->cld_logname);
if (local_only || rc) {
- if (llog_is_empty(env, lctxt, cld->cld_logname)) {
+ if (strcmp(cld->cld_logname, PARAMS_FILENAME) != 0 &&
+ llog_is_empty(env, lctxt, cld->cld_logname)) {
LCONSOLE_ERROR_MSG(0x13a, "Failed to get MGS "
"log %s and no local copy."
"\n", cld->cld_logname);
CDEBUG(D_MGC, "Failed to get MGS log %s, using local "
"copy for now, will try to update later.\n",
cld->cld_logname);
+ rc = 0;
}
/* Now, whether we copied or not, start using the local llog.
* If we failed to copy, we'll start using whatever the old
if (rc == 0 && cld->cld_params != NULL) {
rc = mgc_process_log(obd, cld->cld_params);
if (rc == -ENOENT) {
- CDEBUG(D_MGC, "There is no params"
+ CDEBUG(D_MGC, "There is no params "
"config file yet\n");
rc = 0;
}
RETURN(rc);
}
-struct obd_ops mgc_obd_ops = {
+static struct obd_ops mgc_obd_ops = {
.o_owner = THIS_MODULE,
.o_setup = mgc_setup,
.o_precleanup = mgc_precleanup,
.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,
-#ifndef HAVE_ONLY_PROCFS_SEQ
- NULL,
-#endif
- LUSTRE_MGC_NAME, NULL);
+ return class_register_type(&mgc_obd_ops, NULL, true, NULL,
+ LUSTRE_MGC_NAME, NULL);
}
-#ifdef __KERNEL__
static void /*__exit*/ mgc_exit(void)
{
class_unregister_type(LUSTRE_MGC_NAME);
module_init(mgc_init);
module_exit(mgc_exit);
-#endif