]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: submit txn via kv_sync_thread if ids exceed max
authorSage Weil <sage@redhat.com>
Wed, 19 Oct 2016 17:56:19 +0000 (13:56 -0400)
committerSage Weil <sage@redhat.com>
Tue, 1 Nov 2016 14:30:03 +0000 (10:30 -0400)
This ensures the txn will not commit before an update to the
global max.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 2ed115b9178c830355d0402ab9011c510e8f55a5..bd81dd931c7c4435e0ceeb73c45514fb113602a8 100644 (file)
@@ -6020,11 +6020,13 @@ int BlueStore::_open_super_meta()
     db->get(PREFIX_SUPER, "nid_max", &bl);
     bufferlist::iterator p = bl.begin();
     try {
-      ::decode(nid_max, p);
+      uint64_t v;
+      ::decode(v, p);
+      nid_max = v;
     } catch (buffer::error& e) {
     }
     dout(10) << __func__ << " old nid_max " << nid_max << dendl;
-    nid_last = nid_max;
+    nid_last = nid_max.load();
   }
 
   // blobid
@@ -6034,11 +6036,13 @@ int BlueStore::_open_super_meta()
     db->get(PREFIX_SUPER, "blobid_max", &bl);
     bufferlist::iterator p = bl.begin();
     try {
-      ::decode(blobid_max, p);
+      uint64_t v;
+      ::decode(v, p);
+      blobid_max = v;
     } catch (buffer::error& e) {
     }
     dout(10) << __func__ << " old blobid_max " << blobid_max << dendl;
-    blobid_last = blobid_max;
+    blobid_last = blobid_max.load();
   }
 
   // freelist
@@ -6163,10 +6167,17 @@ void BlueStore::_txc_state_proc(TransContext *txc)
       }
       txc->shared_blobs_written.clear();
       if (g_conf->bluestore_sync_submit_transaction) {
-       _txc_finalize_kv(txc, txc->t);
-       txc->kv_submitted = true;
-       int r = db->submit_transaction(txc->t);
-       assert(r == 0);
+       if (txc->last_nid >= nid_max ||
+           txc->last_blobid >= blobid_max) {
+         dout(20) << __func__
+                  << " last_{nid,blobid} exceeds max, submit via kv thread"
+                  << dendl;
+       } else {
+         _txc_finalize_kv(txc, txc->t);
+         txc->kv_submitted = true;
+         int r = db->submit_transaction(txc->t);
+         assert(r == 0);
+       }
       }
       {
        std::lock_guard<std::mutex> l(kv_lock);
index a10f35495cd175b04be368b5354752e28cafe5fa..3288c2debf5351c56a06bb47d99fb0451ced5574 100644 (file)
@@ -1433,9 +1433,9 @@ private:
 
   std::mutex id_lock;
   std::atomic<uint64_t> nid_last = {0};
-  uint64_t nid_max = 0;
+  std::atomic<uint64_t> nid_max = {0};
   std::atomic<uint64_t> blobid_last = {0};
-  uint64_t blobid_max = 0;
+  std::atomic<uint64_t> blobid_max = {0};
 
   Throttle throttle_ops, throttle_bytes;          ///< submit to commit
   Throttle throttle_wal_ops, throttle_wal_bytes;  ///< submit to wal complete