@@ -43,6 +43,14 @@
int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld);
+/* this timeout represents how many seconds MGC should wait before
+ * requeue config and recover lock to the MGS. We need to randomize this
+ * in order to not flood the MGS.
+ */
+#define MGC_TIMEOUT_MIN_SECONDS 5
+
+extern unsigned int mgc_requeue_timeout_min;
+
static inline bool cld_is_sptlrpc(struct config_llog_data *cld)
{
return cld->cld_type == MGS_CFG_T_SPTLRPC;
@@ -530,13 +530,6 @@ static void do_requeue(struct config_llog_data *cld)
up_read(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem);
}
-/* this timeout represents how many seconds MGC should wait before
- * requeue config and recover lock to the MGS. We need to randomize this
- * in order to not flood the MGS.
- */
-#define MGC_TIMEOUT_MIN_SECONDS 5
-#define MGC_TIMEOUT_RAND_CENTISEC 500
-
static int mgc_requeue_thread(void *data)
{
bool first = true;
@@ -548,7 +541,6 @@ static int mgc_requeue_thread(void *data)
rq_state |= RQ_RUNNING;
while (!(rq_state & RQ_STOP)) {
struct config_llog_data *cld, *cld_prev;
- int rand = prandom_u32_max(MGC_TIMEOUT_RAND_CENTISEC);
int to;
/* Any new or requeued lostlocks will change the state */
@@ -565,11 +557,11 @@ static int mgc_requeue_thread(void *data)
* random so everyone doesn't try to reconnect at once.
*/
/* rand is centi-seconds, "to" is in centi-HZ */
- to = MGC_TIMEOUT_MIN_SECONDS * HZ * 100;
- to += rand * HZ;
+ to = mgc_requeue_timeout_min == 0 ? 1 : mgc_requeue_timeout_min;
+ to = mgc_requeue_timeout_min * HZ + prandom_u32_max(to * HZ);
wait_event_idle_timeout(rq_waitq,
rq_state & (RQ_STOP | RQ_PRECLEANUP),
- to/100);
+ to);
/*
* iterate & processing through the list. for each cld, process
@@ -1835,6 +1827,36 @@ static int mgc_process_config(struct obd_device *obd, u32 len, void *buf)
.process_config = mgc_process_config,
};
+static int mgc_param_requeue_timeout_min_set(const char *val,
+ const struct kernel_param *kp)
+{
+ int rc;
+ unsigned int num;
+
+ rc = kstrtouint(val, 0, &num);
+ if (rc < 0)
+ return rc;
+ if (num > 120)
+ return -EINVAL;
+
+ mgc_requeue_timeout_min = num;
+
+ return 0;
+}
+
+static struct kernel_param_ops param_ops_requeue_timeout_min = {
+ .set = mgc_param_requeue_timeout_min_set,
+ .get = param_get_uint,
+};
+
+#define param_check_requeue_timeout_min(name, p) \
+ __param_check(name, p, unsigned int)
+
+unsigned int mgc_requeue_timeout_min = MGC_TIMEOUT_MIN_SECONDS;
+module_param_call(mgc_requeue_timeout_min, mgc_param_requeue_timeout_min_set,
+ param_get_uint, ¶m_ops_requeue_timeout_min, 0644);
+MODULE_PARM_DESC(mgc_requeue_timeout_min, "Minimal requeue time to refresh logs");
+
static int __init mgc_init(void)
{
int rc;