]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: automaticly allow multi-active MDS after scrubbing all inodes
authorYan, Zheng <zyan@redhat.com>
Mon, 16 Apr 2018 13:26:46 +0000 (21:26 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 19 Apr 2018 04:56:38 +0000 (12:56 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSRank.cc
src/mds/MDSRank.h
src/mds/ScrubHeader.h
src/mds/SnapServer.h

index e93db51b5c8c33a70e7fe421dd97ccaebcc6e049..93a5f8acac1eceb2d4b5c67549f3aae827a49b5a 100644 (file)
@@ -12296,7 +12296,7 @@ void MDCache::enqueue_scrub_work(MDRequestRef& mdr)
     return;
 
   C_MDS_EnqueueScrub *cs = static_cast<C_MDS_EnqueueScrub*>(mdr->internal_op_finish);
-  ScrubHeaderRef &header = cs->header;
+  ScrubHeaderRef header = cs->header;
 
   // Cannot scrub same dentry twice at same time
   if (in->scrub_infop && in->scrub_infop->scrub_in_progress) {
@@ -12308,8 +12308,16 @@ void MDCache::enqueue_scrub_work(MDRequestRef& mdr)
 
   header->set_origin(in);
 
-  Context *fin = nullptr;
-  if (!header->get_recursive()) {
+  Context *fin;
+  if (header->get_recursive()) {
+    header->get_origin()->get(CInode::PIN_SCRUBQUEUE);
+    fin = new MDSInternalContextWrapper(mds,
+           new FunctionContext([this, header](int r) {
+             recursive_scrub_finish(header);
+             header->get_origin()->put(CInode::PIN_SCRUBQUEUE);
+           })
+         );
+  } else {
     fin = cs->take_finisher();
   }
 
@@ -12352,6 +12360,22 @@ void MDCache::enqueue_scrub_work(MDRequestRef& mdr)
   return;
 }
 
+void MDCache::recursive_scrub_finish(const ScrubHeaderRef& header)
+{
+  if (header->get_origin()->is_base() &&
+      header->get_force() && header->get_repair()) {
+    // notify snapserver that base directory is recursively scrubbed.
+    // After both root and mdsdir are recursively scrubbed, snapserver
+    // knows that all old format snaprealms are converted to the new
+    // format.
+    if (mds->mdsmap->get_num_in_mds() == 1 &&
+       mds->mdsmap->get_num_failed_mds() == 0 &&
+       mds->mdsmap->get_tableserver() == mds->get_nodeid()) {
+      mds->mark_base_recursively_scrubbed(header->get_origin()->ino());
+    }
+  }
+}
+
 struct C_MDC_RespondInternalRequest : public MDCacheLogContext {
   MDRequestRef mdr;
   C_MDC_RespondInternalRequest(MDCache *c, MDRequestRef& m) :
index 2963e66c9a92bd81ffb8b7a98abd5717e0f5a0d3..ea2f0fad2745658850ce39d0b544f37d98dd7b8d 100644 (file)
@@ -1227,6 +1227,7 @@ protected:
    * long time)
    */
   void enqueue_scrub_work(MDRequestRef& mdr);
+  void recursive_scrub_finish(const ScrubHeaderRef& header);
   void repair_inode_stats_work(MDRequestRef& mdr);
   void repair_dirfrag_stats_work(MDRequestRef& mdr);
   void upgrade_inode_snaprealm_work(MDRequestRef& mdr);
index b26c9063e31206c4c1d147f336feb29d1ad1395c..35826924fde496efc456cc45c2ec095c36e90b08 100644 (file)
@@ -281,6 +281,12 @@ void MDSRank::set_mdsmap_multimds_snaps_allowed()
   already_sent = true;
 }
 
+void MDSRank::mark_base_recursively_scrubbed(inodeno_t ino)
+{
+  if (mdsmap->get_tableserver() == whoami)
+    snapserver->mark_base_recursively_scrubbed(ino);
+}
+
 void MDSRankDispatcher::tick()
 {
   heartbeat_reset();
index 983a6c3c7d62c2e39c79f04824c22899cc28906a..1f7331a633495d4b80b266e6369d2c101010420d 100644 (file)
@@ -427,6 +427,8 @@ class MDSRank {
     bool evict_client(int64_t session_id, bool wait, bool blacklist,
                       std::stringstream& ss, Context *on_killed=nullptr);
 
+    void mark_base_recursively_scrubbed(inodeno_t ino);
+
   protected:
     void dump_clientreplay_status(Formatter *f) const;
     void command_scrub_path(Formatter *f, std::string_view path, vector<string>& scrubop_vec);
index 753216199a1c1c335d353f365ac2254986197323..ea1ad7543295b289748a4948bbf7c47a93216f04 100644 (file)
@@ -41,7 +41,7 @@ public:
   bool get_recursive() const { return recursive; }
   bool get_repair() const { return repair; }
   bool get_force() const { return force; }
-  const CInode *get_origin() const { return origin; }
+  CInode *get_origin() const { return origin; }
   std::string_view get_tag() const { return tag; }
   Formatter &get_formatter() const { return *formatter; }
 
index 3475099d35015c869e5762d2db784447b7f52130..bcc02e2d447ede4aabdc6db4bec8e3286188213c 100644 (file)
@@ -36,6 +36,9 @@ protected:
 
   version_t last_checked_osdmap;
 
+  bool root_scrubbed = false; // all snaprealms under root are converted?
+  bool mdsdir_scrubbed = false; // all snaprealms under ~mds0 are converted?
+
   void encode_server_state(bufferlist& bl) const override {
     ENCODE_START(5, 3, bl);
     encode(last_snap, bl);
@@ -97,8 +100,17 @@ public:
 
   void check_osd_map(bool force);
 
+  void mark_base_recursively_scrubbed(inodeno_t ino) {
+    if (ino ==  MDS_INO_ROOT)
+      root_scrubbed = true;
+    else if (ino == MDS_INO_MDSDIR(rank))
+      mdsdir_scrubbed = true;
+    else
+      assert(0);
+  }
   bool can_allow_multimds_snaps() const {
-    return snaps.empty() || snaps.begin()->first >= snaprealm_v2_since;
+    return (root_scrubbed && mdsdir_scrubbed) ||
+          snaps.empty() || snaps.begin()->first >= snaprealm_v2_since;
   }
 
   void encode(bufferlist& bl) const {