From: Yan, Zheng Date: Tue, 10 Nov 2015 13:23:43 +0000 (+0800) Subject: mds: re-use C_KickOffScrubs context X-Git-Tag: v10.0.1~51^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=48186fc4e8a5721c2acf39d1312ecfbcee660e15;p=ceph.git mds: re-use C_KickOffScrubs context Signed-off-by: Yan, Zheng --- diff --git a/src/mds/ScrubStack.cc b/src/mds/ScrubStack.cc index f4ada6ed24b9..9fe1c4622d4f 100644 --- a/src/mds/ScrubStack.cc +++ b/src/mds/ScrubStack.cc @@ -101,7 +101,7 @@ void ScrubStack::kick_off_scrubs() if (curi->is_file()) { if (!cur->scrub_info()->on_finish) - cur->scrub_set_finisher(new C_KickOffScrubs(mdcache->mds, this)); + cur->scrub_set_finisher(&scrub_kick); scrub_file_dentry(cur); can_continue = true; } else { @@ -229,7 +229,7 @@ void ScrubStack::scrub_dir_dentry(CDentry *dn, assert (!*added_children); // can't do this if children are still pending if (!dn->scrub_info()->on_finish) - dn->scrub_set_finisher(new C_KickOffScrubs(mdcache->mds, this)); + dn->scrub_set_finisher(&scrub_kick); // OK, so now I can... fire off a validate on the dir inode, and // when it completes, come through here again, noticing that we've @@ -255,8 +255,7 @@ bool ScrubStack::get_next_cdir(CInode *in, CDir **new_dir) dout(25) << "looking up new frag " << next_frag << dendl; CDir *next_dir = in->get_or_open_dirfrag(mdcache, next_frag); if (!next_dir->is_complete()) { - C_KickOffScrubs *c = new C_KickOffScrubs(mdcache->mds, this); - next_dir->fetch(c); + next_dir->fetch(&scrub_kick); dout(25) << "fetching frag from RADOS" << dendl; return false; } @@ -325,7 +324,7 @@ void ScrubStack::scrub_dirfrag(CDir *dir, bool *added_children, // scrub initialize, so that it can populate its lists // of dentries. if (!dir->is_complete()) { - dir->fetch(new C_KickOffScrubs(mdcache->mds, this)); + dir->fetch(&scrub_kick); return; } @@ -334,13 +333,11 @@ void ScrubStack::scrub_dirfrag(CDir *dir, bool *added_children, int r = 0; while(r == 0) { - MDSInternalContext *kick = new C_KickOffScrubs(mdcache->mds, this); CDentry *dn = NULL; - r = dir->scrub_dentry_next(kick, &dn); + r = dir->scrub_dentry_next(&scrub_kick, &dn); if (r != EAGAIN) { // ctx only used by scrub_dentry_next in EAGAIN case // FIXME It's kind of annoying to keep allocating and deleting a ctx here - delete kick; } if (r == EAGAIN) { @@ -438,3 +435,5 @@ void ScrubStack::_validate_inode_done(CDentry *dn, int r, } } +ScrubStack::C_KickOffScrubs::C_KickOffScrubs(MDCache *mdcache, ScrubStack *s) + : MDSInternalContext(mdcache->mds), stack(s) { } diff --git a/src/mds/ScrubStack.h b/src/mds/ScrubStack.h index fa99859fd278..c9bbbd077050 100644 --- a/src/mds/ScrubStack.h +++ b/src/mds/ScrubStack.h @@ -27,7 +27,7 @@ class MDCache; class Finisher; class ScrubStack { - protected: +protected: /// A finisher needed so that we don't re-enter kick_off_scrubs Finisher *finisher; @@ -37,6 +37,19 @@ class ScrubStack { int scrubs_in_progress; ScrubStack *scrubstack; // hack for dout int stack_size; + + class C_KickOffScrubs : public MDSInternalContext { + ScrubStack *stack; + public: + C_KickOffScrubs(MDCache *mdcache, ScrubStack *s); + void finish(int r) { } + void complete(int r) { + stack->kick_off_scrubs(); + // don't delete self + } + }; + C_KickOffScrubs scrub_kick; + public: MDCache *mdcache; ScrubStack(MDCache *mdc, Finisher *finisher_) : @@ -45,6 +58,7 @@ public: scrubs_in_progress(0), scrubstack(this), stack_size(0), + scrub_kick(mdc, this), mdcache(mdc) {} ~ScrubStack() { assert(dentry_stack.empty()); @@ -181,17 +195,6 @@ private: */ bool get_next_cdir(CInode *in, CDir **new_dir); - class C_KickOffScrubs : public MDSInternalContext { - ScrubStack *stack; - public: - C_KickOffScrubs(MDSRank *mds, ScrubStack *s) - : MDSInternalContext(mds), stack(s) - { - } - void finish(int r){ - stack->kick_off_scrubs(); - } - }; }; #endif /* SCRUBSTACK_H_ */