Skip to content

Commit 685047b

Browse files
Matan-Bathanatos
andcommitted
mon/OSDMonitor: add comments
Co-authored-by: Samuel Just <[email protected]> Signed-off-by: Matan Breizman <[email protected]>
1 parent ba750f4 commit 685047b

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/mon/OSDMonitor.cc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,11 +2280,18 @@ version_t OSDMonitor::get_trim_to() const
22802280
return 0;
22812281
}
22822282

2283+
/* There are two constraints on trimming:
2284+
* 1. we must not trim past the last_epoch_clean for any pg
2285+
* 2. we must not trim past the last reported epoch for any up
2286+
* osds.
2287+
*
2288+
* LastEpochClean::get_lower_bound_by_pool gives a value <= constraint 1.
2289+
* For constraint 2, we take the min over osd_epochs, which is populated with
2290+
* MOSDBeacon::version, see OSDMonitor::prepare_beacon
2291+
*/
22832292
epoch_t OSDMonitor::get_min_last_epoch_clean() const
22842293
{
22852294
auto floor = last_epoch_clean.get_lower_bound_by_pool(osdmap);
2286-
// also scan osd epochs
2287-
// don't trim past the oldest reported osd epoch
22882295
for (auto [osd, epoch] : osd_epochs) {
22892296
if (epoch < floor) {
22902297
ceph_assert(osdmap.is_up(osd));

src/mon/OSDMonitor.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ class LastEpochClean {
114114
public:
115115
void report(unsigned pg_num, const pg_t& pg, epoch_t last_epoch_clean);
116116
void remove_pool(uint64_t pool);
117+
/**
118+
* get_lower_bound_by_pool
119+
*
120+
* Returns epoch e such that e <= pg.last_epoch_clean for all pgs in cluster.
121+
* May return 0 if any pool does not have comprehensive values for all pgs.
122+
*/
117123
epoch_t get_lower_bound_by_pool(const OSDMap& latest) const;
118124

119125
void dump(Formatter *f) const;
@@ -639,8 +645,18 @@ class OSDMonitor : public PaxosService,
639645

640646
// when we last received PG stats from each osd and the osd's osd_beacon_report_interval
641647
std::map<int, std::pair<utime_t, int>> last_osd_report;
642-
// TODO: use last_osd_report to store the osd report epochs, once we don't
643-
// need to upgrade from pre-luminous releases.
648+
/**
649+
* osd_epochs
650+
*
651+
* Records the MOSDBeacon::version (the osd epoch at which the OSD sent the
652+
* beacon) of the most recent beacon recevied from each currently up OSD.
653+
* Used in OSDMonitor::get_min_last_epoch_clean().
654+
* Down osds are trimmed upon commit of each map
655+
* (OSDMonitor::update_from_paxos).
656+
*
657+
* TODO: use last_osd_report to store the osd report epochs, once we don't
658+
* need to upgrade from pre-luminous releases.
659+
*/
644660
std::map<int,epoch_t> osd_epochs;
645661
LastEpochClean last_epoch_clean;
646662
bool preprocess_beacon(MonOpRequestRef op);

0 commit comments

Comments
 (0)