]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: send scrub state changes to cluster log.
authorVenky Shankar <vshankar@redhat.com>
Thu, 25 Jul 2019 13:16:18 +0000 (09:16 -0400)
committerVenky Shankar <vshankar@redhat.com>
Thu, 26 Mar 2020 02:44:12 +0000 (22:44 -0400)
... also log new and completed scrubs.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 49520156414cb0667e8edd6ea4b31462e7cb7752)

src/mds/MDSRank.cc
src/mds/ScrubStack.cc
src/mds/ScrubStack.h

index 967553d798c120881630ab9e6a798cabfca92f7e..0fd09ee70c7c46d05f69f975a61778663754d862 100644 (file)
@@ -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);
index 818efce97767625aa90c7acd27b7c1a92441c91d..2743347e4e6783ef9d9069088332306f147c28f3 100644 (file)
@@ -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();
+}
index 8ae674ebec4e3a07829a4aac6b1df036f90af309..3586daf236b202d51ccf1ee472002f0a471d14e2 100644 (file)
@@ -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_ */