]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: added auth_pin debugging; fixed auth_pin leak in scatter_writebehind
authorSage Weil <sage@newdream.net>
Thu, 12 Jun 2008 18:07:18 +0000 (11:07 -0700)
committerSage Weil <sage@newdream.net>
Thu, 12 Jun 2008 18:07:18 +0000 (11:07 -0700)
src/mds/CDentry.cc
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/Migrator.cc
src/mds/mdstypes.h

index 8d7636c9f8978768c37c3ad43c1dcc624acb2d5e..fcda6281d498401125ced8101da215c4fb87b1d2 100644 (file)
@@ -281,26 +281,36 @@ bool CDentry::can_auth_pin()
   return dir->can_auth_pin();
 }
 
-void CDentry::auth_pin()
+void CDentry::auth_pin(void *by)
 {
   if (auth_pins == 0)
     get(PIN_AUTHPIN);
   auth_pins++;
 
-  dout(10) << "auth_pin on " << *this 
+#ifdef MDS_AUTHPIN_SET
+  auth_pin_set.insert(by);
+#endif
+
+  dout(10) << "auth_pin by " << by << " on " << *this 
           << " now " << auth_pins << "+" << nested_auth_pins
           << dendl;
 
   dir->adjust_nested_auth_pins(1, 1);
 }
 
-void CDentry::auth_unpin()
+void CDentry::auth_unpin(void *by)
 {
   auth_pins--;
+
+#ifdef MDS_AUTHPIN_SET
+  assert(auth_pin_set.count(by));
+  auth_pin_set.erase(auth_pin_set.find(by));
+#endif
+
   if (auth_pins == 0)
     put(PIN_AUTHPIN);
 
-  dout(10) << "auth_unpin on " << *this
+  dout(10) << "auth_unpin by " << by << " on " << *this
           << " now " << auth_pins << "+" << nested_auth_pins
           << dendl;
   assert(auth_pins >= 0);
index d5b4c5a0f2965e2565387bf5191eb4b34a1b1399..a201faa4f713333ebceb19d755052a686fb2e7cd 100644 (file)
@@ -92,6 +92,9 @@ class CDentry : public MDSCacheObject, public LRUObject {
   off_t dir_offset;   
 
   int auth_pins, nested_auth_pins;
+#ifdef MDS_AUTHPIN_SET
+  multiset<void*> auth_pin_set;
+#endif
   int nested_anchors;
 
   friend class Migrator;
@@ -165,8 +168,8 @@ public:
 
   // auth pins
   bool can_auth_pin();
-  void auth_pin();
-  void auth_unpin();
+  void auth_pin(void *by);
+  void auth_unpin(void *by);
   void adjust_nested_auth_pins(int by, int dirby);
   bool is_frozen();
   
index 2c80babcf9b197d25f7aba7b47b29daf03efa896..9f13f293b96c5e42d056f9e85bbe74edc4e59f1d 100644 (file)
@@ -921,7 +921,7 @@ void CDir::fetch(Context *c, bool ignore_authpinnability)
     return;
   }
 
-  auth_pin();
+  auth_pin(this);
   state_set(CDir::STATE_FETCHING);
 
   if (cache->mds->logger) cache->mds->logger->inc("dir_f");
@@ -1110,7 +1110,7 @@ void CDir::_fetched(bufferlist &bl)
   // mark complete, !fetching
   state_set(STATE_COMPLETE);
   state_clear(STATE_FETCHING);
-  auth_unpin();
+  auth_unpin(this);
 
   // kick waiters
   finish_waiting(WAIT_COMPLETE, 0);
@@ -1145,7 +1145,7 @@ void CDir::commit(version_t want, Context *c)
 
   // auth_pin on first waiter
   if (waiting_for_commit.empty())
-    auth_pin();
+    auth_pin(this);
   waiting_for_commit[want].push_back(c);
   
   // ok.
@@ -1351,7 +1351,7 @@ void CDir::_committed(version_t v)
   // unpin if we kicked the last waiter.
   if (were_waiters &&
       waiting_for_commit.empty())
-    auth_unpin();
+    auth_unpin(this);
 }
 
 
@@ -1495,7 +1495,7 @@ void CDir::set_dir_auth(pair<int,int> a)
     
     // unpin parent of frozen dir/tree?
     if (inode->is_auth() && (is_frozen_tree_root() || is_frozen_dir()))
