]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: store ScrubHeader refernce in CInode's scrub_info_t
authorYan, Zheng <zyan@redhat.com>
Thu, 10 Dec 2015 11:47:42 +0000 (19:47 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 7 Mar 2016 07:59:13 +0000 (15:59 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/CDentry.cc
src/mds/CDentry.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/ScrubStack.cc
src/mds/ScrubStack.h

index eb74332986cd0811c329459e78980264f48282cd..b7ccea9d09992a897544edaf8b5bb5e131ff419e 100644 (file)
@@ -623,7 +623,7 @@ std::string CDentry::linkage_t::get_remote_d_type_string() const
 }
 
 void CDentry::scrub_initialize(CDir *parent, bool recurse, bool children,
-                        ScrubHeaderRefConst header,
+                              const ScrubHeaderRefConst& header,
                                Context *f)
 {
   if (!scrub_infop)
index 7bf21d629bc56d9f01f674fdee8a2223d41541f7..4fc0ba0340efcd43881a2aba4171f941d179f8ab 100644 (file)
@@ -180,7 +180,7 @@ public:
     return scrub_infop;
   }
   void scrub_initialize(CDir *parent, bool recurse, bool children,
-                        ScrubHeaderRefConst header,
+                        const ScrubHeaderRefConst& header,
                         Context *f);
   void scrub_finished(Context **c);
   void scrub_children_finished() {
index ad73d1ca3d99e10c9d327ef1d61b52353ec820c3..7bf38779505e291a515339c33b2aea24bc40f12f 100644 (file)
@@ -3774,10 +3774,9 @@ void CInode::validate_disk_state(CInode::validated_data *results,
 
       // Whether we have a tag to apply depends on ScrubHeader (if one is
       // present)
-      if (in->get_parent_dn() != nullptr &&
-          in->get_parent_dn()->scrub_info()->header != nullptr) {
+      if (in->scrub_infop && in->scrub_infop->header) {
         // I'm a non-orphan, so look up my ScrubHeader via my linkage
-        const std::string &tag = in->get_parent_dn()->scrub_info()->header->tag;
+        const std::string &tag = in->scrub_infop->header->tag;
         // Rather than using the usual CInode::fetch_backtrace,
         // use a special variant that optionally writes a tag in the same
         // operation.
@@ -4155,10 +4154,9 @@ void CInode::scrub_maybe_delete_info()
   }
 }
 
-void CInode::scrub_initialize(version_t scrub_version)
+void CInode::scrub_initialize(const ScrubHeaderRefConst& header)
 {
-  dout(20) << __func__ << " with scrub_version "
-           << scrub_version << dendl;
+  dout(20) << __func__ << " with scrub_version " << get_version() << dendl;
   assert(!scrub_infop || !scrub_infop->scrub_in_progress);
   scrub_info();
   if (!scrub_infop)
@@ -4177,8 +4175,9 @@ void CInode::scrub_initialize(version_t scrub_version)
     }
   }
   scrub_infop->scrub_in_progress = true;
-  scrub_infop->scrub_start_version = scrub_version;
+  scrub_infop->scrub_start_version = get_version();
   scrub_infop->scrub_start_stamp = ceph_clock_now(g_ceph_context);
+  scrub_infop->header = header;
   // right now we don't handle remote inodes
 }
 
index 65dd35b0792dc997ab7976e0d464f26df27cf435..ca11e0ea6b5b298a340bbfde1a9847aed51612fe 100644 (file)
@@ -264,6 +264,8 @@ public:
     /// my own (temporary) stamps and versions for each dirfrag we have
     std::map<frag_t, scrub_stamp_info_t> dirfrag_stamps;
 
+    ScrubHeaderRefConst header;
+
     scrub_info_t() : scrub_stamp_info_t(), last_scrub_dirty(false),
         scrub_in_progress(false) {}
   };
