From a4bdcdd2a2c36440add18b9fde4d945f0d79e4aa Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 17 Mar 2010 11:08:21 -0700 Subject: [PATCH] mds: fix up root/base inode special cases --- src/mds/AnchorServer.cc | 4 ++-- src/mds/MDCache.cc | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mds/AnchorServer.cc b/src/mds/AnchorServer.cc index 4ed27235055be..b0a4ca762ace1 100644 --- a/src/mds/AnchorServer.cc +++ b/src/mds/AnchorServer.cc @@ -52,7 +52,7 @@ bool AnchorServer::add(inodeno_t ino, inodeno_t dirino, __u32 dn_hash) //dout(17) << "add " << ino << " dirfrag " << dirfrag << dendl; // parent should be there - assert(dirino == MDS_INO_ROOT || // base case, + assert(MDS_INO_IS_BASE(dirino) || // base case, anchor_map.count(dirino)); // or have it if (anchor_map.count(ino) == 0) { @@ -242,7 +242,7 @@ void AnchorServer::handle_query(MMDSTableRequest *req) dout(10) << "handle_lookup adding " << anchor << dendl; trace.insert(trace.begin(), anchor); // lame FIXME - if (anchor.dirino == MDS_INO_ROOT) + if (MDS_INO_IS_BASE(anchor.dirino)) break; curino = anchor.dirino; } diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 0c97da16773fe..6c48752542dc7 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -730,7 +730,7 @@ void MDCache::try_subtree_merge_at(CDir *dir) // merge with parent? CDir *parent = dir; - if (dir->ino() != MDS_INO_ROOT) + if (!dir->inode->is_base()) parent = get_subtree_root(dir->get_parent_dir()); if (parent != dir && // we have a parent, @@ -7365,15 +7365,15 @@ void MDCache::handle_discover(MDiscover *dis) cur = root; } - else if (dis->get_base_ino() == MDS_INO_STRAY(whoami)) { + else if (dis->get_base_ino() == MDS_INO_MDSDIR(whoami)) { // wants root dout(7) << "handle_discover from mds" << from - << " wants stray + " << dis->get_want().get_path() + << " wants mdsdir + " << dis->get_want().get_path() << " snap " << snapid << dendl; reply->starts_with = MDiscoverReply::INODE; - replicate_inode(stray, from, reply->trace); - dout(10) << "added stray " << *stray << dendl; + replicate_inode(myin, from, reply->trace); + dout(10) << "added mdsdir " << *myin << dendl; cur = stray; } @@ -7424,7 +7424,7 @@ void MDCache::handle_discover(MDiscover *dis) } else { // requester explicity specified the frag fg = dis->get_base_dir_frag(); - assert(dis->wants_base_dir() || dis->get_want_ino() || dis->get_base_ino() == MDS_INO_ROOT); + assert(dis->wants_base_dir() || dis->get_want_ino() || MDS_INO_IS_BASE(dis->get_base_ino())); } CDir *curdir = cur->get_dirfrag(fg); @@ -7880,6 +7880,8 @@ CInode *MDCache::add_replica_inode(bufferlist::iterator& p, CDentry *dn, listino() == MDS_INO_ROOT) in->inode_auth.first = 0; + else if (in->is_mdsdir()) + in->inode_auth.first = in->ino() - MDS_INO_MDSDIR_OFFSET; dout(10) << "add_replica_inode added " << *in << dendl; if (dn) { assert(dn->get_linkage()->is_null()); @@ -8720,6 +8722,8 @@ void MDCache::show_subtrees(int dbl) if (dir->ino() == MDS_INO_ROOT) assert(dir->inode == root); + if (dir->ino() == MDS_INO_MDSDIR(mds->get_nodeid())) + assert(dir->inode == myin); if (dir->ino() == MDS_INO_STRAY(mds->get_nodeid())) assert(dir->inode == stray); -- 2.39.5