#include <linux/module.h>
#include <linux/kthread.h>
+#include <linux/random.h>
#include <dt_object.h>
#include <lprocfs_status.h>
EXPORT_SYMBOL(mgc_logname2resid);
/********************** config llog list **********************/
-static struct list_head config_llog_list = LIST_HEAD_INIT(config_llog_list);
+static LIST_HEAD(config_llog_list);
static DEFINE_SPINLOCK(config_list_lock); /* protects config_llog_list */
/* Take a reference to a config log */
return ERR_PTR(rc);
}
-DEFINE_MUTEX(llog_process_lock);
-
static inline void config_mark_cld_stop(struct config_llog_data *cld)
{
if (cld) {
* in order to not flood the MGS.
*/
#define MGC_TIMEOUT_MIN_SECONDS 5
-#define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 */
+#define MGC_TIMEOUT_RAND_CENTISEC 500
static int mgc_requeue_thread(void *data)
{
while (!(rq_state & RQ_STOP)) {
struct l_wait_info lwi;
struct config_llog_data *cld, *cld_prev;
- int rand = cfs_rand() & MGC_TIMEOUT_RAND_CENTISEC;
+ int rand = prandom_u32_max(MGC_TIMEOUT_RAND_CENTISEC);
int to;
/* Any new or requeued lostlocks will change the state */
/* 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 = msecs_to_jiffies(MGC_TIMEOUT_MIN_SECONDS * MSEC_PER_SEC);
+ to = cfs_time_seconds(MGC_TIMEOUT_MIN_SECONDS * 100 + rand);
/* rand is centi-seconds */
- to += msecs_to_jiffies(rand * MSEC_PER_SEC / 100);
- lwi = LWI_TIMEOUT(to, NULL, NULL);
+ lwi = LWI_TIMEOUT(to / 100, NULL, NULL);
l_wait_event(rq_waitq, rq_state & (RQ_STOP | RQ_PRECLEANUP),
&lwi);
- /*
- * iterate & processing through the list. for each cld, process
- * its depending sptlrpc cld firstly (if any) and then itself.
- *
- * it's guaranteed any item in the list must have
- * reference > 0; and if cld_lostlock is set, at
- * least one reference is taken by the previous enqueue.
- */
- cld_prev = NULL;
+ /*
+ * iterate & processing through the list. for each cld, process
+ * its depending sptlrpc cld firstly (if any) and then itself.
+ *
+ * it's guaranteed any item in the list must have
+ * reference > 0; and if cld_lostlock is set, at
+ * least one reference is taken by the previous enqueue.
+ */
+ cld_prev = NULL;
spin_lock(&config_list_lock);
rq_state &= ~RQ_PRECLEANUP;
config_log_put(cld_prev);
/* Wait a bit to see if anyone else needs a requeue */
- lwi = (struct l_wait_info) { 0 };
- l_wait_event(rq_waitq, rq_state & (RQ_NOW | RQ_STOP),
- &lwi);
+ wait_event_idle(rq_waitq, rq_state & (RQ_NOW | RQ_STOP));
spin_lock(&config_list_lock);
}
char *inst;
char *buf;
int bufsz;
- int pos;
+ int pos = 0;
int rc = 0;
int off = 0;
OBD_FREE(inst, PAGE_SIZE);
return -E2BIG;
}
+#ifdef HAVE_SERVER_SUPPORT
} else {
LASSERT(IS_MDT(lsi));
rc = server_name2svname(lsi->lsi_svname, inst, NULL,
RETURN(-EINVAL);
}
pos = strlen(inst);
- }
+#endif /* HAVE_SERVER_SUPPORT */
+ }
++pos;
buf = inst + pos;
&cld->cld_cfg);
/*
- * update settings on existing OBDs. doing it inside
- * of llog_process_lock so no device is attaching/detaching
- * in parallel.
+ * update settings on existing OBDs.
* the logname must be <fsname>-sptlrpc
*/
if (rc == 0 && cld_is_sptlrpc(cld))
atomic_read(&mgc->u.cli.cl_mgc_refcount) > 0 && !retry) {
struct obd_import *imp;
struct l_wait_info lwi;
- int secs = cfs_time_seconds(obd_timeout);
+ long timeout = cfs_time_seconds(obd_timeout);
mutex_unlock(&cld->cld_lock);
imp = class_exp2cliimp(mgc->u.cli.cl_mgc_mgsexp);
* FULL or closed */
ptlrpc_pinger_force(imp);
- lwi = LWI_TIMEOUT(secs, NULL, NULL);
+ lwi = LWI_TIMEOUT(timeout, NULL, NULL);
l_wait_event(imp->imp_recovery_waitq,
!mgc_import_in_recovery(imp), &lwi);