From: Venky Shankar Date: Thu, 25 Jul 2019 13:16:18 +0000 (-0400) Subject: mds: send scrub state changes to cluster log. X-Git-Tag: v14.2.10~168^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=456ed450adc416fdf9075b7e46a214b9e172f18e;p=ceph.git mds: send scrub state changes to cluster log. ... also log new and completed scrubs. Signed-off-by: Venky Shankar (cherry picked from commit 49520156414cb0667e8edd6ea4b31462e7cb7752) --- diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 967553d798c..0fd09ee70c7 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -538,7 +538,7 @@ MDSRank::MDSRank( mdlog = new MDLog(this); balancer = new MDBalancer(this, messenger, monc); - scrubstack = new ScrubStack(mdcache, finisher); + scrubstack = new ScrubStack(mdcache, clog, finisher); inotable = new InoTable(this); snapserver = new SnapServer(this, monc); diff --git a/src/mds/ScrubStack.cc b/src/mds/ScrubStack.cc index 818efce9776..2743347e4e6 100644 --- a/src/mds/ScrubStack.cc +++ b/src/mds/ScrubStack.cc @@ -482,6 +482,7 @@ void ScrubStack::_validate_inode_done(CInode *in, int r, if (in == header->get_origin()) { scrub_origins.erase(in); + clog_scrub_summary(in); if (!header->get_recursive()) { if (r >= 0) { // we got into the scrubbing dump it result.dump(&(header->get_formatter())); @@ -514,6 +515,7 @@ void ScrubStack::set_state(State next_state) { dout(20) << __func__ << ", from state=" << state << ", to state=" << next_state << dendl; state = next_state; + clog_scrub_summary(); } } @@ -570,9 +572,7 @@ std::string_view ScrubStack::scrub_summary() { *cs << ","; } - std::string path; - (*inode)->make_path_string(path, true); - *cs << (path.empty() ? "/" : path.c_str()); + *cs << scrub_inode_path(*inode); } *cs << "]"; } @@ -621,9 +621,7 @@ void ScrubStack::scrub_status(Formatter *f) { std::string tag(header->get_tag()); f->open_object_section(tag.c_str()); // scrub id - std::string path; - inode->make_path_string(path, true); - f->dump_string("path", path.empty() ? "/" : path.c_str()); + f->dump_string("path", scrub_inode_path(inode)); std::stringstream optss; if (header->get_recursive()) { @@ -659,6 +657,7 @@ void ScrubStack::abort_pending_scrubs() { CInode *in = *inode; if (in == in->scrub_info()->header->get_origin()) { scrub_origins.erase(in); + clog_scrub_summary(in); } MDSContext *ctx = nullptr; @@ -737,3 +736,20 @@ bool ScrubStack::scrub_resume() { return r; } + +// send current scrub summary to cluster log +void ScrubStack::clog_scrub_summary(CInode *in) { + if (in) { + std::string what; + if (clear_inode_stack) { + what = "aborted"; + } else if (scrub_origins.count(in)) { + what = "queued"; + } else { + what = "completed"; + } + clog->info() << "scrub " << what << " for path: " << scrub_inode_path(in); + } + + clog->info() << "scrub summary: " << scrub_summary(); +} diff --git a/src/mds/ScrubStack.h b/src/mds/ScrubStack.h index 8ae674ebec4..3586daf236b 100644 --- a/src/mds/ScrubStack.h +++ b/src/mds/ScrubStack.h @@ -21,6 +21,7 @@ #include "MDSContext.h" #include "ScrubHeader.h" +#include "common/LogClient.h" #include "include/elist.h" class MDCache; @@ -28,6 +29,9 @@ class Finisher; class ScrubStack { protected: + // reference to global cluster log client + LogChannelRef &clog; + /// A finisher needed so that we don't re-enter kick_off_scrubs Finisher *finisher; @@ -57,7 +61,8 @@ protected: public: MDCache *mdcache; - ScrubStack(MDCache *mdc, Finisher *finisher_) : + ScrubStack(MDCache *mdc, LogChannelRef &clog, Finisher *finisher_) : + clog(clog), finisher(finisher_), inode_stack(member_offset(CInode, item_scrub)), scrubs_in_progress(0), @@ -81,6 +86,7 @@ public: MDSContext *on_finish) { enqueue_inode(in, header, on_finish, true); scrub_origins.emplace(in); + clog_scrub_summary(in); } /** Like enqueue_inode_top, but we wait for all pending scrubs before * starting this one. @@ -89,6 +95,7 @@ public: MDSContext *on_finish) { enqueue_inode(in, header, on_finish, false); scrub_origins.emplace(in); + clog_scrub_summary(in); } /** @@ -277,6 +284,23 @@ private: * Completion context is complete with -ECANCELED. */ void abort_pending_scrubs(); + + /** + * Return path for a given inode. + * @param in inode to make path entry. + */ + std::string scrub_inode_path(CInode *in) { + std::string path; + in->make_path_string(path, true); + return (path.empty() ? "/" : path.c_str()); + } + + /** + * Send scrub information (queued/finished scrub path and summary) + * to cluster log. + * @param in inode for which scrub has been queued or finished. + */ + void clog_scrub_summary(CInode *in=nullptr); }; #endif /* SCRUBSTACK_H_ */