-      inode->auth_unpin();
+      inode->auth_unpin(this);
   } 
   if (was_subtree && !is_subtree_root()) {
     dout(10) << " old subtree root, adjusting auth_pins" << dendl;
@@ -1505,7 +1505,7 @@ void CDir::set_dir_auth(pair<int,int> a)
 
     // pin parent of frozen dir/tree?
     if (inode->is_auth() && (is_frozen_tree_root() || is_frozen_dir()))
-      inode->auth_pin();
+      inode->auth_pin(this);
   }
 
   // newly single auth?
@@ -1533,13 +1533,19 @@ void CDir::set_dir_auth(pair<int,int> a)
  *
  */
 
-void CDir::auth_pin() 
+void CDir::auth_pin(void *by
 {
   if (auth_pins == 0)
     get(PIN_AUTHPIN);
   auth_pins++;
 
-  dout(10) << "auth_pin on " << *this << " count now " << auth_pins << " + " << nested_auth_pins << dendl;
+#ifdef MDS_AUTHPIN_SET
+  auth_pin_set.insert(by);
+#endif
+
+  dout(10) << "auth_pin by " << by
+          << " on " << *this
+          << " count now " << auth_pins << " + " << nested_auth_pins << dendl;
 
   // nest pins?
   if (is_subtree_root()) return;  // no.
@@ -1548,13 +1554,20 @@ void CDir::auth_pin()
   inode->adjust_nested_auth_pins(1);
 }
 
-void CDir::auth_unpin() 
+void CDir::auth_unpin(void *by
 {
   auth_pins--;
+
+#ifdef MDS_AUTHPIN_SET
+  assert(auth_pin_set.count(by));
+  auth_pin_set.erase(auth_pin_set.find(by));
+#endif
   if (auth_pins == 0)
     put(PIN_AUTHPIN);
 
-  dout(10) << "auth_unpin on " << *this << " count now " << auth_pins << " + " << nested_auth_pins << dendl;
+  dout(10) << "auth_unpin by " << by
+          << " on " << *this
+          << " count now " << auth_pins << " + " << nested_auth_pins << dendl;
   assert(auth_pins >= 0);
   
   maybe_finish_freeze();  // pending freeze?
@@ -1651,10 +1664,10 @@ bool CDir::freeze_tree()
   assert(!is_frozen());
   assert(!is_freezing());
 
-  auth_pin();
+  auth_pin(this);
   if (is_freezeable(true)) {
     _freeze_tree();
-    auth_unpin();
+    auth_unpin(this);
     return true;
   } else {
     state_set(STATE_FREEZINGTREE);
@@ -1675,7 +1688,7 @@ void CDir::_freeze_tree()
 
   // auth_pin inode for duration of freeze, if we are not a subtree root.
   if (is_auth() && !is_subtree_root())
-    inode->auth_pin();
+    inode->auth_pin(this);
 }
 
 void CDir::unfreeze_tree()
@@ -1689,7 +1702,7 @@ void CDir::unfreeze_tree()
 
     // unpin  (may => FREEZEABLE)   FIXME: is this order good?
     if (is_auth() && !is_subtree_root())
-      inode->auth_unpin();
+      inode->auth_unpin(this);
 
     // waiters?
     finish_waiting(WAIT_UNFREEZE);
@@ -1699,7 +1712,7 @@ void CDir::unfreeze_tree()
     // freezing.  stop it.
     assert(state_test(STATE_FREEZINGTREE));
     state_clear(STATE_FREEZINGTREE);
-    auth_unpin();
+    auth_unpin(this);
     
     finish_waiting(WAIT_UNFREEZE);
   }
@@ -1754,10 +1767,10 @@ bool CDir::freeze_dir()
   assert(!is_frozen());
   assert(!is_freezing());
   
-  auth_pin();
+  auth_pin(this);
   if (is_freezeable_dir(true)) {
     _freeze_dir();
-    auth_unpin();
+    auth_unpin(this);
     return true;
   } else {
     state_set(STATE_FREEZINGDIR);
@@ -1776,7 +1789,7 @@ void CDir::_freeze_dir()
   get(PIN_FROZEN);
 
   if (is_auth() && !is_subtree_root())
-    inode->auth_pin();  // auth_pin for duration of freeze
+    inode->auth_pin(this);  // auth_pin for duration of freeze
 }
 
 
@@ -1790,7 +1803,7 @@ void CDir::unfreeze_dir()
 
     // unpin  (may => FREEZEABLE)   FIXME: is this order good?
     if (is_auth() && !is_subtree_root())
-      inode->auth_unpin();
+      inode->auth_unpin(this);
 
     finish_waiting(WAIT_UNFREEZE);
   } else {
@@ -1799,7 +1812,7 @@ void CDir::unfreeze_dir()
     // still freezing. stop.
     assert(state_test(STATE_FREEZINGDIR));
     state_clear(STATE_FREEZINGDIR);
-    auth_unpin();
+    auth_unpin(this);
     
     finish_waiting(WAIT_UNFREEZE);
   }
index 5c672b39c3118643494b7aac105f9984a8036e54..2d3dc3417f5538134424868f9949f314976dcba9 100644 (file)
@@ -211,6 +211,9 @@ protected:
 
   // lock nesting, freeze
   int auth_pins;
+#ifdef MDS_AUTHPIN_SET
+  multiset<void*> auth_pin_set;
+#endif
   int nested_auth_pins, dir_auth_pins;
   int request_pins;
 
@@ -445,8 +448,8 @@ public:
   int get_auth_pins() { return auth_pins; }
   int get_nested_auth_pins() { return nested_auth_pins; }
   int get_dir_auth_pins() { return dir_auth_pins; }
-  void auth_pin();
-  void auth_unpin();
+  void auth_pin(void *who);
+  void auth_unpin(void *who);
 
   void adjust_nested_auth_pins(int inc, int dirinc);
   void verify_fragstat();
@@ -470,14 +473,14 @@ public:
     // we can freeze the _dir_ even with nested pins...
     if (state_test(STATE_FREEZINGDIR)) {
       _freeze_dir();
-      auth_unpin();
+      auth_unpin(this);
       finish_waiting(WAIT_FROZEN);
     }
     if (nested_auth_pins != 0) 
       return;
     if (state_test(STATE_FREEZINGTREE)) {
       _freeze_tree();
-      auth_unpin();
+      auth_unpin(this);
       finish_waiting(WAIT_FROZEN);
     }
   }
