From: Yan, Zheng Date: Mon, 23 Apr 2018 06:38:59 +0000 (+0800) Subject: mds: don't discover inode/dirfrag when mds is in 'starting' state X-Git-Tag: v12.2.6~77^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c3f7794b947681dc8cf4710613a399b9e7d17242;p=ceph.git mds: don't discover inode/dirfrag when mds is in 'starting' state Signed-off-by: "Yan, Zheng" Fixes: http://tracker.ceph.com/issues/23812 (cherry picked from commit edab76f0e2cd31a36308575c24428e785e8677a4) Conflicts: src/mds/MDSRank.cc --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index c10cc2fe4f8d..ef3516a2db05 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -613,6 +613,24 @@ void MDCache::open_mydir_inode(MDSInternalContextBase *c) gather.activate(); } +void MDCache::open_mydir_frag(MDSInternalContextBase *c) +{ + open_mydir_inode( + new MDSInternalContextWrapper(mds, + new FunctionContext([this, c](int r) { + if (r < 0) { + c->complete(r); + return; + } + CDir *mydir = myin->get_or_open_dirfrag(this, frag_t()); + assert(mydir); + adjust_subtree_auth(mydir, mds->get_nodeid()); + mydir->fetch(c); + }) + ) + ); +} + void MDCache::open_root() { dout(10) << "open_root" << dendl; diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 3d3f9686414b..7b003c140a11 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -892,6 +892,7 @@ public: void open_root_inode(MDSInternalContextBase *c); void open_root(); void open_mydir_inode(MDSInternalContextBase *c); + void open_mydir_frag(MDSInternalContextBase *c); void populate_mydir(); void _create_system_file(CDir *dir, const char *name, CInode *in, MDSInternalContextBase *fin); diff --git a/src/mds/MDSRank.cc b/src/mds/MDSRank.cc index 5791b845efec..a888f2d07b50 100644 --- a/src/mds/MDSRank.cc +++ b/src/mds/MDSRank.cc @@ -1094,15 +1094,19 @@ void MDSRank::boot_start(BootStep step, int r) MDSGatherBuilder gather(g_ceph_context, new C_MDS_BootStart(this, MDS_BOOT_PREPARE_LOG)); - mdcache->open_mydir_inode(gather.new_sub()); - - if (is_starting() || - whoami == mdsmap->get_root()) { // load root inode off disk if we are auth - mdcache->open_root_inode(gather.new_sub()); - } else { - // replay. make up fake root inode to start with - (void)mdcache->create_root_inode(); - } + if (is_starting()) { + // load mydir frag for the first log segment (creating subtree map) + mdcache->open_mydir_frag(gather.new_sub()); + } else { + mdcache->open_mydir_inode(gather.new_sub()); + } + + if (whoami == mdsmap->get_root()) { // load root inode off disk if we are auth + mdcache->open_root_inode(gather.new_sub()); + } else if (is_any_replay()) { + // replay. make up fake root inode to start with + mdcache->create_root_inode(); + } gather.activate(); } break; @@ -1168,16 +1172,7 @@ void MDSRank::starting_done() assert(is_starting()); request_state(MDSMap::STATE_ACTIVE); - mdcache->open_root(); - - if (mdcache->is_open()) { - mdlog->start_new_segment(); - } else { - mdcache->wait_for_open(new MDSInternalContextWrapper(this, - new FunctionContext([this] (int r) { - mdlog->start_new_segment(); - }))); - } + mdlog->start_new_segment(); } @@ -1462,7 +1457,8 @@ void MDSRank::active_start() { dout(1) << "active_start" << dendl; - if (last_state == MDSMap::STATE_CREATING) { + if (last_state == MDSMap::STATE_CREATING || + last_state == MDSMap::STATE_STARTING) { mdcache->open_root(); } @@ -1694,7 +1690,7 @@ void MDSRankDispatcher::handle_mds_map( // REJOIN // is everybody finally rejoining? - if (is_starting() || is_rejoin() || is_clientreplay() || is_active() || is_stopping()) { + if (is_rejoin() || is_clientreplay() || is_active() || is_stopping()) { // did we start? if (!oldmap->is_rejoining() && mdsmap->is_rejoining()) rejoin_joint_start();