From: Adam Kupczyk Date: Fri, 31 Mar 2023 09:04:40 +0000 (+0000) Subject: os/bluestore: Add conf option elastic_shared_blobs X-Git-Tag: v19.0.0~486^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8cf27efeb705237687dd5ab32169d34df8beef25;p=ceph.git os/bluestore: Add conf option elastic_shared_blobs 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 --- diff --git a/src/common/options/global.yaml.in b/src/common/options/global.yaml.in index 39c61e1f5a8c..990c55e61cbb 100644 --- a/src/common/options/global.yaml.in +++ b/src/common/options/global.yaml.in @@ -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 diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 03e28518f3a9..4ad4f0374f19 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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("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; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 780ec9b44b4d..c5e0bf632905 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2350,6 +2350,7 @@ private: static_assert(std::numeric_limits::max() > std::numeric_limits::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();