From: Yan, Zheng Date: Thu, 10 Dec 2015 11:47:42 +0000 (+0800) Subject: mds: store ScrubHeader refernce in CInode's scrub_info_t X-Git-Tag: v10.1.0~176^2~1^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dad48ecb134668a76f9f82c58bb76d34661d1703;p=ceph.git mds: store ScrubHeader refernce in CInode's scrub_info_t Signed-off-by: Yan, Zheng --- diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index eb74332986cd..b7ccea9d0999 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -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) diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index 7bf21d629bc5..4fc0ba0340ef 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -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() { diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index ad73d1ca3d99..7bf38779505e 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -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 } diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 65dd35b0792d..ca11e0ea6b5b 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -264,6 +264,8 @@ public: /// my own (temporary) stamps and versions for each dirfrag we have std::map 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). diff --git a/src/mds/ScrubStack.cc b/src/mds/ScrubStack.cc index 0d99bebcb95e..aaf7b95724b7 100644 --- a/src/mds/ScrubStack.cc +++ b/src/mds/ScrubStack.cc @@ -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 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, diff --git a/src/mds/ScrubStack.h b/src/mds/ScrubStack.h index b01ee84e5187..96e1383d1818 100644 --- a/src/mds/ScrubStack.h +++ b/src/mds/ScrubStack.h @@ -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. *