]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: pin inodes on LogSegment::truncating_inodes list
authorSage Weil <sage.weil@dreamhost.com>
Thu, 28 Jul 2011 04:29:05 +0000 (21:29 -0700)
committerSage Weil <sage@newdream.net>
Thu, 28 Jul 2011 16:49:23 +0000 (09:49 -0700)
For active MDS, pin when we add to the list, unpin when we finish
truncating.

For replay, pin when we replay a truncate start, unpin when we replay a
truncate finish.  Use a nice helper for both.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/journal.cc

index 7c0124f50da17a1070bfd3522686da5d29689cae..c774a6015cef88a840fafa33935859180ac64e9e 100644 (file)
@@ -5187,7 +5187,8 @@ void MDCache::truncate_inode(CInode *in, LogSegment *ls)
           << dendl;
 
   ls->truncating_inodes.insert(in);
-  
+  in->get(CInode::PIN_TRUNCATING);
+
   _truncate_inode(in, ls);
 }
 
@@ -5209,7 +5210,6 @@ void MDCache::_truncate_inode(CInode *in, LogSegment *ls)
           << pi->truncate_from << " -> " << pi->truncate_size
           << " on " << *in << dendl;
 
-  in->get(CInode::PIN_TRUNCATING);
   in->auth_pin(this);
 
   SnapRealm *realm = in->find_snaprealm();
@@ -5289,6 +5289,16 @@ void MDCache::truncate_inode_logged(CInode *in, Mutation *mut)
 void MDCache::add_recovered_truncate(CInode *in, LogSegment *ls)
 {
   ls->truncating_inodes.insert(in);
+  in->get(CInode::PIN_TRUNCATING);
+}
+
+void MDCache::remove_recovered_truncate(CInode *in, LogSegment *ls)
+{
+  // if we have the logseg the truncate started in, it must be in our list.
+  set<CInode*>::iterator p = ls->truncating_inodes.find(in);
+  assert(p != ls->truncating_inodes.end());
+  ls->truncating_inodes.erase(p);
+  in->put(CInode::PIN_TRUNCATING);
 }
 
 void MDCache::start_recovered_truncates()
index 79c740ccb83e224a82346f317a234a57560d63b5..6cb5a3e1a08ca53c89aa880c3ed83d2ee1e76ee2 100644 (file)
@@ -970,7 +970,7 @@ protected:
   void truncate_inode_logged(CInode *in, Mutation *mut);
 
   void add_recovered_truncate(CInode *in, LogSegment *ls);
-  void remove_recovered_truncate(CInode *in);
+  void remove_recovered_truncate(CInode *in, LogSegment *ls);
   void start_recovered_truncates();
 
 
index d182fdb8368ade7adf1b08281a86c8032f1c3eee..c7b79e0b6970b7d88b689b19d2321662c6e7e918 100644 (file)
@@ -764,7 +764,7 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
     if (ls) {
       CInode *in = mds->mdcache->get_inode(p->first);
       assert(in);
-      ls->truncating_inodes.erase(in);
+      mds->mdcache->remove_recovered_truncate(in, ls);
     }
   }