summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Dryomov <idryomov@gmail.com>2016-01-21 10:33:25 -0500
committerIlya Dryomov <idryomov@gmail.com>2016-03-25 13:51:39 -0400
commit1752b50ca240a7f722f57e81ba04496eb15c466f (patch)
tree577db5b01a790f7aa324fac3429e4f85f6bf3caf
parent168b9090c739c4b5556023a3f08789b349ca7339 (diff)
libceph: introduce and switch to reopen_session()
hunting is now set in __open_session() and cleared in finish_hunting(), instead of all around. The "session lost" message is printed not only on connection resets, but also on keepalive timeouts. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
-rw-r--r--net/ceph/mon_client.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c
index fd1cf408fd89..816fb813a336 100644
--- a/net/ceph/mon_client.c
+++ b/net/ceph/mon_client.c
@@ -171,6 +171,7 @@ static void __open_session(struct ceph_mon_client *monc)
171 171
172 pick_new_mon(monc); 172 pick_new_mon(monc);
173 173
174 monc->hunting = true;
174 if (monc->had_a_connection) { 175 if (monc->had_a_connection) {
175 monc->hunt_mult *= CEPH_MONC_HUNT_BACKOFF; 176 monc->hunt_mult *= CEPH_MONC_HUNT_BACKOFF;
176 if (monc->hunt_mult > CEPH_MONC_HUNT_MAX_MULT) 177 if (monc->hunt_mult > CEPH_MONC_HUNT_MAX_MULT)
@@ -198,6 +199,16 @@ static void __open_session(struct ceph_mon_client *monc)
198 __send_prepared_auth_request(monc, ret); 199 __send_prepared_auth_request(monc, ret);
199} 200}
200 201
202static void reopen_session(struct ceph_mon_client *monc)
203{
204 if (!monc->hunting)
205 pr_info("mon%d %s session lost, hunting for new mon\n",
206 monc->cur_mon, ceph_pr_addr(&monc->con.peer_addr.in_addr));
207
208 __close_session(monc);
209 __open_session(monc);
210}
211
201/* 212/*
202 * Reschedule delayed work timer. 213 * Reschedule delayed work timer.
203 */ 214 */
@@ -788,17 +799,15 @@ static void delayed_work(struct work_struct *work)
788 dout("monc delayed_work\n"); 799 dout("monc delayed_work\n");
789 mutex_lock(&monc->mutex); 800 mutex_lock(&monc->mutex);
790 if (monc->hunting) { 801 if (monc->hunting) {
791 __close_session(monc); 802 dout("%s continuing hunt\n", __func__);
792 __open_session(monc); /* continue hunting */ 803 reopen_session(monc);
793 } else { 804 } else {
794 int is_auth = ceph_auth_is_authenticated(monc->auth); 805 int is_auth = ceph_auth_is_authenticated(monc->auth);
795 if (ceph_con_keepalive_expired(&monc->con, 806 if (ceph_con_keepalive_expired(&monc->con,
796 CEPH_MONC_PING_TIMEOUT)) { 807 CEPH_MONC_PING_TIMEOUT)) {
797 dout("monc keepalive timeout\n"); 808 dout("monc keepalive timeout\n");
798 is_auth = 0; 809 is_auth = 0;
799 __close_session(monc); 810 reopen_session(monc);
800 monc->hunting = true;
801 __open_session(monc);
802 } 811 }
803 812
804 if (!monc->hunting) { 813 if (!monc->hunting) {
@@ -900,9 +909,6 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
900 &monc->client->msgr); 909 &monc->client->msgr);
901 910
902 monc->cur_mon = -1; 911 monc->cur_mon = -1;
903 monc->hunting = true;
904 monc->sub_renew_after = jiffies;
905 monc->sub_renew_sent = 0;
906 monc->had_a_connection = false; 912 monc->had_a_connection = false;
907 monc->hunt_mult = 1; 913 monc->hunt_mult = 1;
908 914
@@ -1157,16 +1163,9 @@ static void mon_fault(struct ceph_connection *con)
1157 if (!con->private) 1163 if (!con->private)
1158 goto out; 1164 goto out;
1159 1165
1160 if (!monc->hunting)
1161 pr_info("mon%d %s session lost, "
1162 "hunting for new mon\n", monc->cur_mon,
1163 ceph_pr_addr(&monc->con.peer_addr.in_addr));
1164
1165 __close_session(monc);
1166 if (!monc->hunting) { 1166 if (!monc->hunting) {
1167 /* start hunting */ 1167 dout("%s hunting for new mon\n", __func__);
1168 monc->hunting = true; 1168 reopen_session(monc);
1169 __open_session(monc);
1170 } else { 1169 } else {
1171 /* already hunting, let's wait a bit */ 1170 /* already hunting, let's wait a bit */
1172 __schedule_delayed(monc); 1171 __schedule_delayed(monc);