index f8bea2b5b47c8895ad44a5e34943be812bc76303..6e275b7205d0f06d624f733e914b256958321c07 100644 (file)
@@ -67,8 +67,12 @@ ostream& operator<<(ostream& out, CInode& in)
   
   out << " v" << in.get_version();
 
-  if (in.is_auth_pinned())
+  if (in.is_auth_pinned()) {
     out << " ap=" << in.get_num_auth_pins();
+#ifdef MDS_AUTHPIN_SET
+    out << "(" << in.auth_pin_set << ")";
+#endif
+  }
 
   if (in.state_test(CInode::STATE_AMBIGUOUSAUTH)) out << " AMBIGAUTH";
   if (in.state_test(CInode::STATE_NEEDSRECOVER)) out << " needsrecover";
@@ -842,13 +846,17 @@ bool CInode::can_auth_pin() {
   return true;
 }
 
-void CInode::auth_pin() 
+void CInode::auth_pin(void *by
 {
   if (auth_pins == 0)
     get(PIN_AUTHPIN);
   auth_pins++;
 
-  dout(10) << "auth_pin on " << *this
+#ifdef MDS_AUTHPIN_SET
+  auth_pin_set.insert(by);
+#endif
+
+  dout(10) << "auth_pin by " << by << " on " << *this
           << " now " << auth_pins << "+" << nested_auth_pins
           << dendl;
   
@@ -856,13 +864,19 @@ void CInode::auth_pin()
     parent->adjust_nested_auth_pins(1, 1);
 }
 
-void CInode::auth_unpin() 
+void CInode::auth_unpin(void *by
 {
   auth_pins--;
+
+#ifdef MDS_AUTHPIN_SET
+  assert(auth_pin_set.count(by));
+  auth_pin_set.erase(auth_pin_set.find(by));
+#endif
+
   if (auth_pins == 0)
     put(PIN_AUTHPIN);
   
-  dout(10) << "auth_unpin on " << *this
+  dout(10) << "auth_unpin by " << by << " on " << *this
           << " now " << auth_pins << "+" << nested_auth_pins
           << dendl;
   
index 19ffd2541a9be6b464c09e395749998592c47404..b70824ea50a6c3e0202e9402c44c49f6c396cb84 100644 (file)
@@ -230,6 +230,9 @@ private:
   int auth_pins;
   int nested_auth_pins;
 public:
+#ifdef MDS_AUTHPIN_SET
+  multiset<void*> auth_pin_set;
+#endif
   int auth_pin_freeze_allowance;
 
 private:
@@ -505,8 +508,8 @@ public:
   int get_num_auth_pins() { return auth_pins; }
   void adjust_nested_auth_pins(int a);
   bool can_auth_pin();
-  void auth_pin();
-  void auth_unpin();
+  void auth_pin(void *by);
+  void auth_unpin(void *by);
 
   void adjust_nested_anchors(int by);
   int get_nested_anchors() { return nested_anchors; }
@@ -524,14 +527,22 @@ public:
 
   // -- reference counting --
   void bad_put(int by) {
-    generic_dout(7) << " bad put " << *this << " by " << by << " " << pin_name(by) << " was " << ref << " (" << ref_set << ")" << dendl;
+    generic_dout(0) << " bad put " << *this << " by " << by << " " << pin_name(by) << " was " << ref
+#ifdef MDS_REF_SET
+                   << " (" << ref_set << ")"
+#endif
+                   << dendl;
 #ifdef MDS_REF_SET
     assert(ref_set.count(by) == 1);
 #endif
     assert(ref > 0);
   }
   void bad_get(int by) {
-    generic_dout(7) << " bad get " << *this << " by " << by << " " << pin_name(by) << " was " << ref << " (" << ref_set << ")" << dendl;
+    generic_dout(0) << " bad get " << *this << " by " << by << " " << pin_name(by) << " was " << ref
+#ifdef MDS_REF_SET
+                   << " (" << ref_set << ")"
+#endif
+                   << dendl;
 #ifdef MDS_REF_SET
     assert(ref_set.count(by) == 0);
 #endif
index d45c5e61c24e14d133da1724ea82145ac95395ad..23b1f3ad5b906112ed3b4bcc86b227c6456abc9a 100644 (file)
@@ -452,7 +452,7 @@ void Locker::rejoin_set_state(SimpleLock *lock, int s, list<Context*>& waiters)
 {
   if (!lock->is_stable()) {
     lock->set_state(s);
-    lock->get_parent()->auth_unpin();
+    lock->get_parent()->auth_unpin(lock);
   } else {
     lock->set_state(s);
   }
@@ -493,7 +493,6 @@ void Locker::file_update_finish(CInode *in, Mutation *mut, bool share)
   mut->apply();
   drop_locks(mut);
   mut->drop_local_auth_pins();
-
   delete mut;
   
   if (share && in->is_auth() && in->filelock.is_stable())
@@ -1671,7 +1670,7 @@ void Locker::simple_eval_gather(SimpleLock *lock)
     lock->finish_waiters(SimpleLock::WAIT_STABLE|SimpleLock::WAIT_WR);
 
     if (lock->get_parent()->is_auth()) {
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
 
       // re-eval?
       simple_eval(lock);
@@ -1752,7 +1751,7 @@ void Locker::simple_lock(SimpleLock *lock)
     // change lock
     lock->set_state(LOCK_GLOCKR);
     lock->init_gather();
-    lock->get_parent()->auth_pin();
+    lock->get_parent()->auth_pin(lock);
   } else {
     lock->set_state(LOCK_LOCK);
   }
@@ -2244,7 +2243,7 @@ void Locker::scatter_eval_gather(ScatterLock *lock)
                << " on " << *lock->get_parent() << dendl;
        lock->set_state(LOCK_LOCK);
        lock->finish_waiters(ScatterLock::WAIT_XLOCK|ScatterLock::WAIT_STABLE);
-       lock->get_parent()->auth_unpin();
+       lock->get_parent()->auth_unpin(lock);
       }
     }
     
@@ -2259,7 +2258,7 @@ void Locker::scatter_eval_gather(ScatterLock *lock)
              << " on " << *lock->get_parent() << dendl;
        lock->set_state(LOCK_LOCK);
        lock->finish_waiters(ScatterLock::WAIT_XLOCK|ScatterLock::WAIT_STABLE);
-       lock->get_parent()->auth_unpin();
+       lock->get_parent()->auth_unpin(lock);
       }
     }
 
@@ -2276,7 +2275,7 @@ void Locker::scatter_eval_gather(ScatterLock *lock)
       }
       lock->set_state(LOCK_SYNC);
       lock->finish_waiters(ScatterLock::WAIT_RD|ScatterLock::WAIT_STABLE);
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
     }
 
     // gscattert|gscatters -> scatter?
