From e18001c11b8601d99b2356beb170b242823f7906 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 1 Oct 2010 12:43:20 -0700 Subject: [PATCH] mds: fix stray replica push on _rename_prepare_witness() We need to push all parents of the straydn to the target. This changed a while back with the mdsdir stuff but this bit of code wasn't updated. Updated to mirror send_dentry_unlink(). This fixes a crash like: mds/MDCache.cc: In function 'void MDCache::adjust_subtree_auth(CDir*, std::pair, bool)': mds/MDCache.cc:644: FAILED assert(root) ceph version 0.22~rc (0e67718a365b42969e785f544ea3b4258bb2407f) 1: (MDCache::add_replica_dir(ceph::buffer::list::iterator&, CInode*, int, std::list >&)+0x1c1) [0x536a91] 2: (MDCache::add_replica_stray(ceph::buffer::list&, int)+0xdb) [0x536fab] 3: (Server::handle_slave_rename_prep(MDRequest*)+0x1113) [0x4d5c33] 4: (Server::dispatch_slave_request(MDRequest*)+0x21b) [0x4de80b] 5: (Server::handle_slave_request(MMDSSlaveRequest*)+0x145) [0x4e1955] 6: (MDS::_dispatch(Message*)+0x2598) [0x49e038] ... Signed-off-by: Sage Weil --- src/mds/MDCache.cc | 22 +++++++++++++--------- src/mds/MDCache.h | 2 ++ src/mds/Server.cc | 7 ++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 176c150293806..0abe20e39c741 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -8142,7 +8142,17 @@ CInode *MDCache::add_replica_inode(bufferlist::iterator& p, CDentry *dn, listget_dir()->inode->get_parent_dn()->get_dir(), who, bl); + replicate_dentry(straydn->get_dir()->inode->get_parent_dn(), who, bl); + replicate_inode(straydn->get_dir()->inode, who, bl); + replicate_dir(straydn->get_dir(), who, bl); + replicate_dentry(straydn, who, bl); +} + CDentry *MDCache::add_replica_stray(bufferlist &bl, int from) { list finished; @@ -8317,14 +8327,8 @@ void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn) it != dn->replicas_end(); it++) { MDentryUnlink *unlink = new MDentryUnlink(dn->get_dir()->dirfrag(), dn->name); - if (straydn) { - replicate_inode(get_myin(), it->first, unlink->straybl); - replicate_dir(straydn->get_dir()->inode->get_parent_dn()->get_dir(), it->first, unlink->straybl); - replicate_dentry(straydn->get_dir()->inode->get_parent_dn(), it->first, unlink->straybl); - replicate_inode(straydn->get_dir()->inode, it->first, unlink->straybl); - replicate_dir(straydn->get_dir(), it->first, unlink->straybl); - replicate_dentry(straydn, it->first, unlink->straybl); - } + if (straydn) + replicate_stray(straydn, it->first, unlink->straybl); mds->send_message_mds(unlink, it->first); } } diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 5d2b7e284a97d..086caa3df3431 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -1048,6 +1048,8 @@ public: CDir* forge_replica_dir(CInode *diri, frag_t fg, int from); CDentry *add_replica_dentry(bufferlist::iterator& p, CDir *dir, list& finished); CInode *add_replica_inode(bufferlist::iterator& p, CDentry *dn, list& finished); + + void replicate_stray(CDentry *straydn, int who, bufferlist& bl); CDentry *add_replica_stray(bufferlist &bl, int from); // -- namespace -- diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 7466e1c08aed9..c2e83e8bcd0a0 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4659,11 +4659,8 @@ void Server::_rename_prepare_witness(MDRequest *mdr, int who, CDentry *srcdn, CD destdn->make_path(req->destdnpath); req->now = mdr->now; - if (straydn) { - mdcache->replicate_inode(straydn->get_dir()->inode, who, req->stray); - mdcache->replicate_dir(straydn->get_dir(), who, req->stray); - mdcache->replicate_dentry(straydn, who, req->stray); - } + if (straydn) + mdcache->replicate_stray(straydn, who, req->stray); // srcdn auth will verify our current witness list is sufficient req->witnesses = mdr->more()->witnessed; -- 2.39.5