From 880884b517346a414aceae31ff8057b960fd38e5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 14 Apr 2017 12:15:02 -0400 Subject: [PATCH] os/bluestore: do not balance bluefs on every kv_sync_thread iteration This showed up with multiple samples in a wall-clock profile. We do not need to reconsider the freespace balance on every single kv commit cycle. Signed-off-by: Sage Weil --- src/common/config_opts.h | 1 + src/os/bluestore/BlueStore.cc | 5 ++++- src/os/bluestore/BlueStore.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 8984c35594e32..ee28638787fca 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -1020,6 +1020,7 @@ OPTION(bluestore_bluefs_min_ratio, OPT_FLOAT, .02) // min fs free / total free OPTION(bluestore_bluefs_max_ratio, OPT_FLOAT, .90) // max fs free / total free OPTION(bluestore_bluefs_gift_ratio, OPT_FLOAT, .02) // how much to add at a time OPTION(bluestore_bluefs_reclaim_ratio, OPT_FLOAT, .20) // how much to reclaim at a time +OPTION(bluestore_bluefs_balance_interval, OPT_FLOAT, 1) // how often (sec) to balance free space between bluefs and bluestore // If you want to use spdk driver, you need to specify NVMe serial number here // with "spdk:" prefix. // Users can use 'lspci -vvv -d 8086:0953 | grep "Device Serial Number"' to diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e9f0d1d40f804..663a1e83dd23f 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7847,7 +7847,10 @@ void BlueStore::_kv_sync_thread() } PExtentVector bluefs_gift_extents; - if (bluefs) { + if (bluefs && + after_flush - bluefs_last_balance > + cct->_conf->bluestore_bluefs_balance_interval) { + bluefs_last_balance = after_flush; int r = _balance_bluefs_freespace(&bluefs_gift_extents); assert(r >= 0); if (r > 0) { diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 64200e398bdc1..8e6e224070394 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1723,6 +1723,8 @@ private: BlueFS *bluefs = nullptr; unsigned bluefs_shared_bdev = 0; ///< which bluefs bdev we are sharing bool bluefs_single_shared_device = true; + utime_t bluefs_last_balance; + KeyValueDB *db = nullptr; BlockDevice *bdev = nullptr; std::string freelist_type; -- 2.39.5