]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
memstore: replace apply_lock with sequencer
authorCasey Bodley <cbodley@redhat.com>
Wed, 19 Aug 2015 13:59:59 +0000 (09:59 -0400)
committerCasey Bodley <cbodley@redhat.com>
Wed, 26 Aug 2015 21:49:46 +0000 (17:49 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/os/MemStore.cc

index 1f51f0e50f34cedab31b90111dbd458898743569..0fff54506ce9ba20d748d4a97afedc85a986601e 100644 (file)
@@ -581,8 +581,22 @@ int MemStore::queue_transactions(Sequencer *osr,
                                 TrackedOpRef op,
                                 ThreadPool::TPHandle *handle)
 {
-  // fixme: ignore the Sequencer and serialize everything.
-  Mutex::Locker l(apply_lock);
+  // because memstore operations are synchronous, we can implement the
+  // Sequencer with a mutex. this guarantees ordering on a given sequencer,
+  // while allowing operations on different sequencers to happen in parallel
+  struct OpSequencer : public Sequencer_impl {
+    std::mutex mutex;
+    void flush() override {}
+    bool flush_commit(Context*) override { return true; }
+  };
+
+  std::unique_lock<std::mutex> lock;
+  if (osr) {
+    auto seq = reinterpret_cast<OpSequencer**>(&osr->p);
+    if (*seq == nullptr)
+      *seq = new OpSequencer;
+    lock = std::unique_lock<std::mutex>((*seq)->mutex);
+  }
 
   for (list<Transaction*>::iterator p = tls.begin(); p != tls.end(); ++p) {
     // poke the TPHandle heartbeat just to exercise that code path