for (int o = 0; o < osdmap.get_max_osd(); o++) {
if (osdmap.is_down(o)) {
- // invalidate osd_epoch cache
- osd_epoch.erase(o);
-
// populate down -> out map
if (osdmap.is_in(o) &&
down_pending_out.count(o) == 0) {
}
}
}
- // blow away any osd_epoch items beyond max_osd
- map<int,epoch_t>::iterator p = osd_epoch.upper_bound(osdmap.get_max_osd());
- while (p != osd_epoch.end()) {
- osd_epoch.erase(p++);
- }
+ // XXX: need to trim MonSession connected with a osd whose id > max_osd?
/** we don't have any of the feature bit infrastructure in place for
* supporting primary_temp mappings without breaking old clients/OSDs.*/
<< " to " << op->get_req()->get_orig_source_inst()
<< dendl;
- int osd = -1;
+ MonSession *s = NULL;
if (op->get_req()->get_source().is_osd()) {
- osd = op->get_req()->get_source().num();
- map<int,epoch_t>::iterator p = osd_epoch.find(osd);
- if (p != osd_epoch.end()) {
- if (first <= p->second) {
- dout(10) << __func__ << " osd." << osd << " should already have epoch "
- << p->second << dendl;
- first = p->second + 1;
- if (first > osdmap.get_epoch())
- return;
- }
- }
+ s = op->get_session();
+ }
+
+ if (s && first <= s->osd_epoch) {
+ dout(10) << __func__ << s->inst << " should already have epoch "
+ << s->osd_epoch << dendl;
+ first = s->osd_epoch + 1;
+ if (first > osdmap.get_epoch())
+ return;
}
if (first < get_first_committed()) {
m->maps[first] = bl;
mon->send_reply(op, m);
- if (osd >= 0)
- note_osd_has_epoch(osd, osdmap.get_epoch());
+ if (s)
+ s->osd_epoch = osdmap.get_epoch();
return;
}
m->newest_map = osdmap.get_epoch();
mon->send_reply(op, m);
- if (osd >= 0)
- note_osd_has_epoch(osd, last);
-}
-
-// FIXME: we assume the OSD actually receives this. if the mon
-// session drops and they reconnect we may not share the same maps
-// with them again, which could cause a strange hang (perhaps stuck
-// 'waiting for osdmap' requests?). this information should go in the
-// MonSession, but I think these functions need to be refactored in
-// terms of MonSession first for that to work.
-void OSDMonitor::note_osd_has_epoch(int osd, epoch_t epoch)
-{
- dout(20) << __func__ << " osd." << osd << " epoch " << epoch << dendl;
- map<int,epoch_t>::iterator p = osd_epoch.find(osd);
- if (p != osd_epoch.end()) {
- dout(20) << __func__ << " osd." << osd << " epoch " << epoch
- << " (was " << p->second << ")" << dendl;
- p->second = epoch;
- } else {
- dout(20) << __func__ << " osd." << osd << " epoch " << epoch << dendl;
- osd_epoch[osd] = epoch;
- }
+ if (s)
+ s->osd_epoch = last;
}
void OSDMonitor::send_incremental(epoch_t first, MonSession *session,
m->newest_map = osdmap.get_epoch();
m->maps[first] = bl;
session->con->send_message(m);
+ if (session->inst.name.is_osd()) {
+ session->osd_epoch = first;
+ }
first++;
}
session->con->send_message(m);
first = last + 1;
- if (session->inst.name.is_osd())
- note_osd_has_epoch(session->inst.name.num(), last);
+ if (session->inst.name.is_osd()) {
+ session->osd_epoch = last;
+ }
if (onetime)
break;
uint64_t global_id;
map<string, Subscription*> sub_map;
+ epoch_t osd_epoch; // the osdmap epoch sent to the mon client
AuthServiceHandler *auth_handler;
EntityName entity_name;
MonSession(const entity_inst_t& i, Connection *c) :
con(c), inst(i), closed(false), item(this),
auid(0),
- global_id(0), auth_handler(NULL),
+ global_id(0),
+ osd_epoch(0),
+ auth_handler(NULL),
proxy_con(NULL), proxy_tid(0) {
time_established = ceph_clock_now(g_ceph_context);
}