diff options
Diffstat (limited to 'net/ceph/mon_client.c')
-rw-r--r-- | net/ceph/mon_client.c | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/net/ceph/mon_client.c b/net/ceph/mon_client.c index 9d6ff1215928..edda01626a45 100644 --- a/net/ceph/mon_client.c +++ b/net/ceph/mon_client.c | |||
@@ -149,6 +149,10 @@ static int __open_session(struct ceph_mon_client *monc) | |||
149 | CEPH_ENTITY_TYPE_MON, monc->cur_mon, | 149 | CEPH_ENTITY_TYPE_MON, monc->cur_mon, |
150 | &monc->monmap->mon_inst[monc->cur_mon].addr); | 150 | &monc->monmap->mon_inst[monc->cur_mon].addr); |
151 | 151 | ||
152 | /* send an initial keepalive to ensure our timestamp is | ||
153 | * valid by the time we are in an OPENED state */ | ||
154 | ceph_con_keepalive(&monc->con); | ||
155 | |||
152 | /* initiatiate authentication handshake */ | 156 | /* initiatiate authentication handshake */ |
153 | ret = ceph_auth_build_hello(monc->auth, | 157 | ret = ceph_auth_build_hello(monc->auth, |
154 | monc->m_auth->front.iov_base, | 158 | monc->m_auth->front.iov_base, |
@@ -170,14 +174,19 @@ static bool __sub_expired(struct ceph_mon_client *monc) | |||
170 | */ | 174 | */ |
171 | static void __schedule_delayed(struct ceph_mon_client *monc) | 175 | static void __schedule_delayed(struct ceph_mon_client *monc) |
172 | { | 176 | { |
173 | unsigned int delay; | 177 | struct ceph_options *opt = monc->client->options; |
178 | unsigned long delay; | ||
174 | 179 | ||
175 | if (monc->cur_mon < 0 || __sub_expired(monc)) | 180 | if (monc->cur_mon < 0 || __sub_expired(monc)) { |
176 | delay = 10 * HZ; | 181 | delay = 10 * HZ; |
177 | else | 182 | } else { |
178 | delay = 20 * HZ; | 183 | delay = 20 * HZ; |
179 | dout("__schedule_delayed after %u\n", delay); | 184 | if (opt->monc_ping_timeout > 0) |
180 | schedule_delayed_work(&monc->delayed_work, delay); | 185 | delay = min(delay, opt->monc_ping_timeout / 3); |
186 | } | ||
187 | dout("__schedule_delayed after %lu\n", delay); | ||
188 | schedule_delayed_work(&monc->delayed_work, | ||
189 | round_jiffies_relative(delay)); | ||
181 | } | 190 | } |
182 | 191 | ||
183 | /* | 192 | /* |
@@ -743,11 +752,23 @@ static void delayed_work(struct work_struct *work) | |||
743 | __close_session(monc); | 752 | __close_session(monc); |
744 | __open_session(monc); /* continue hunting */ | 753 | __open_session(monc); /* continue hunting */ |
745 | } else { | 754 | } else { |
746 | ceph_con_keepalive(&monc->con); | 755 | struct ceph_options *opt = monc->client->options; |
756 | int is_auth = ceph_auth_is_authenticated(monc->auth); | ||
757 | if (ceph_con_keepalive_expired(&monc->con, | ||
758 | opt->monc_ping_timeout)) { | ||
759 | dout("monc keepalive timeout\n"); | ||
760 | is_auth = 0; | ||
761 | __close_session(monc); | ||
762 | monc->hunting = true; | ||
763 | __open_session(monc); | ||
764 | } | ||
747 | 765 | ||
748 | __validate_auth(monc); | 766 | if (!monc->hunting) { |
767 | ceph_con_keepalive(&monc->con); | ||
768 | __validate_auth(monc); | ||
769 | } | ||
749 | 770 | ||
750 | if (ceph_auth_is_authenticated(monc->auth)) | 771 | if (is_auth) |
751 | __send_subscribe(monc); | 772 | __send_subscribe(monc); |
752 | } | 773 | } |
753 | __schedule_delayed(monc); | 774 | __schedule_delayed(monc); |