]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add a config parameter to control garbage collection
authorIgor Fedotov <ifedotov@mirantis.com>
Tue, 29 Nov 2016 12:53:06 +0000 (12:53 +0000)
committerIgor Fedotov <ifedotov@mirantis.com>
Thu, 2 Feb 2017 15:22:50 +0000 (15:22 +0000)
Signed-off-by: Igor Fedotov <ifedotov@mirantis.com>
src/common/config_opts.h
src/os/bluestore/BlueStore.cc
src/test/objectstore/store_test.cc

index 3f15a3d91f5c6e918334d8ca9eef2c9acaee0a41..e98d7944e8894920cd43424abfd4d70a261c76f3 100644 (file)
@@ -1037,6 +1037,19 @@ OPTION(bluestore_compression_mode, OPT_STR, "none")  // force|aggressive|passive
 OPTION(bluestore_compression_algorithm, OPT_STR, "snappy")
 OPTION(bluestore_compression_min_blob_size, OPT_U32, 128*1024)
 OPTION(bluestore_compression_max_blob_size, OPT_U32, 512*1024)
+/*
+ * Specifies minimum expected amount of saved allocation units
+ * per single blob to enable compressed blobs garbage collection
+ * 
+ */
+OPTION(bluestore_gc_enable_blob_threshold, OPT_INT, 0)  
+/*
+ * Specifies minimum expected amount of saved allocation units
+ * per all blobsb to enable compressed blobs garbage collection
+ * 
+ */
+OPTION(bluestore_gc_enable_total_threshold, OPT_INT, 0)  
+
 OPTION(bluestore_max_blob_size, OPT_U32, 512*1024)
 /*
  * Require the net gain of compression at least to be at this ratio,
index 50ef7a7b0284f29388391023d1df5a811e957b3c..0d7a23829c1a0c746a581f44136895769ed412d0 100644 (file)
@@ -643,7 +643,8 @@ void BlueStore::GarbageCollector::process_protrusive_extents(
                << " expected4release=" << blob_expected_for_release
                << " expected_allocations=" << bi.expected_allocations
                << dendl;
-      if (blob_expected_for_release >= bi.expected_allocations) {
+      int64_t benefit = blob_expected_for_release - bi.expected_allocations;
+      if (benefit >= g_conf->bluestore_gc_enable_blob_threshold) {
         if (bi.collect_candidate) {
           auto it = bi.first_lextent;
           bool bExit = false;
@@ -8724,10 +8725,10 @@ void BlueStore::_do_garbage_collection(
   GarbageCollector gc(c->store->cct);
   int64_t benefit = gc.estimate(offset,
                                 length,
-                                o->extent_map,
-                                wctx->old_extents, 
-                                min_alloc_size);
-  if (benefit > 0) {
+                               o->extent_map,
+                               wctx->old_extents,
+                               min_alloc_size);
+  if (benefit > g_conf->bluestore_gc_enable_total_threshold) {
     auto& extents_to_collect = gc.get_extents_to_collect();
     for (auto it = extents_to_collect.begin();
          it != extents_to_collect.end();
index 940f5fceb0fe7f5bf1b2a1783f1c3d12c4a9f391..f91a40dd5273baea91880eb22bda233182759c74 100644 (file)
@@ -1236,6 +1236,9 @@ TEST_P(StoreTest, BluestoreStatFSTest) {
     return;
   g_conf->set_val("bluestore_compression_mode", "force");
   g_conf->set_val("bluestore_min_alloc_size", "65536");
+ // just a big number to disble gc
+  g_conf->set_val("bluestore_gc_enable_total_threshold", "100000");
   g_ceph_context->_conf->apply_changes(NULL);
   int r = store->umount();
   ASSERT_EQ(r, 0);
@@ -1474,6 +1477,7 @@ TEST_P(StoreTest, BluestoreStatFSTest) {
     ASSERT_EQ( 0u, statfs.compressed);
     ASSERT_EQ( 0u, statfs.compressed_allocated);
   }
+  g_conf->set_val("bluestore_gc_enable_total_threshold", "0");
   g_conf->set_val("bluestore_compression_mode", "none");
   g_conf->set_val("bluestore_min_alloc_size", "0");
   g_ceph_context->_conf->apply_changes(NULL);