@@ -2295,7 +2294,7 @@ void Locker::scatter_eval_gather(ScatterLock *lock)
       }
       lock->set_state(LOCK_SCATTER);
       lock->finish_waiters(ScatterLock::WAIT_WR|ScatterLock::WAIT_STABLE);      
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
     }
 
     // gTempsyncC|gTempsyncL -> tempsync
@@ -2310,7 +2309,7 @@ void Locker::scatter_eval_gather(ScatterLock *lock)
                << " on " << *lock->get_parent() << dendl;
        lock->set_state(LOCK_TEMPSYNC);
        lock->finish_waiters(ScatterLock::WAIT_RD|ScatterLock::WAIT_STABLE);
-       lock->get_parent()->auth_unpin();
+       lock->get_parent()->auth_unpin(lock);
       }
     }
 
@@ -2365,8 +2364,12 @@ void Locker::scatter_writebehind_finish(ScatterLock *lock, Mutation *mut)
   CInode *in = (CInode*)lock->get_parent();
   dout(10) << "scatter_writebehind_finish on " << *lock << " on " << *in << dendl;
   in->pop_and_dirty_projected_inode(mut->ls);
+
   mut->apply();
   drop_locks(mut);
+  mut->drop_local_auth_pins();
+  delete mut;
+
   //scatter_eval_gather(lock);
 }
 