@@ -281,7 +283,7 @@ public:
    * @param scrub_version What version are we scrubbing at (usually, parent
    * directory's get_projected_version())
    */
-  void scrub_initialize(version_t scrub_version);
+  void scrub_initialize(const ScrubHeaderRefConst& header);
   /**
    * Get the next dirfrag to scrub. Gives you a frag_t in output param which
    * you must convert to a CDir (and possibly load off disk).
index 0d99bebcb95eaeb0b089c0079a732ff993933fa0..aaf7b95724b748504ca8892a9be21a9e913755d1 100644 (file)
@@ -58,7 +58,7 @@ void ScrubStack::pop_dentry(CDentry *dn)
 }
 
 void ScrubStack::_enqueue_dentry(CDentry *dn, CDir *parent, bool recursive,
-    bool children, ScrubHeaderRefConst header,
+    bool children, const ScrubHeaderRefConst& header,
     MDSInternalContextBase *on_finish, bool top)
 {
   dout(10) << __func__ << " with {" << *dn << "}"
@@ -73,7 +73,7 @@ void ScrubStack::_enqueue_dentry(CDentry *dn, CDir *parent, bool recursive,
 }
 
 void ScrubStack::enqueue_dentry(CDentry *dn, bool recursive, bool children,
-                                ScrubHeaderRefConst header,
+                                const ScrubHeaderRefConst& header,
                                  MDSInternalContextBase *on_finish, bool top)
 {
   _enqueue_dentry(dn, NULL, recursive, children, header, on_finish, top);
@@ -160,7 +160,7 @@ void ScrubStack::scrub_dir_dentry(CDentry *dn,
     // the stack... or actually is that right?  Should we perhaps
     // only see ourselves once on the way down and once on the way
     // back up again, and not do this?
-    in->scrub_initialize(in->get_version());
+    in->scrub_initialize(dn->scrub_info()->header);
   }
 
   list<frag_t> scrubbing_frags;
@@ -194,9 +194,6 @@ void ScrubStack::scrub_dir_dentry(CDentry *dn,
     } else {
       bool ready = get_next_cdir(in, &cur_dir);
       dout(20) << __func__ << " get_next_cdir ready=" << ready << dendl;
-      if (cur_dir) {
-        cur_dir->scrub_initialize();
-      }
 
       if (ready && cur_dir) {
         scrubbing_cdirs.push_back(cur_dir);
@@ -214,7 +211,8 @@ void ScrubStack::scrub_dir_dentry(CDentry *dn,
     bool frag_added_children = false;
     bool frag_terminal = true;
     bool frag_done = false;
-    scrub_dirfrag(cur_dir, &frag_added_children, &frag_terminal, &frag_done);
+    scrub_dirfrag(cur_dir, dn->scrub_info()->scrub_recursive,
+                 &frag_added_children, &frag_terminal, &frag_done);
     if (frag_done) {
       // FIXME is this right?  Can we end up hitting this more than
       // once and is that a problem?
@@ -314,8 +312,9 @@ void ScrubStack::scrub_dir_dentry_final(CDentry *dn)
   return;
 }
 
-void ScrubStack::scrub_dirfrag(CDir *dir, bool *added_children,
-                               bool *is_terminal, bool *done)
+void ScrubStack::scrub_dirfrag(CDir *dir, bool recursive,
+                              bool *added_children,
+                              bool *is_terminal, bool *done)
 {
   assert(dir != NULL);
 
@@ -324,6 +323,8 @@ void ScrubStack::scrub_dirfrag(CDir *dir, bool *added_children,
   *is_terminal = false;
   *done = false;
 
+  const ScrubHeaderRefConst& header = dir->get_inode()->scrub_info()->header;
+
   if (!dir->scrub_info()->directory_scrubbing) {
     // Get the frag complete before calling
     // scrub initialize, so that it can populate its lists
@@ -386,14 +387,12 @@ void ScrubStack::scrub_dirfrag(CDir *dir, bool *added_children,
     // never get random IO errors here.
     assert(r == 0);
 
-    CDentry *parent_dn = dir->get_inode()->get_parent_dn();
-    ScrubHeaderRefConst header = parent_dn->scrub_info()->header;
 
     // FIXME: Do I *really* need to construct a kick context for every
     // single dentry I'm going to scrub?
     _enqueue_dentry(dn,
         dir,
-        parent_dn->scrub_info()->scrub_recursive,
+       recursive,
         false,  // We are already recursing so scrub_children not meaningful
         header,
        NULL,
index b01ee84e518720a19cb0b1932f59b5fb08359481..96e1383d1818098b42c82ef168bfb2b75e068377 100644 (file)
@@ -79,7 +79,7 @@ public:
    *               was initiated
    */
   void enqueue_dentry_top(CDentry *dn, bool recursive, bool children,
-                          ScrubHeaderRefConst header,
+                          const ScrubHeaderRefConst& header,
                           MDSInternalContextBase *on_finish) {
     enqueue_dentry(dn, recursive, children, header, on_finish, true);
   }
@@ -87,7 +87,7 @@ public:
    * starting this one.
    */
   void enqueue_dentry_bottom(CDentry *dn, bool recursive, bool children,
-                             ScrubHeaderRefConst header,
+                             const ScrubHeaderRefConst& header,
                              MDSInternalContextBase *on_finish) {
     enqueue_dentry(dn, recursive, children, header, on_finish, false);
   }
@@ -98,10 +98,10 @@ private:
    * the given scrub params, and then try and kick off more scrubbing.
    */
   void enqueue_dentry(CDentry *dn, bool recursive, bool children,
-                      ScrubHeaderRefConst header,
+                      const ScrubHeaderRefConst& header,
                       MDSInternalContextBase *on_finish, bool top);
   void _enqueue_dentry(CDentry *dn, CDir *parent, bool recursive, bool children,
-                      ScrubHeaderRefConst header,
+                      const ScrubHeaderRefConst& header,
                        MDSInternalContextBase *on_finish, bool top);
   /**
    * Kick off as many scrubs as are appropriate, based on the current
@@ -175,8 +175,8 @@ private:
    * progress. Try again later.
    *
    */
-  void scrub_dirfrag(CDir *dir, bool *added_children, bool *is_terminal,
-                    bool *done);
+  void scrub_dirfrag(CDir *dir, bool recursive,
+                    bool *added_children, bool *is_terminal, bool *done);
   /**
    * Scrub a directory-representing dentry.
    *