]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: generate random scrub tag when empty
authorVenky Shankar <vshankar@redhat.com>
Mon, 5 Nov 2018 05:49:44 +0000 (00:49 -0500)
committerVenky Shankar <vshankar@redhat.com>
Wed, 2 Jan 2019 13:51:00 +0000 (08:51 -0500)
With this, scrub operations are tagged with a random
uuid if tag is unspecified. This also helps to show
in-progress scrub operations via "scrub status" command
(introduced in later commits).

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/mds/CInode.cc
src/mds/MDCache.cc
src/mds/ScrubHeader.h

index 801b20a1e7f1b6e2724dffd0cbdd4a558720f5a8..636e64ed796f04e127614dfd5a41a7aa6395d6ca 100644 (file)
@@ -4110,7 +4110,8 @@ void CInode::validate_disk_state(CInode::validated_data *results,
     /**
      * Fetch backtrace and set tag if tag is non-empty
      */
-    void fetch_backtrace_and_tag(CInode *in, std::string_view tag,
+    void fetch_backtrace_and_tag(CInode *in,
+                                 std::string_view tag, bool is_internal,
                                  Context *fin, int *bt_r, bufferlist *bt)
     {
       const int64_t pool = in->get_backtrace_pool();
@@ -4121,8 +4122,8 @@ void CInode::validate_disk_state(CInode::validated_data *results,
       in->mdcache->mds->objecter->read(oid, object_locator_t(pool), fetch, CEPH_NOSNAP,
                                       NULL, 0, fin);
       using ceph::encode;
-      if (!tag.empty()) {
-       ObjectOperation scrub_tag;
+      if (!is_internal) {
+        ObjectOperation scrub_tag;
         bufferlist tag_bl;
         encode(tag, tag_bl);
         scrub_tag.setxattr("scrub_tag", tag_bl);
@@ -4153,10 +4154,11 @@ void CInode::validate_disk_state(CInode::validated_data *results,
                                            in->mdcache->mds->finisher);
 
       std::string_view tag = in->scrub_infop->header->get_tag();
+      bool is_internal = in->scrub_infop->header->is_internal_tag();
       // Rather than using the usual CInode::fetch_backtrace,
       // use a special variant that optionally writes a tag in the same
       // operation.
-      fetch_backtrace_and_tag(in, tag, conf, &results->backtrace.ondisk_read_retval, &bl);
+      fetch_backtrace_and_tag(in, tag, is_internal, conf, &results->backtrace.ondisk_read_retval, &bl);
       return false;
     }
 
@@ -4800,12 +4802,8 @@ void CInode::scrub_finished(MDSInternalContextBase **c) {
   if (scrub_infop->header->get_origin() == this) {
     // We are at the point that a tagging scrub was initiated
     LogChannelRef clog = mdcache->mds->clog;
-    if (scrub_infop->header->get_tag().empty()) {
-      clog->info() << "scrub complete";
-    } else {
-      clog->info() << "scrub complete with tag '"
-                   << scrub_infop->header->get_tag() << "'";
-    }
+    clog->info() << "scrub complete with tag '"
+                 << scrub_infop->header->get_tag() << "'";
   }
 }
 
index 94163ab8944f25059bf2f052f9f00aee23575c7a..2d841f77174b8da3cfad7e60315ba6663700e3b0 100644 (file)
@@ -12351,8 +12351,18 @@ void MDCache::enqueue_scrub(
   }
 
   C_MDS_EnqueueScrub *cs = new C_MDS_EnqueueScrub(f, fin);
+
+  bool is_internal = false;
+  std::string tag_str(tag);
+  if (tag_str.empty()) {
+    uuid_d uuid_gen;
+    uuid_gen.generate_random();
+    tag_str = uuid_gen.to_string();
+    is_internal = true;
+  }
+
   cs->header = std::make_shared<ScrubHeader>(
-      tag, force, recursive, repair, f);
+    tag_str, is_internal, force, recursive, repair, f);
 
   mdr->internal_op_finish = cs;
   enqueue_scrub_work(mdr);
index 02acc84fb5207a9a29b4e478e9f00e96b66b97e8..f49598d85e06c913dd054435bfa49f95908ac66d 100644 (file)
@@ -26,10 +26,10 @@ class CInode;
  */
 class ScrubHeader {
 public:
-  ScrubHeader(std::string_view tag_, bool force_, bool recursive_,
-              bool repair_, Formatter *f_)
-      : tag(tag_), force(force_), recursive(recursive_), repair(repair_),
-        formatter(f_), origin(nullptr)
+  ScrubHeader(std::string_view tag_, bool is_tag_internal_, bool force_,
+              bool recursive_, bool repair_, Formatter *f_)
+    : tag(tag_), is_tag_internal(is_tag_internal_), force(force_),
+      recursive(recursive_), repair(repair_), formatter(f_), origin(nullptr)
   {
     ceph_assert(formatter != nullptr);
   }
@@ -41,6 +41,7 @@ public:
   bool get_recursive() const { return recursive; }
   bool get_repair() const { return repair; }
   bool get_force() const { return force; }
+  bool is_internal_tag() const { return is_tag_internal; }
   CInode *get_origin() const { return origin; }
   std::string_view get_tag() const { return tag; }
   Formatter &get_formatter() const { return *formatter; }
@@ -50,6 +51,7 @@ public:
 
 protected:
   const std::string tag;
+  bool is_tag_internal;
   const bool force;
   const bool recursive;
   const bool repair;