@@ -2513,7 +2516,7 @@ void Locker::scatter_sync(ScatterLock *lock)
   case LOCK_LOCK:
     if (lock->is_wrlocked() || lock->is_xlocked()) {
       lock->set_state(LOCK_GSYNCL);
-      lock->get_parent()->auth_pin();
+      lock->get_parent()->auth_pin(lock);
       return;
     }
     break; // do it.
@@ -2524,7 +2527,7 @@ void Locker::scatter_sync(ScatterLock *lock)
       break; // do it now
 
     lock->set_state(LOCK_GLOCKC);
-    lock->get_parent()->auth_pin();
+    lock->get_parent()->auth_pin(lock);
 
     if (lock->get_parent()->is_replicated()) {
       lock->init_gather();
@@ -2601,7 +2604,7 @@ void Locker::scatter_scatter(ScatterLock *lock)
   default: assert(0);
   }
 
-  lock->get_parent()->auth_pin();
+  lock->get_parent()->auth_pin(lock);
 
   if (lock->get_parent()->is_replicated()) {
     send_lock_message(lock, LOCK_AC_LOCK);
@@ -2655,7 +2658,7 @@ void Locker::scatter_lock(ScatterLock *lock)
   default: assert(0);
   }
 
-  lock->get_parent()->auth_pin();
+  lock->get_parent()->auth_pin(lock);
 
   if (lock->get_parent()->is_replicated()) {
     send_lock_message(lock, LOCK_AC_LOCK);
@@ -2680,7 +2683,7 @@ void Locker::scatter_tempsync(ScatterLock *lock)
     if (lock->is_wrlocked() ||
        lock->is_xlocked()) {
       lock->set_state(LOCK_GTEMPSYNCL);
-      lock->get_parent()->auth_pin();
+      lock->get_parent()->auth_pin(lock);
       return;
     }
     break; // do it.
@@ -2692,7 +2695,7 @@ void Locker::scatter_tempsync(ScatterLock *lock)
     }
     
     lock->set_state(LOCK_GTEMPSYNCC);
