From 652d18f3596670bbf8968a63708ea2752d3dafc5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 15 Nov 2016 12:09:28 -0500 Subject: [PATCH] os/bluestore: fix alloc release timing on sync submits If we submit the txc synchronously, we can't immediately release our freed space to the allocator; that still needs to be done between commit_start() and commit_finish() from the kv_sync_thread, protected by the bdev barriers. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 9 ++++++++- src/os/bluestore/BlueStore.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index b27e3c51bfc8..071bdc6e73c6 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6559,6 +6559,11 @@ void BlueStore::_txc_finalize_kv(TransContext *txc, KeyValueDB::Transaction t) fm->release(p.get_start(), p.get_len(), t); } + _txc_update_store_statfs(txc); +} + +void BlueStore::_txc_release_alloc(TransContext *txc) +{ // update allocator with full released set if (!g_conf->bluestore_debug_no_reuse_blocks) { for (interval_set::iterator p = txc->released.begin(); @@ -6570,7 +6575,6 @@ void BlueStore::_txc_finalize_kv(TransContext *txc, KeyValueDB::Transaction t) txc->allocated.clear(); txc->released.clear(); - _txc_update_store_statfs(txc); } void BlueStore::_kv_sync_thread() @@ -6642,6 +6646,9 @@ void BlueStore::_kv_sync_thread() --txc->osr->kv_committing_serially; txc->kv_submitted = true; } + for (auto txc : kv_committing) { + _txc_release_alloc(txc); + } vector bluefs_gift_extents; if (bluefs) { diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 5db44e6a39f8..80bd466e83b0 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1651,13 +1651,14 @@ private: void _txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t); void _txc_state_proc(TransContext *txc); void _txc_aio_submit(TransContext *txc); - void _txc_finalize_kv(TransContext *txc, KeyValueDB::Transaction t); public: void _txc_aio_finish(void *p) { _txc_state_proc(static_cast(p)); } private: void _txc_finish_io(TransContext *txc); + void _txc_finalize_kv(TransContext *txc, KeyValueDB::Transaction t); + void _txc_release_alloc(TransContext *txc); void _txc_finish_kv(TransContext *txc); void _txc_finish(TransContext *txc); -- 2.47.3