aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2016-01-21 10:33:19 -0500
committerIlya Dryomov <idryomov@gmail.com>2016-03-25 13:51:39 -0400
commit168b9090c739c4b5556023a3f08789b349ca7339 (patch)
treea39d7d7d5d11eff31834fb492c719f5520f6cdc4
parent58d81b1294f02262a141687cd62529c1ec8e6484 (diff)
libceph: monc hunt rate is 3s with backoff up to 30s
Unless we are in the process of setting up a client (i.e. connecting to the monitor cluster for the first time), apply a backoff: every time we want to reopen a session, increase our timeout by a multiple (currently 2); when we complete the connection, reduce that multipler by 50%. Mirrors ceph.git commit 794c86fd289bd62a35ed14368fa096c46736e9a2. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r--include/linux/ceph/libceph.h3
-rw-r--r--include/linux/ceph/mon_client.h3
-rw-r--r--net/ceph/mon_client.c25
3 files changed, 22 insertions, 9 deletions
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h
index f5466273b9a3..e7975e4681e1 100644
--- a/include/linux/ceph/libceph.h
+++ b/include/linux/ceph/libceph.h
@@ -68,8 +68,11 @@ struct ceph_options {
68#define CEPH_OSD_KEEPALIVE_DEFAULT msecs_to_jiffies(5 * 1000) 68#define CEPH_OSD_KEEPALIVE_DEFAULT msecs_to_jiffies(5 * 1000)
69#define CEPH_OSD_IDLE_TTL_DEFAULT msecs_to_jiffies(60 * 1000) 69#define CEPH_OSD_IDLE_TTL_DEFAULT msecs_to_jiffies(60 * 1000)
70 70
71#define CEPH_MONC_HUNT_INTERVAL msecs_to_jiffies(3 * 1000)
71#define CEPH_MONC_PING_INTERVAL msecs_to_jiffies(10 * 1000) 72#define CEPH_MONC_PING_INTERVAL msecs_to_jiffies(10 * 1000)
72#define CEPH_MONC_PING_TIMEOUT msecs_to_jiffies(30 * 1000) 73#define CEPH_MONC_PING_TIMEOUT msecs_to_jiffies(30 * 1000)
74#define CEPH_MONC_HUNT_BACKOFF 2
75#define CEPH_MONC_HUNT_MAX_MULT 10
73 76
74#define CEPH_MSG_MAX_FRONT_LEN (16*1024*1024) 77#define CEPH_MSG_MAX_FRONT_LEN (16*1024*1024)
75#define CEPH_MSG_MAX_MIDDLE_LEN (16*1024*1024) 78#define CEPH_MSG_MAX_MIDDLE_LEN (16*1024*1024)
diff --git a/include/linux/ceph/mon_client.h b/include/linux/ceph/mon_client.h
index 8b2d2f0b659e..e230e7ed60d3 100644
--- a/include/linux/ceph/mon_client.h
+++ b/include/linux/ceph/mon_client.h
@@ -72,6 +72,9 @@ struct ceph_mon_client {
72 unsigned long sub_renew_sent; 72 unsigned long sub_renew_sent;
73 struct ceph_connection con; 73 struct ceph_connection con;
74 74
75 bool had_a_connection;
76 int hunt_mult; /* [1..CEPH_MONC_HUNT_MAX_MULT] */
77
75 /* pending generic requests */ 78 /* pending generic requests */
76 struct rb_root generic_request_tree; 79 struct rb_root generic_request_tree;
77 int num_generic_requests; 80 int num_generic_requests;
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
index 23a270c49baf..fd1cf408fd89 100644
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -171,6 +171,12 @@ static void __open_session(struct ceph_mon_client *monc)
171 171
172 pick_new_mon(monc); 172 pick_new_mon(monc);
173 173
174 if (monc->had_a_connection) {
175 monc->hunt_mult *= CEPH_MONC_HUNT_BACKOFF;
176 if (monc->hunt_mult > CEPH_MONC_HUNT_MAX_MULT)
177 monc->hunt_mult = CEPH_MONC_HUNT_MAX_MULT;
178 }
179
174 monc->sub_renew_after = jiffies; /* i.e., expired */ 180 monc->sub_renew_after = jiffies; /* i.e., expired */
175 monc->sub_renew_sent = 0; 181 monc->sub_renew_sent = 0;
176 182
@@ -192,11 +198,6 @@ static void __open_session(struct ceph_mon_client *monc)
192 __send_prepared_auth_request(monc, ret); 198 __send_prepared_auth_request(monc, ret);
193} 199}
194 200
195static bool __sub_expired(struct ceph_mon_client *monc)
196{
197 return time_after_eq(jiffies, monc->sub_renew_after);
198}
199
200/* 201/*
201 * Reschedule delayed work timer. 202 * Reschedule delayed work timer.
202 */ 203 */
@@ -204,11 +205,11 @@ static void __schedule_delayed(struct ceph_mon_client *monc)
204{ 205{
205 unsigned long delay; 206 unsigned long delay;
206 207
207 if (monc->cur_mon < 0 || __sub_expired(monc)) { 208 if (monc->hunting)
208 delay = 10 * HZ; 209 delay = CEPH_MONC_HUNT_INTERVAL * monc->hunt_mult;
209 } else { 210 else
210 delay = CEPH_MONC_PING_INTERVAL; 211 delay = CEPH_MONC_PING_INTERVAL;
211 } 212
212 dout("__schedule_delayed after %lu\n", delay); 213 dout("__schedule_delayed after %lu\n", delay);
213 schedule_delayed_work(&monc->delayed_work, 214 schedule_delayed_work(&monc->delayed_work,
214 round_jiffies_relative(delay)); 215 round_jiffies_relative(delay));
@@ -902,6 +903,8 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
902 monc->hunting = true; 903 monc->hunting = true;
903 monc->sub_renew_after = jiffies; 904 monc->sub_renew_after = jiffies;
904 monc->sub_renew_sent = 0; 905 monc->sub_renew_sent = 0;
906 monc->had_a_connection = false;
907 monc->hunt_mult = 1;
905 908
906 INIT_DELAYED_WORK(&monc->delayed_work, delayed_work); 909 INIT_DELAYED_WORK(&monc->delayed_work, delayed_work);
907 monc->generic_request_tree = RB_ROOT; 910 monc->generic_request_tree = RB_ROOT;
@@ -959,6 +962,10 @@ static void finish_hunting(struct ceph_mon_client *monc)
959 if (monc->hunting) { 962 if (monc->hunting) {
960 dout("%s found mon%d\n", __func__, monc->cur_mon); 963 dout("%s found mon%d\n", __func__, monc->cur_mon);
961 monc->hunting = false; 964 monc->hunting = false;
965 monc->had_a_connection = true;
966 monc->hunt_mult /= 2; /* reduce by 50% */
967 if (monc->hunt_mult < 1)
968 monc->hunt_mult = 1;
962 } 969 }
963} 970}
964 971