From 1080e7a375c18dfc792854e363c869197559c469 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Sun, 8 Jun 2014 12:27:03 +0800 Subject: [PATCH] Add upper limit to the write size of set_alloc_hint in KeyValueStore Signed-off-by: Haomai Wang --- src/common/config_opts.h | 1 + src/os/KeyValueStore.cc | 8 ++++++-- src/os/KeyValueStore.h | 3 +-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 18b0a2ab44747..ed97e3e6a6321 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -693,6 +693,7 @@ OPTION(keyvaluestore_op_threads, OPT_INT, 2) OPTION(keyvaluestore_op_thread_timeout, OPT_INT, 60) OPTION(keyvaluestore_op_thread_suicide_timeout, OPT_INT, 180) OPTION(keyvaluestore_default_strip_size, OPT_INT, 4096) // Only affect new object +OPTION(keyvaluestore_max_expected_write_size, OPT_U64, 1ULL << 24) // bytes // max bytes to search ahead in journal searching for corruption OPTION(journal_max_corrupt_search, OPT_U64, 10<<20) diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index b20f9cae472ed..3381908003f28 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -510,6 +510,7 @@ KeyValueStore::KeyValueStore(const std::string &base, m_keyvaluestore_queue_max_ops(g_conf->keyvaluestore_queue_max_ops), m_keyvaluestore_queue_max_bytes(g_conf->keyvaluestore_queue_max_bytes), m_keyvaluestore_strip_size(g_conf->keyvaluestore_default_strip_size), + m_keyvaluestore_max_expected_write_size(g_conf->keyvaluestore_max_expected_write_size), do_update(do_update) { ostringstream oss; @@ -3008,7 +3009,8 @@ int KeyValueStore::_set_alloc_hint(coll_t cid, const ghobject_t& oid, // Now only consider to change "strip_size" when the object is blank, // because set_alloc_hint is expected to be very lightweight if (blank) { - header->strip_size = expected_write_size; + header->strip_size = MIN(expected_write_size, m_keyvaluestore_max_expected_write_size); + dout(20) << __func__ << " hint " << header->strip_size << " success" << dendl; } dout(10) << __func__ << "" << cid << "/" << oid << " object_size " @@ -3033,9 +3035,11 @@ void KeyValueStore::handle_conf_change(const struct md_config_t *conf, const std::set &changed) { if (changed.count("keyvaluestore_queue_max_ops") || - changed.count("keyvaluestore_queue_max_bytes")) { + changed.count("keyvaluestore_queue_max_bytes") || + changed.count("keyvaluestore_max_expected_write_size")) { m_keyvaluestore_queue_max_ops = conf->keyvaluestore_queue_max_ops; m_keyvaluestore_queue_max_bytes = conf->keyvaluestore_queue_max_bytes; + m_keyvaluestore_max_expected_write_size = conf->keyvaluestore_max_expected_write_size; } if (changed.count("keyvaluestore_default_strip_size")) { m_keyvaluestore_strip_size = conf->keyvaluestore_default_strip_size; diff --git a/src/os/KeyValueStore.h b/src/os/KeyValueStore.h index 27eb993cbe7ac..4911d3884a4a5 100644 --- a/src/os/KeyValueStore.h +++ b/src/os/KeyValueStore.h @@ -586,10 +586,9 @@ class KeyValueStore : public ObjectStore, int m_keyvaluestore_queue_max_ops; int m_keyvaluestore_queue_max_bytes; int m_keyvaluestore_strip_size; - + uint64_t m_keyvaluestore_max_expected_write_size; int do_update; - static const string OBJECT_STRIP_PREFIX; static const string OBJECT_XATTR; static const string OBJECT_OMAP; -- 2.39.5