]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add upper limit to the write size of set_alloc_hint in KeyValueStore 1937/head
authorHaomai Wang <haomaiwang@gmail.com>
Sun, 8 Jun 2014 04:27:03 +0000 (12:27 +0800)
committerHaomai Wang <haomaiwang@gmail.com>
Mon, 9 Jun 2014 05:46:01 +0000 (13:46 +0800)
Signed-off-by: Haomai Wang <haomaiwang@gmail.com>
src/common/config_opts.h
src/os/KeyValueStore.cc
src/os/KeyValueStore.h

index 18b0a2ab447470983899dfcf542700154b687ae6..ed97e3e6a6321d4cbc18760c22b9a1b9294ee4db 100644 (file)
@@ -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)
index b20f9cae472edce365751c3e7fbb4352d373f5ed..3381908003f28a139130231cdbd591c9d63b4ddb 100644 (file)
@@ -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<O(1)>
   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 <std::string> &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;
index 27eb993cbe7ac1c5a5ba1345682b814a7fa1b1ef..4911d3884a4a5508a713ab113ccf94f104098535 100644 (file)
@@ -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;