From bc273957af2224d028626a961fdb1bf3bc153f40 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 20 Jun 2011 17:55:54 -0700 Subject: [PATCH] AnchorServer: overwrite old Anchor backpointers when proper. Sometimes when we do an AnchorTable update, it's because the inode in question got moved. However, if the inode had multiple references, its Anchor wasn't removed by decrementing its count, and so the add function simply noted that it already had the Anchor and returned. This obviously wasn't the proper behavior in cases where the inode was getting moved -- we want to update its back pointer! So do so. Signed-off-by: Greg Farnum --- src/mds/AnchorServer.cc | 12 +++++++++--- src/mds/AnchorServer.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mds/AnchorServer.cc b/src/mds/AnchorServer.cc index 5cc63b3ab8adc..14b541cc9038b 100644 --- a/src/mds/AnchorServer.cc +++ b/src/mds/AnchorServer.cc @@ -47,7 +47,8 @@ void AnchorServer::dump() * basic updates */ -bool AnchorServer::add(inodeno_t ino, inodeno_t dirino, __u32 dn_hash) +bool AnchorServer::add(inodeno_t ino, inodeno_t dirino, __u32 dn_hash, + bool replace) { //dout(17) << "add " << ino << " dirfrag " << dirfrag << dendl; @@ -60,6 +61,11 @@ bool AnchorServer::add(inodeno_t ino, inodeno_t dirino, __u32 dn_hash) anchor_map[ino] = Anchor(ino, dirino, dn_hash, 0, version); dout(7) << "add added " << anchor_map[ino] << dendl; return true; + } else if (replace) { + anchor_map[ino].dirino = dirino; + anchor_map[ino].dn_hash = dn_hash; + dout(7) << "add had old Anchor, updated it to " + << anchor_map[ino] << dendl; } else { dout(7) << "add had " << anchor_map[ino] << dendl; return false; @@ -130,7 +136,7 @@ void AnchorServer::_prepare(bufferlist &bl, uint64_t reqid, int bymds) // make sure trace is in table dout(25) << "trace.size=" << trace.size() << dendl; for (unsigned i=0; i