From d28c8e0fb924fbf36e4e15e19554ad30da3ff8f2 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 2 Nov 2014 08:50:59 -0800 Subject: [PATCH] mon/PGMap and PGMonitor: update last_epoch_clean cache from new osd keys We were only invalidating the cached value from apply_incremental, which is no longer called on modern clusters. Fix this by storing the update epoch in the key as well (it is not part of osd_stat_t). Backport: giant, firefly, dumpling(?) Fixes: #9987 Signed-off-by: Sage Weil (cherry picked from commit 093c5f0cabeb552b90d944da2c50de48fcf6f564) --- src/mon/PGMap.cc | 21 ++++++++++++++++++++- src/mon/PGMonitor.cc | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index b7acb86bf2e12..74347f24daefb 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -413,14 +413,33 @@ void PGMap::update_osd(int osd, bufferlist& bl) { bufferlist::iterator p = bl.begin(); ceph::unordered_map::iterator o = osd_stat.find(osd); - if (o != osd_stat.end()) + epoch_t old_lec = 0; + if (o != osd_stat.end()) { + ceph::unordered_map::iterator i = osd_epochs.find(osd); + if (i != osd_epochs.end()) + old_lec = i->second; stat_osd_sub(o->second); + } osd_stat_t& r = osd_stat[osd]; ::decode(r, p); stat_osd_add(r); // adjust [near]full status register_nearfull_status(osd, r); + + // epoch? + if (!p.end()) { + epoch_t e; + ::decode(e, p); + + if (e < min_last_epoch_clean || + (e > min_last_epoch_clean && + old_lec == min_last_epoch_clean)) + min_last_epoch_clean = 0; + } else { + // WARNING: we are not refreshing min_last_epoch_clean! must be old store + // or old mon running. + } } void PGMap::remove_osd(int osd) diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index d95288cbb30a1..f197b3a52c060 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -548,6 +548,7 @@ void PGMonitor::encode_pending(MonitorDBStore::TransactionRef t) ::encode(p->first, dirty); bufferlist bl; ::encode(p->second, bl, features); + ::encode(pending_inc.get_osd_epochs().find(p->first)->second, bl); t->put(prefix, stringify(p->first), bl); } for (set::const_iterator p = -- 2.47.3