Skip to content

Commit 1770b17

Browse files
committed
osd/scrub: improve scrub information conveyed in standard
PG log line references When "mentioning" a PG in a log message, we include a set of data items, including some scrub related information. This commit improves the scrubber information conveyed, following changes to the scrub scheduler. Signed-off-by: Ronen Friedman <[email protected]>
1 parent ed58632 commit 1770b17

File tree

3 files changed

+58
-9
lines changed

3 files changed

+58
-9
lines changed

src/osd/scrubber/pg_scrubber.cc

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,9 +2687,53 @@ void PgScrubber::log_cluster_warning(const std::string& warning) const
26872687
m_osds->clog->do_log(CLOG_WARN, warning);
26882688
}
26892689

2690-
ostream& PgScrubber::show(ostream& out) const
2691-
{
2692-
return out << " [ " << m_pg_id << ": " << m_flags << " ] ";
2690+
2691+
ostream& PgScrubber::show_concise(ostream& out) const
2692+
{
2693+
/*
2694+
* 'show_concise()' is only used when calling operator<< thru the ScrubPgIF,
2695+
* i.e. only by the PG when creating a standard log entry.
2696+
*
2697+
* desired outcome (only relevant for Primaries):
2698+
*
2699+
* if scrubbing:
2700+
* (urgency,flags)
2701+
* or (if blocked)
2702+
* (*blocked*,urgency,flags)
2703+
*
2704+
* if not scrubbing:
2705+
* either nothing (if only periodic scrubs are scheduled)
2706+
* or [next-scrub: effective-lvl, urgency]
2707+
*/
2708+
if (!is_primary()) {
2709+
return out;
2710+
}
2711+
2712+
if (m_active) {
2713+
const auto flags_txt = fmt::format("{}", m_flags);
2714+
const std::string sep = (flags_txt.empty() ? "" : ",");
2715+
if (m_active_target) {
2716+
return out << fmt::format(
2717+
"({}{}{}{})", (m_scrub_job->blocked ? "*blocked*," : ""),
2718+
m_active_target->urgency(), sep, flags_txt);
2719+
} else {
2720+
// only expected in a couple of messages during scrub termination
2721+
return out << fmt::format(
2722+
"(teardown{}{}{})", (m_scrub_job->blocked ? "-*blocked*" : ""),
2723+
sep, flags_txt);
2724+
}
2725+
}
2726+
2727+
// not actively scrubbing now. Show some info about the next scrub
2728+
const auto now_is = ceph_clock_now();
2729+
const auto& next_scrub = m_scrub_job->earliest_target(now_is);
2730+
if (!next_scrub.is_high_priority()) {
2731+
// no interesting flags to report
2732+
return out;
2733+
}
2734+
return out << fmt::format(
2735+
"[next-scrub:{},{:10.10}]", (next_scrub.is_deep() ? "dp" : "sh"),
2736+
next_scrub.urgency());
26932737
}
26942738

26952739
int PgScrubber::asok_debug(std::string_view cmd,

src/osd/scrubber/pg_scrubber.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ template <>
164164
struct formatter<scrub_flags_t> {
165165
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
166166
template <typename FormatContext>
167-
auto format(scrub_flags_t& sf, FormatContext& ctx) const
167+
auto format(const scrub_flags_t& sf, FormatContext& ctx) const
168168
{
169169
std::string txt;
170170
bool sep{false};
@@ -528,7 +528,7 @@ class PgScrubber : public ScrubPgIF,
528528
/// to complete (in order to perform an 'after-repair' scrub)
529529
bool m_after_repair_scrub_required{false};
530530

531-
ostream& show(ostream& out) const override;
531+
ostream& show_concise(ostream& out) const override;
532532

533533
public:
534534
// ------------------ the I/F used by the ScrubBackend (ScrubBeListener)
@@ -741,6 +741,12 @@ class PgScrubber : public ScrubPgIF,
741741
bool m_publish_sessions{false}; //< will the counter be part of 'query'
742742
//output?
743743

744+
/**
745+
* the scrub operation flags.
746+
* Set at scrub start. Checked in multiple locations - mostly
747+
* at finish.
748+
* Note: replicas only use the 'priority' field.
749+
*/
744750
scrub_flags_t m_flags;
745751

746752
bool m_active{false};

src/osd/scrubber_common.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,11 @@ struct ScrubPgIF {
299299

300300
virtual ~ScrubPgIF() = default;
301301

302-
friend std::ostream& operator<<(std::ostream& out, const ScrubPgIF& s)
303-
{
304-
return s.show(out);
302+
friend std::ostream& operator<<(std::ostream& out, const ScrubPgIF& s) {
303+
return s.show_concise(out);
305304
}
306305

307-
virtual std::ostream& show(std::ostream& out) const = 0;
306+
virtual std::ostream& show_concise(std::ostream& out) const = 0;
308307

309308
// --------------- triggering state-machine events:
310309

0 commit comments

Comments
 (0)