-    lock->get_parent()->auth_pin();
+    lock->get_parent()->auth_pin(lock);
 
     if (lock->get_parent()->is_replicated()) {
       lock->init_gather();
@@ -2857,7 +2860,7 @@ void Locker::handle_scatter_lock(ScatterLock *lock, MLock *m)
 
 void Locker::local_wrlock_grab(LocalLock *lock, Mutation *mut)
 {
-  dout(7) << "local_wrlock_try  on " << *lock
+  dout(7) << "local_wrlock_grab  on " << *lock
          << " on " << *lock->get_parent() << dendl;  
   
   assert(lock->can_wrlock());
@@ -3205,14 +3208,14 @@ void Locker::file_eval_gather(FileLock *lock)
       lock->get_rdlock();
       lock->finish_waiters(SimpleLock::WAIT_STABLE|SimpleLock::WAIT_WR|SimpleLock::WAIT_RD);
       lock->put_rdlock();
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
       break;
       
       // to mixed
     case LOCK_GMIXEDR:
       lock->set_state(LOCK_MIXED);
       lock->finish_waiters(SimpleLock::WAIT_STABLE);
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
       break;
 
     case LOCK_GMIXEDL:
@@ -3228,20 +3231,20 @@ void Locker::file_eval_gather(FileLock *lock)
       }
       
       lock->finish_waiters(SimpleLock::WAIT_STABLE);
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
       break;
 
       // to loner
     case LOCK_GLONERR:
       lock->set_state(LOCK_LONER);
       lock->finish_waiters(SimpleLock::WAIT_STABLE);
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
       break;
 
     case LOCK_GLONERM:
       lock->set_state(LOCK_LONER);
       lock->finish_waiters(SimpleLock::WAIT_STABLE);
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
       break;
       
       // to sync
@@ -3260,7 +3263,7 @@ void Locker::file_eval_gather(FileLock *lock)
       lock->get_rdlock();
       lock->finish_waiters(SimpleLock::WAIT_RD|SimpleLock::WAIT_STABLE);
       lock->put_rdlock();
-      lock->get_parent()->auth_unpin();
+      lock->get_parent()->auth_unpin(lock);
       break;
       
     default: 
@@ -3406,7 +3409,7 @@ bool Locker::file_sync(FileLock *lock)
     }
 
     if (gather) {
-      lock->get_parent()->auth_pin();
+      lock->get_parent()->auth_pin(lock);
       return false;
     }
   }
@@ -3466,7 +3469,7 @@ void Locker::file_lock(FileLock *lock)
   }
 
   if (gather)
-    lock->get_parent()->auth_pin();
+    lock->get_parent()->auth_pin(lock);
   else
     lock->set_state(LOCK_LOCK);
 }
@@ -3525,7 +3528,7 @@ void Locker::file_mixed(FileLock *lock)
     }
 
     if (gather)
-      lock->get_parent()->auth_pin();
+      lock->get_parent()->auth_pin(lock);
     else {
       lock->set_state(LOCK_MIXED);
       issue_caps(in);
@@ -3568,7 +3571,7 @@ void Locker::file_loner(FileLock *lock)
     }
  
     if (gather) {
-      lock->get_parent()->auth_pin();
+      lock->get_parent()->auth_pin(lock);
       return;
     }
   }
index a9d10448b8755cfaa806f3ebca1340c0ef7ac973..6b46994cf0ffc008c79c1cdeacc1a161698268f2 100644 (file)
@@ -494,7 +494,7 @@ void MDCache::try_subtree_merge_at(CDir *dir)
       CInode *in = dir->inode;
       dout(10) << "try_subtree_merge_at journaling merged bound " << *in << dendl;
       
-      in->auth_pin();
+      in->auth_pin(this);
 
       // journal write-behind.
       inode_t *pi = in->project_inode();
@@ -517,7 +517,7 @@ void MDCache::subtree_merge_writebehind_finish(CInode *in, LogSegment *ls)
 {
   dout(10) << "subtree_merge_writebehind_finish on " << in << dendl;
   in->pop_and_dirty_projected_inode(ls);
-  in->auth_unpin();
+  in->auth_unpin(this);
 }
 
 void MDCache::eval_subtree_root(CDir *dir)
@@ -2913,7 +2913,7 @@ void MDCache::queue_file_recover(CInode *in)
   dout(10) << "queue_file_recover " << *in << dendl;
   in->state_clear(CInode::STATE_NEEDSRECOVER);
   in->state_set(CInode::STATE_RECOVERING);
-  in->auth_pin();
+  in->auth_pin(this);
   file_recover_queue.insert(in);
 }
 
@@ -2987,7 +2987,7 @@ void MDCache::_recovered(CInode *in, int r)
   in->get_projected_inode()->size = in->inode.size;
   mds->locker->check_inode_max_size(in, true, in->inode.size);
 
-  in->auth_unpin();
+  in->auth_unpin(this);
 
   do_file_recover();
 }
@@ -4974,7 +4974,7 @@ void MDCache::anchor_create(MDRequest *mdr, CInode *in, Context *onfinish)
   // auth: do it
   in->state_set(CInode::STATE_ANCHORING);
   in->get(CInode::PIN_ANCHORING);
-  in->auth_pin();
+  in->auth_pin(this);
   
   // make trace
   vector<Anchor> trace;
