From: Yan, Zheng Date: Mon, 19 Nov 2012 02:43:34 +0000 (+0800) Subject: mds: fix anchor table update X-Git-Tag: v0.55~29^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a3aad3c3c58ffd7cd556275cd1c7dbc69b3eb4dd;p=ceph.git mds: fix anchor table update The reference count of an anchor table entry that corresponds to directory is number of anchored inodes under the directory. But when updating anchor trace for an directory inode, the code only increases/decreases its new/old ancestor anchor table entries' reference counts by one. This patch probably resolves BUG #1850. Signed-off-by: Yan, Zheng --- diff --git a/src/mds/AnchorServer.cc b/src/mds/AnchorServer.cc index 731ec9633bb4..cd2e625e49df 100644 --- a/src/mds/AnchorServer.cc +++ b/src/mds/AnchorServer.cc @@ -73,7 +73,7 @@ bool AnchorServer::add(inodeno_t ino, inodeno_t dirino, __u32 dn_hash, return true; } -void AnchorServer::inc(inodeno_t ino) +void AnchorServer::inc(inodeno_t ino, int ref) { dout(7) << "inc " << ino << dendl; @@ -81,7 +81,7 @@ void AnchorServer::inc(inodeno_t ino) while (1) { Anchor &anchor = anchor_map[ino]; - anchor.nref++; + anchor.nref += ref; anchor.updated = version; dout(10) << "inc now " << anchor << dendl; @@ -92,14 +92,14 @@ void AnchorServer::inc(inodeno_t ino) } } -void AnchorServer::dec(inodeno_t ino) +void AnchorServer::dec(inodeno_t ino, int ref) { dout(7) << "dec " << ino << dendl; assert(anchor_map.count(ino)); while (true) { Anchor &anchor = anchor_map[ino]; - anchor.nref--; + anchor.nref -= ref; anchor.updated = version; if (anchor.nref == 0) { @@ -186,13 +186,14 @@ void AnchorServer::_commit(version_t tid) if (anchor_map.count(ino)) { dout(7) << "commit " << tid << " update " << ino << dendl; + int ref = anchor_map[ino].nref; // remove old - dec(ino); + dec(ino, ref); // add new for (unsigned i=0; i