Skip to content

Commit 7d11c70

Browse files
committed
mds: make parts of mdlog reusable to be used by beacon
Signed-off-by: Venky Shankar <[email protected]>
1 parent fca07e9 commit 7d11c70

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/mds/Beacon.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,15 @@ void Beacon::notify_health(MDSRank const *mds)
320320
// Detect MDS_HEALTH_TRIM condition
321321
// Indicates MDS is not trimming promptly
322322
{
323-
const auto log_max_segments = mds->mdlog->get_max_segments();
324-
const auto log_warn_factor = g_conf().get_val<double>("mds_log_warn_factor");
325-
if (mds->mdlog->get_num_segments() > (size_t)(log_max_segments * log_warn_factor)) {
323+
if (mds->mdlog->is_trim_slow()) {
324+
auto num_segments = mds->mdlog->get_num_segments();
325+
auto max_segments = mds->mdlog->get_max_segments();
326326
CachedStackStringStream css;
327-
*css << "Behind on trimming (" << mds->mdlog->get_num_segments()
328-
<< "/" << log_max_segments << ")";
327+
*css << "Behind on trimming (" << num_segments << "/" << max_segments << ")";
329328

330329
MDSHealthMetric m(MDS_HEALTH_TRIM, HEALTH_WARN, css->strv());
331-
m.metadata["num_segments"] = stringify(mds->mdlog->get_num_segments());
332-
m.metadata["max_segments"] = stringify(log_max_segments);
330+
m.metadata["num_segments"] = stringify(num_segments);
331+
m.metadata["max_segments"] = stringify(max_segments);
333332
health.metrics.push_back(m);
334333
}
335334
}

src/mds/MDLog.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ MDLog::MDLog(MDSRank* m)
5858
max_events = g_conf().get_val<int64_t>("mds_log_max_events");
5959
skip_corrupt_events = g_conf().get_val<bool>("mds_log_skip_corrupt_events");
6060
skip_unbounded_events = g_conf().get_val<bool>("mds_log_skip_unbounded_events");
61+
log_warn_factor = g_conf().get_val<double>("mds_log_warn_factor");
6162
upkeep_thread = std::thread(&MDLog::log_trim_upkeep, this);
6263
}
6364

@@ -656,6 +657,10 @@ void MDLog::try_to_commit_open_file_table(uint64_t last_seq)
656657
}
657658
}
658659

660+
bool MDLog::is_trim_slow() const {
661+
return (segments.size() > (size_t)(max_segments * log_warn_factor));
662+
}
663+
659664
void MDLog::log_trim_upkeep(void) {
660665
dout(10) << dendl;
661666

@@ -1642,4 +1647,7 @@ void MDLog::handle_conf_change(const std::set<std::string>& changed, const MDSMa
16421647
if (changed.count("mds_log_trim_decay_rate")){
16431648
log_trim_counter = DecayCounter(g_conf().get_val<double>("mds_log_trim_decay_rate"));
16441649
}
1650+
if (changed.count("mds_log_warn_factor")) {
1651+
log_warn_factor = g_conf().get_val<double>("mds_log_warn_factor");
1652+
}
16451653
}

src/mds/MDLog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ class MDLog {
173173
// replay state
174174
std::map<inodeno_t, std::set<inodeno_t>> pending_exports;
175175

176+
// beacon needs me too
177+
bool is_trim_slow() const;
178+
176179
protected:
177180
struct PendingEvent {
178181
PendingEvent(LogEvent *e, Context* c, bool f=false) : le(e), fin(c), flush(f) {}
@@ -313,6 +316,7 @@ class MDLog {
313316
std::set<LogSegment*> expired_segments;
314317
std::set<LogSegment*> expiring_segments;
315318
uint64_t events_since_last_major_segment = 0;
319+
double log_warn_factor;
316320

317321
// log trimming decay counter
318322
DecayCounter log_trim_counter;

0 commit comments

Comments
 (0)