From: Yan, Zheng Date: Mon, 16 Apr 2018 13:26:46 +0000 (+0800) Subject: mds: automaticly allow multi-active MDS after scrubbing all inodes X-Git-Tag: v13.1.0~2^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=40b3f7e5a5b87b65d735a0d0568e2917599b94c9;p=ceph.git mds: automaticly allow multi-active MDS after scrubbing all inodes Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index e93db51b5c8..93a5f8acac1 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -12296,7 +12296,7 @@ void MDCache::enqueue_scrub_work(MDRequestRef& mdr) return; C_MDS_EnqueueScrub *cs = static_cast(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) : diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 2963e66c9a9..ea2f0fad274 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -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); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index b26c9063e31..35826924fde 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -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(); diff --git a/src/mds/MDSRank.h b/src/mds/MDSRank.h index 983a6c3c7d6..1f7331a6334 100644 --- a/src/mds/MDSRank.h +++ b/src/mds/MDSRank.h @@ -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& scrubop_vec); diff --git a/src/mds/ScrubHeader.h b/src/mds/ScrubHeader.h index 753216199a1..ea1ad754329 100644 --- a/src/mds/ScrubHeader.h +++ b/src/mds/ScrubHeader.h @@ -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; } diff --git a/src/mds/SnapServer.h b/src/mds/SnapServer.h index 3475099d350..bcc02e2d447 100644 --- a/src/mds/SnapServer.h +++ b/src/mds/SnapServer.h @@ -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 {