]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: move txc on_commits assignment into ctor 22382/head
authorSage Weil <sage@redhat.com>
Mon, 21 May 2018 13:24:54 +0000 (08:24 -0500)
committerPrashant D <pdhange@redhat.com>
Mon, 4 Jun 2018 02:25:10 +0000 (22:25 -0400)
This avoids adjusting the oncommits without a lock after the txc is
queued on the sequencer.

This is a bit defensive since the ObjectStore caller doesn't call
flush_commit() at the same time as queue_transaction(), but the could
change in the future.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit efde8d440b482e3fd90c6b60ef5118f408afd0fa)

src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 3f41dee846a31adea131ad485554f7eed3013b5f..973bde64db5bc491e7ab70cf41595a8bbbaafc01 100644 (file)
@@ -8330,9 +8330,10 @@ void BlueStore::get_db_statistics(Formatter *f)
 }
 
 BlueStore::TransContext *BlueStore::_txc_create(
-  Collection *c, OpSequencer *osr)
+  Collection *c, OpSequencer *osr,
+  list<Context*> *on_commits)
 {
-  TransContext *txc = new TransContext(cct, c, osr);
+  TransContext *txc = new TransContext(cct, c, osr, on_commits);
   txc->t = db->get_transaction();
   osr->queue_new(txc);
   dout(20) << __func__ << " osr " << osr << " = " << txc
@@ -9427,7 +9428,7 @@ int BlueStore::_deferred_replay()
       r = -EIO;
       goto out;
     }
-    TransContext *txc = _txc_create(ch.get(), osr);
+    TransContext *txc = _txc_create(ch.get(), osr,  nullptr);
     txc->deferred_txn = deferred_txn;
     txc->state = TransContext::STATE_KV_DONE;
     _txc_state_proc(txc);
@@ -9474,8 +9475,8 @@ int BlueStore::queue_transactions(
   dout(10) << __func__ << " ch " << c << " " << c->cid << dendl;
 
   // prepare
-  TransContext *txc = _txc_create(static_cast<Collection*>(ch.get()), osr);
-  txc->oncommits.swap(on_commit);
+  TransContext *txc = _txc_create(static_cast<Collection*>(ch.get()), osr,
+                                 &on_commit);
 
   for (vector<Transaction>::iterator p = tls.begin(); p != tls.end(); ++p) {
     txc->bytes += (*p).get_num_bytes();
index b2048584b01c3ad4c439efc73865d5ff176308f9..62fc7cf0da639759bcc0ca341f7cbb36e2e38a17 100644 (file)
@@ -1591,12 +1591,16 @@ public:
     uint64_t last_nid = 0;     ///< if non-zero, highest new nid we allocated
     uint64_t last_blobid = 0;  ///< if non-zero, highest new blobid we allocated
 
-    explicit TransContext(CephContext* cct, Collection *c, OpSequencer *o)
+    explicit TransContext(CephContext* cct, Collection *c, OpSequencer *o,
+                         list<Context*> *on_commits)
       : ch(c),
        osr(o),
        ioc(cct, this),
        start(ceph_clock_now()) {
       last_stamp = start;
+      if (on_commits) {
+       oncommits.swap(*on_commits);
+      }
     }
     ~TransContext() {
       delete deferred_txn;
@@ -2016,7 +2020,8 @@ private:
   template <int LogLevelV = 30> void _dump_extent_map(ExtentMap& em);
   template <int LogLevelV = 30> void _dump_transaction(Transaction *t);
 
-  TransContext *_txc_create(Collection *c, OpSequencer *osr);
+  TransContext *_txc_create(Collection *c, OpSequencer *osr,
+                           list<Context*> *on_commits);
   void _txc_update_store_statfs(TransContext *txc);
   void _txc_add_transaction(TransContext *txc, Transaction *t);
   void _txc_calc_cost(TransContext *txc);