]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: update mds_lock handling in Locker contexts
authorJohn Spray <john.spray@redhat.com>
Wed, 23 Jul 2014 16:35:24 +0000 (17:35 +0100)
committerJohn Spray <john.spray@redhat.com>
Mon, 25 Aug 2014 00:34:07 +0000 (01:34 +0100)
For some contexts, we expect to be called back from the objecter/filer
on an I/O completion, so we must take mds_lock before updating any
MDS metadata.  In others, we expect to be called back from the MDCache
in response to updates to a CInode's state, so we assert that mds_lock
is already held.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/Locker.cc
src/mds/Locker.h

index 8a52d33ba985b89fdcb29416ee8691bcc657e1ac..c317a69fea55377f55eae06886693d003dee82f1 100644 (file)
@@ -975,6 +975,9 @@ class C_Locker_Eval : public Context {
   int mask;
 public:
   C_Locker_Eval(Locker *l, MDSCacheObject *pp, int m) : locker(l), p(pp), mask(m) {
+    // We are used as an MDSCacheObject waiter, so should
+    // only be invoked by someone already holding the big lock.
+    assert(locker->mds->mds_lock.is_locked_by_me());
     p->get(MDSCacheObject::PIN_PTRWAITER);    
   }
   void finish(int r) {
@@ -1668,6 +1671,7 @@ struct C_Locker_FileUpdate_finish : public Context {
     in->get(CInode::PIN_PTRWAITER);
   }
   void finish(int r) {
+    Mutex::Locker l(locker->mds->mds_lock);
     locker->file_update_finish(in, mut, share, client, cap, ack);
   }
 };
@@ -2009,6 +2013,7 @@ public:
     in->get(CInode::PIN_PTRWAITER);
   }
   void finish(int r) {
+    assert(locker->mds->mds_lock.is_locked_by_me());
     in->put(CInode::PIN_PTRWAITER);
     if (!in->is_auth())
       locker->request_inode_file_caps(in);
@@ -2091,6 +2096,8 @@ public:
     in->get(CInode::PIN_PTRWAITER);
   }
   void finish(int r) {
+    assert(locker->mds->mds_lock.is_locked_by_me());
+
     in->put(CInode::PIN_PTRWAITER);
     if (in->is_auth())
       locker->check_inode_max_size(in, false, update_size, newsize,
@@ -2234,7 +2241,8 @@ bool Locker::check_inode_max_size(CInode *in, bool force_wrlock,
     metablob->add_dir_context(in->get_projected_parent_dn()->get_dir());
     mdcache->journal_dirty_inode(mut.get(), metablob, in);
   }
-  mds->mdlog->submit_entry(le, new C_Locker_FileUpdate_finish(this, in, mut, true));
+  mds->mdlog->submit_entry(le,
+          new C_Locker_FileUpdate_finish(this, in, mut, true));
   wrlock_force(&in->filelock, mut);  // wrlock for duration of journal
   mut->auth_pin(in);
 
index 31e3d9812e975d69ca9ad4dd607fc6638d2ef549..df8d109c6938723517fc6b70e6e4397366fee2ab 100644 (file)
@@ -186,6 +186,7 @@ protected:
     C_Locker_ScatterWB(Locker *l, ScatterLock *sl, MutationRef& m) :
       locker(l), lock(sl), mut(m) {}
     void finish(int r) { 
+      Mutex::Locker l(locker->mds->mds_lock);
       locker->scatter_writebehind_finish(lock, mut); 
     }
   };
@@ -285,6 +286,7 @@ private:
   friend class C_MDL_RequestInodeFileCaps;
   friend struct C_Locker_FileUpdate_finish;
   friend class C_Locker_RetryCapRelease;
+  friend class C_Locker_Eval;
 
   
   // -- client leases --