@@ -5016,7 +5016,7 @@ void MDCache::anchor_destroy(CInode *in, Context *onfinish)
   // auth: do it
   in->state_set(CInode::STATE_UNANCHORING);
   in->get(CInode::PIN_UNANCHORING);
-  in->auth_pin();
+  in->auth_pin(this);
   
   // do it
   C_MDC_AnchorPrepared *fin = new C_MDC_AnchorPrepared(this, in, false);
@@ -5073,7 +5073,7 @@ void MDCache::_anchor_logged(CInode *in, version_t atid, Mutation *mut)
   assert(in->state_test(CInode::STATE_ANCHORING));
   in->state_clear(CInode::STATE_ANCHORING);
   in->put(CInode::PIN_ANCHORING);
-  in->auth_unpin();
+  in->auth_unpin(this);
   
   // apply update to cache
   in->pop_and_dirty_projected_inode(mut->ls);
index 5f584295bb878c24a79ffb403a961d37ec34257c..d996836095ae7e8b0ff01eabc559aa52227a777a 100644 (file)
@@ -142,13 +142,13 @@ struct Mutation {
   }
   void auth_pin(MDSCacheObject *object) {
     if (!is_auth_pinned(object)) {
-      object->auth_pin();
+      object->auth_pin(this);
       auth_pins.insert(object);
     }
   }
   void auth_unpin(MDSCacheObject *object) {
     assert(auth_pins.count(object));
-    object->auth_unpin();
+    object->auth_unpin(this);
     auth_pins.erase(object);
   }
   void drop_local_auth_pins() {
@@ -156,7 +156,7 @@ struct Mutation {
         it != auth_pins.end();
         it++) {
       assert((*it)->is_auth());
-      (*it)->auth_unpin();
+      (*it)->auth_unpin(this);
     }
     auth_pins.clear();
   }
index 87314914fd0d48cc464c9bd64bd946d01af42a2a..202642f91a63f867e845ca33244fd9f713aafe02 100644 (file)
@@ -192,7 +192,7 @@ void Migrator::handle_mds_failure_or_stop(int who)
       case EXPORT_DISCOVERING:
        dout(10) << "export state=discovering : canceling freeze and removing auth_pin" << dendl;
        dir->unfreeze_tree();  // cancel the freeze
-       dir->auth_unpin();
+       dir->auth_unpin(this);
        export_state.erase(dir); // clean up
        dir->state_clear(CDir::STATE_EXPORTING);
        if (export_peer[dir] != who) // tell them.
@@ -597,7 +597,7 @@ void Migrator::export_dir(CDir *dir, int dest)
   mds->send_message_mds(new MExportDirDiscover(dir), dest);
 
   // start the freeze, but hold it up with an auth_pin.
-  dir->auth_pin();
+  dir->auth_pin(this);
   dir->freeze_tree();
   assert(dir->is_freezing_tree());
   dir->add_waiter(CDir::WAIT_FROZEN, new C_MDC_ExportFreeze(this, dir));
@@ -623,7 +623,7 @@ void Migrator::handle_export_discover_ack(MExportDirDiscoverAck *m)
   } else {
     // freeze the subtree
     export_state[dir] = EXPORT_FREEZING;
-    dir->auth_unpin();
+    dir->auth_unpin(this);
   }
   
   delete m;  // done
index a38f9e636bfdb9a2af04c5ef6deb54e7ff02104c..e9fbaf0e71526a1e4b9b34c55dac062f28dbd128 100644 (file)
@@ -19,7 +19,8 @@ using namespace std;
 #include "include/frag.h"
 #include "include/xlist.h"
 
-#define MDS_REF_SET    // define me for improved debug output, sanity checking
+#define MDS_REF_SET      // define me for improved debug output, sanity checking
+#define MDS_AUTHPIN_SET  // define me for debugging auth pin leaks
 //#define MDS_VERIFY_FRAGSTAT    // do do (slow) sanity checking on frags
 
 #define MDS_PORT_CACHE   0x200
@@ -821,8 +822,8 @@ protected:
   // --------------------------------------------
   // auth pins
   virtual bool can_auth_pin() = 0;
-  virtual void auth_pin() = 0;
-  virtual void auth_unpin() = 0;
+  virtual void auth_pin(void *who) = 0;
+  virtual void auth_unpin(void *who) = 0;
   virtual bool is_frozen() = 0;