From d9b0cd31334ce1eb49c6a36da43003463b9c6b33 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 12 Feb 2015 13:50:42 -0800 Subject: [PATCH] mon/OSDMonitor: move osd epoch cache update into helper, add fixme There is no semantic change here, just a helper to make things more clear. Add warning about a potential bug so we don't lose track. Signed-off-by: Sage Weil --- src/mon/OSDMonitor.cc | 24 ++++++++++++++++++++++-- src/mon/OSDMonitor.h | 2 ++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index c008e20680e8e..16840b8048f3a 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2145,7 +2145,7 @@ void OSDMonitor::send_incremental(PaxosServiceMessage *req, epoch_t first) mon->send_reply(req, m); if (osd >= 0) - osd_epoch[osd] = osdmap.get_epoch(); + note_osd_has_epoch(osd, osdmap.get_epoch()); return; } @@ -2158,7 +2158,27 @@ void OSDMonitor::send_incremental(PaxosServiceMessage *req, epoch_t first) mon->send_reply(req, m); if (osd >= 0) - osd_epoch[osd] = last; + 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::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; + } } void OSDMonitor::send_incremental(epoch_t first, MonSession *session, diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index e6c295a595e25..afeacde4a5243 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -140,6 +140,8 @@ private: */ map osd_epoch; + void note_osd_has_epoch(int osd, epoch_t epoch); + void check_failures(utime_t now); bool check_failure(utime_t now, int target_osd, failure_info_t& fi); -- 2.39.5