[PATCH 02/16] mds: fix anchor table update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Yan, Zheng" <zheng.z.yan@xxxxxxxxx>

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 <zheng.z.yan@xxxxxxxxx>
---
 src/mds/AnchorServer.cc | 13 +++++++------
 src/mds/AnchorServer.h  |  4 ++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/mds/AnchorServer.cc b/src/mds/AnchorServer.cc
index 731ec96..cd2e625 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<trace.size(); i++) 
 	add(trace[i].ino, trace[i].dirino, trace[i].dn_hash, true);
-      inc(ino);
+      inc(ino, ref);
     } else {
       dout(7) << "commit " << tid << " update " << ino << " -- DNE" << dendl;
     }
diff --git a/src/mds/AnchorServer.h b/src/mds/AnchorServer.h
index ca70aa2..aa5588a 100644
--- a/src/mds/AnchorServer.h
+++ b/src/mds/AnchorServer.h
@@ -50,8 +50,8 @@ class AnchorServer : public MDSTableServer {
   }
 
   bool add(inodeno_t ino, inodeno_t dirino, __u32 dn_hash, bool replace);
-  void inc(inodeno_t ino);
-  void dec(inodeno_t ino);
+  void inc(inodeno_t ino, int ref=1);
+  void dec(inodeno_t ino, int ref=1);
 
   void dump();
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux