From e2ba42bd7552694fcd51af8845ba176fcc0174dd Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 19 Oct 2016 13:56:19 -0400 Subject: [PATCH] os/bluestore: submit txn via kv_sync_thread if ids exceed max This ensures the txn will not commit before an update to the global max. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 27 +++++++++++++++++++-------- src/os/bluestore/BlueStore.h | 4 ++-- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 2ed115b9178c8..bd81dd931c7c4 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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 l(kv_lock); diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index a10f35495cd17..3288c2debf535 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1433,9 +1433,9 @@ private: std::mutex id_lock; std::atomic nid_last = {0}; - uint64_t nid_max = 0; + std::atomic nid_max = {0}; std::atomic blobid_last = {0}; - uint64_t blobid_max = 0; + std::atomic blobid_max = {0}; Throttle throttle_ops, throttle_bytes; ///< submit to commit Throttle throttle_wal_ops, throttle_wal_bytes; ///< submit to wal complete -- 2.39.5