From e013293b7fc3087de1b3df57a219240f9f08008e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 18 Oct 2016 14:52:58 -0400 Subject: [PATCH] os/bluestore: refactor bluestore_sync_submit_transaction And drop bluestore_sync_transaction, at least for now. The key change here is to make a per-txc flag indicating whether the txn was already submitted. This allows us to make a choice between sync and not-sync on a per-txn basis. Signed-off-by: Sage Weil --- src/common/config_opts.h | 3 +-- src/os/bluestore/BlueStore.cc | 29 +++++++++++++++-------------- src/os/bluestore/BlueStore.h | 2 ++ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index a1d8e379baf..d3ea410cb8c 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -1011,8 +1011,7 @@ OPTION(bluestore_rocksdb_options, OPT_STR, "compression=kNoCompression,max_write OPTION(bluestore_fsck_on_mount, OPT_BOOL, false) OPTION(bluestore_fsck_on_umount, OPT_BOOL, false) OPTION(bluestore_fsck_on_mkfs, OPT_BOOL, true) -OPTION(bluestore_sync_transaction, OPT_BOOL, false) // perform kv txn synchronously -OPTION(bluestore_sync_submit_transaction, OPT_BOOL, false) +OPTION(bluestore_sync_submit_transaction, OPT_BOOL, false) // submit kv txn in queueing thread (not kv_sync_thread) OPTION(bluestore_sync_wal_apply, OPT_BOOL, true) // perform initial wal work synchronously (possibly in combination with aio so we only *queue* ios) OPTION(bluestore_wal_threads, OPT_INT, 4) OPTION(bluestore_wal_thread_timeout, OPT_INT, 30) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index b437135be5e..2ed115b9178 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6162,15 +6162,10 @@ void BlueStore::_txc_state_proc(TransContext *txc) sb->bc.finish_write(txc->seq); } txc->shared_blobs_written.clear(); - if (!g_conf->bluestore_sync_transaction) { - if (g_conf->bluestore_sync_submit_transaction) { - _txc_finalize_kv(txc, txc->t); - int r = db->submit_transaction(txc->t); - assert(r == 0); - } - } else { + if (g_conf->bluestore_sync_submit_transaction) { _txc_finalize_kv(txc, txc->t); - int r = db->submit_transaction_sync(txc->t); + txc->kv_submitted = true; + int r = db->submit_transaction(txc->t); assert(r == 0); } { @@ -6529,9 +6524,9 @@ void BlueStore::_kv_sync_thread() bdev->flush(); uint64_t high_nid = 0, high_blobid = 0; - if (!g_conf->bluestore_sync_transaction && - !g_conf->bluestore_sync_submit_transaction) { - for (auto txc : kv_committing) { + bool any_to_submit = false; + for (auto txc : kv_committing) { + if (!txc->kv_submitted) { _txc_finalize_kv(txc, txc->t); if (txc->last_nid > high_nid) { high_nid = txc->last_nid; @@ -6540,8 +6535,11 @@ void BlueStore::_kv_sync_thread() high_blobid = txc->last_blobid; } txc->log_state_latency(logger, l_bluestore_state_kv_queued_lat); + any_to_submit = true; } - if (!kv_committing.empty()) { + } + if (any_to_submit) { + if (high_nid || high_blobid) { TransContext *first_txc = kv_committing.front(); std::lock_guard l(id_lock); if (high_nid + g_conf->bluestore_nid_prealloc/2 > nid_max) { @@ -6560,8 +6558,11 @@ void BlueStore::_kv_sync_thread() } } for (auto txc : kv_committing) { - int r = db->submit_transaction(txc->t); - assert(r == 0); + if (!txc->kv_submitted) { + txc->kv_submitted = true; + int r = db->submit_transaction(txc->t); + assert(r == 0); + } } } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 4afffd760d2..a10f35495cd 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1160,6 +1160,8 @@ public: bluestore_wal_transaction_t *wal_txn; ///< wal transaction (if any) vector wal_op_onodes; + bool kv_submitted = false; ///< true when we've been submitted to kv db + interval_set allocated, released; struct volatile_statfs{ enum { -- 2.39.5