]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: mutation: add start/finish locking hooks
authorSage Weil <sage@newdream.net>
Thu, 1 Sep 2011 23:27:49 +0000 (16:27 -0700)
committerSage Weil <sage@newdream.net>
Wed, 7 Sep 2011 15:44:59 +0000 (08:44 -0700)
Keep track of which lock we are currently working on locking in the
Mutation.  Use helpers to make sure we start/finish locking in a sane
way.

Signed-off-by: Sage Weil <sage@newdream.net>
src/mds/Mutation.cc
src/mds/Mutation.h

index 47380f14613729f2d0ad74a168e20b4c9fd822fa..1f2b6a9a1efaa69496bb2b2764aeb902363a7846 100644 (file)
@@ -47,7 +47,21 @@ void Mutation::drop_pins()
   pins.clear();
 }
 
-  // auth pins
+void Mutation::start_locking(SimpleLock *lock)
+{
+  assert(locking == NULL);
+  pin(lock->get_parent());
+  locking = lock;
+}
+
+void Mutation::finish_locking(SimpleLock *lock)
+{
+  assert(locking == lock);
+  locking = NULL;
+}
+
+
+// auth pins
 bool Mutation::is_auth_pinned(MDSCacheObject *object)
 { 
   return auth_pins.count(object) || remote_auth_pins.count(object); 
index 71f041593224dcdb4b02f91ae40dedd1beecbcf3..ca5ee963a91a06b3e35448736ad0713475b54099 100644 (file)
@@ -58,6 +58,10 @@ struct Mutation {
   set< SimpleLock* > xlocks;   // local or remote.
   set< SimpleLock*, SimpleLock::ptr_lt > locks;  // full ordering
 
+  // lock we are currently trying to acquire.  if we give up for some reason,
+  // be sure to eval() this.
+  SimpleLock *locking;
+
   // if this flag is set, do not attempt to acquire further locks.
   //  (useful for wrlock, which may be a moving auth target)
   bool done_locking; 
@@ -72,17 +76,20 @@ struct Mutation {
   list<CInode*> dirty_cow_inodes;
   list<pair<CDentry*,version_t> > dirty_cow_dentries;
 
-  Mutation() : 
-    attempt(0),
-    ls(0),
-    slave_to_mds(-1),
-    done_locking(false), committing(false), aborted(false) { }
-  Mutation(metareqid_t ri, __u32 att=0, int slave_to=-1) : 
-    reqid(ri), attempt(att),
-    ls(0),
-    slave_to_mds(slave_to), 
-    done_locking(false), committing(false), aborted(false) { }
+  Mutation()
+    : attempt(0),
+      ls(0),
+      slave_to_mds(-1),
+      locking(NULL),
+      done_locking(false), committing(false), aborted(false) { }
+  Mutation(metareqid_t ri, __u32 att=0, int slave_to=-1)
+    : reqid(ri), attempt(att),
+      ls(0),
+      slave_to_mds(slave_to), 
+      locking(NULL),
+      done_locking(false), committing(false), aborted(false) { }
   virtual ~Mutation() {
+    assert(locking == NULL);
     assert(pins.empty());
     assert(auth_pins.empty());
     assert(xlocks.empty());
@@ -105,6 +112,9 @@ struct Mutation {
   void set_stickydirs(CInode *in);
   void drop_pins();
 
+  void start_locking(SimpleLock *lock);
+  void finish_locking(SimpleLock *lock);
+
   // auth pins
   bool is_auth_pinned(MDSCacheObject *object);
   void auth_pin(MDSCacheObject *object);