]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add missing lock in sync_write_commit
authorJohn Spray <john.spray@redhat.com>
Tue, 5 Aug 2014 14:14:14 +0000 (15:14 +0100)
committerJohn Spray <john.spray@redhat.com>
Mon, 25 Aug 2014 00:34:17 +0000 (01:34 +0100)
This would otherwise assert when entering
the objectcacher.

Also add assertions for all the other Contexts
in Client, which are currently correct but not
so obvious.

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

index f7e38627bed31931fa657b8c488e94489dce2645..1a108a442822a675a73e18b6f77f52fe7c933432 100644 (file)
@@ -2821,6 +2821,8 @@ public:
     inode->get();
   }
   void finish(int r) {
+    // _async_invalidate takes the lock when it needs to, call this back from outside of lock.
+    assert(!client->client_lock.is_locked_by_me());
     client->_async_invalidate(inode, offset, length, keep_caps);
   }
 };
@@ -2889,6 +2891,9 @@ public:
     in->get();
   }
   void finish(int) {
+    // I am used via ObjectCacher, which is responsible for taking
+    // the client lock before calling me back.
+    assert(client->client_lock.is_locked_by_me());
     client->put_inode(in);
   }
 };
@@ -3786,6 +3791,8 @@ public:
        ino.ino = inodeno_t();
   }
   void finish(int r) {
+    // _async_dentry_invalidate is responsible for its own locking
+    assert(!client->client_lock.is_locked_by_me());
     client->_async_dentry_invalidate(dirino, ino, name);
   }
 };
@@ -4141,6 +4148,8 @@ class C_C_Tick : public Context {
 public:
   C_C_Tick(Client *c) : client(c) {}
   void finish(int r) {
+    // Called back via Timer, which takes client_lock for us
+    assert(client->client_lock.is_locked_by_me());
     client->tick();
   }
 };
@@ -6449,12 +6458,16 @@ public:
     in->get();
   }
   void finish(int) {
+    // Called back by Filter, then Client is responsible for taking its own lock
+    assert(!cl->client_lock.is_locked_by_me()); 
     cl->sync_write_commit(in);
   }
 };
 
 void Client::sync_write_commit(Inode *in)
 {
+  Mutex::Locker l(client_lock);
+
   assert(unsafe_sync_write > 0);
   unsafe_sync_write--;
 
@@ -6626,7 +6639,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf)
     r = filer->write_trunc(in->ino, &in->layout, in->snaprealm->get_snap_context(),
                           offset, size, bl, ceph_clock_now(cct), 0,
                           in->truncate_size, in->truncate_seq,
-                          onfinish, onsafe);
+                          onfinish, new C_OnFinisher(onsafe, &objecter_finisher));
     if (r < 0)
       goto done;
 
@@ -8704,7 +8717,7 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)
                       in->snaprealm->get_snap_context(),
                       offset, length,
                       ceph_clock_now(cct),
-                      0, true, onfinish, onsafe);
+                      0, true, onfinish, new C_OnFinisher(onsafe, &objecter_finisher));
       if (r < 0)
         goto done;
 
index 78d0f0dd771216ece729a41929bd9ae7e7ef3cce..534b8c3690f92c1cdfa97781330909ff3fee6a10 100644 (file)
@@ -373,6 +373,8 @@ protected:
   friend class C_Client_CacheInvalidate;  // calls ino_invalidate_cb
   friend class C_Client_DentryInvalidate;  // calls dentry_invalidate_cb
   friend class C_Block_Sync; // Calls block map and protected helpers
+  friend class C_C_Tick; // Asserts on client_lock
+  friend class C_Client_SyncCommit; // Asserts on client_lock
 
   //int get_cache_size() { return lru.lru_get_size(); }
   //void set_cache_size(int m) { lru.lru_set_max(m); }