From 7e07b3a38b22bca86f4b7fa340f6184f0a634501 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 19 Jun 2008 16:39:03 -0700 Subject: [PATCH] Revert "mds: fixed rename ancestor thing.. again" This reverts commit a672ab23145c899dc095b955e42dfbf7478b647c. --- src/mds/CDentry.cc | 10 ++++++++++ src/mds/CDentry.h | 2 ++ src/mds/CInode.cc | 11 ----------- src/mds/CInode.h | 1 - src/mds/Server.cc | 21 ++++++++------------- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index 8fc44b462b66c..d083a0d999ea3 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -190,6 +190,16 @@ void CDentry::mark_new() state_set(STATE_NEW); } +bool CDentry::is_parent_of(CDentry *other) +{ + while (other) { + if (other == this) + return true; + other = other->get_dir()->get_inode()->get_parent_dn(); + } + return false; +} + void CDentry::make_path_string(string& s) { if (dir) { diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index fab43d0509c60..39bb6596b50c2 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -191,6 +191,8 @@ public: const CDentry& operator= (const CDentry& right); // misc + bool is_parent_of(CDentry *other); + void make_path_string(string& s); void make_path(filepath& fp); void make_anchor_trace(vector& trace, CInode *in); diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 69ef74d10e3bf..599ecd8b43274 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -389,17 +389,6 @@ CInode *CInode::get_parent_inode() } -bool CInode::is_ancestor_of(CInode *other) -{ - while (other) { - if (other == this) - return true; - if (!get_parent_dn()) - break; - other = get_parent_dn()->get_dir()->get_inode(); - } - return false; -} void CInode::make_path_string(string& s) { diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 8a6008bce9b56..33427cb4b4642 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -319,7 +319,6 @@ private: } // -- misc -- - bool is_ancestor_of(CInode *other); void make_path_string(string& s); void make_path(filepath& s); void make_anchor_trace(vector& trace); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index d3933f7732b6b..bf47fa127606b 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -3040,26 +3040,21 @@ void Server::handle_client_rename(MDRequest *mdr) if (common) { dout(10) << "rename src and dest traces share common dentry " << *common << dendl; } else { - CInode *srcbase = mdcache->get_inode(srcpath.get_ino()); - CInode *destbase = mdcache->get_inode(destpath.get_ino()); - // ok, extend srctrace toward root until it is an ancestor of desttrace. - while (srcbase != destbase && - !srcbase->is_ancestor_of(destbase)) { + while (srctrace[0] != desttrace[0] && + !srctrace[0]->is_parent_of(desttrace[0])) { srctrace.insert(srctrace.begin(), - srcbase->get_parent_dn()); - srcbase = srctrace[0]->get_dir()->get_inode(); - dout(10) << "rename prepended srctrace with " << *srctrace[0] << dendl; + srctrace[0]->get_dir()->get_inode()->get_parent_dn()); + dout(10) << "rename prepending srctrace with " << *srctrace[0] << dendl; } // then, extend destpath until it shares the same parent as srcpath. - while (srcbase != destbase) { + while (desttrace[0] != srctrace[0]) { desttrace.insert(desttrace.begin(), - destbase->get_parent_dn()); - destbase = desttrace[0]->get_dir()->get_inode(); - dout(10) << "rename prepended desttrace with " << *desttrace[0] << dendl; + desttrace[0]->get_dir()->get_inode()->get_parent_dn()); + dout(10) << "rename prepending desttrace with " << *desttrace[0] << dendl; } - dout(10) << "rename src and dest traces now share common ancestor " << *srcbase << dendl; + dout(10) << "rename src and dest traces now share common dentry " << *desttrace[0] << dendl; } } -- 2.39.5