]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Add conf option elastic_shared_blobs
authorAdam Kupczyk <akupczyk@ibm.com>
Fri, 31 Mar 2023 09:04:40 +0000 (09:04 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Thu, 6 Jul 2023 15:28:50 +0000 (15:28 +0000)
Having new ExtentMap::dup that introduces heavy changes to blob processing
seems risky. We will enable it only on demand. In future, once the feature
is tested in production, the choice should be removed (and feature always on).

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/common/options/global.yaml.in
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 39c61e1f5a8cbd4b655927172b086f8e8f56038a..990c55e61cbb62f541d430d37ebea72d3409ce1a 100644 (file)
@@ -4909,6 +4909,17 @@ options:
   flags:
   - create
   with_legacy: true
+- name: bluestore_elastic_shared_blobs
+  type: bool
+  level: advanced
+  desc: Let bluestore to reuse existing shared blobs if possible
+  long_desc: Overwrites on snapped objects cause shared blob count to grow.
+    It has a very negative performance effect. When enabled shared blob count
+    is significantly reduced.
+  default: false
+  flags:
+  - create
+  with_legacy: false
 - name: bluestore_allocator
   type: str
   level: advanced
index 03e28518f3a948297c431bddc4b582a998fe9cc8..4ad4f0374f191545f0ada401e93786c6f5300ba9 100644 (file)
@@ -5908,6 +5908,38 @@ int BlueStore::read_meta(const std::string& key, std::string *value)
   return 0;
 }
 
+
+// Reads configuration.
+// Validates values.
+//
+// In future this should be the only place that reads meta,
+// except initialization of components, like BlueFS, FreeListManager
+//
+// NOTE: Any configuration settings that affect data layout on disk
+//       must be persisted to meta.
+int BlueStore::read_meta_conf_check_env()
+{
+  int r = 0;
+  std::string esb;
+  r = read_meta("elastic_shared_blobs",&esb);
+  if (r == 0) {
+    if (esb != "1" && esb != "0") {
+      derr << __func__ << " wrong meta.elastic_shared_blobs=" << esb << dendl;
+      r = -EIO;
+    } else {
+      elastic_shared_blobs = esb == "1";
+    }
+  } else {
+    if (r == -ENOENT) {
+      dout(1) << __func__ << " meta.elastic_shared_blobs not set, using legacy mode" << dendl;
+      elastic_shared_blobs = false;
+      r = 0;
+    }
+  }
+  return r;
+}
+
+
 void BlueStore::_init_logger()
 {
   PerfCountersBuilder b(cct, "bluestore",
@@ -8179,6 +8211,11 @@ int BlueStore::mkfs()
   if (r < 0)
     goto out_close_fm;
 
+  r = write_meta("elastic_shared_blobs",
+                cct->_conf.get_val<bool>("bluestore_elastic_shared_blobs") ? "1" : "0");
+  if (r < 0)
+    goto out_close_fm;
+
   if (fsid != old_fsid) {
     r = _write_fsid();
     if (r < 0) {
@@ -8607,11 +8644,17 @@ bool BlueStore::has_null_manager() const
 
 int BlueStore::_mount()
 {
-  dout(5) << __func__ << "NCB:: path " << path << dendl;
+  dout(5) << __func__ << " path " << path << dendl;
+
+  {
+    int r = read_meta_conf_check_env();
+    if (r < 0) {
+      return r;
+    }
+  }
 
   _kv_only = false;
   if (cct->_conf->bluestore_fsck_on_mount) {
-    dout(5) << __func__ << "::NCB::calling fsck()" << dendl;
     int rc = fsck(cct->_conf->bluestore_fsck_on_mount_deep);
     if (rc < 0)
       return rc;
index 780ec9b44b4d27cc394966a83839d7f0e52def33..c5e0bf632905976476ba5c19a5722523263bc4a7 100644 (file)
@@ -2350,6 +2350,7 @@ private:
   static_assert(std::numeric_limits<uint8_t>::max() >
                std::numeric_limits<decltype(min_alloc_size)>::digits,
                "not enough bits for min_alloc_size");
+  bool elastic_shared_blobs = false; ///< use smart ExtentMap::dup to reduce shared blob count
 
   // smr-only
   uint64_t zone_size = 0;              ///< number of SMR zones 
@@ -2962,6 +2963,9 @@ public:
 
   int write_meta(const std::string& key, const std::string& value) override;
   int read_meta(const std::string& key, std::string *value) override;
+  int read_meta_check(const std::string& key, std::string *value);
+
+  int read_meta_conf_check_env();
 
   // open in read-only and limited mode
   int cold_open();