From: Igor Fedotov Date: Mon, 20 Apr 2026 20:06:51 +0000 (+0300) Subject: os/bluestore: make 'bluestore_debug_enforce_settings' control X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4b74d0af8fb968d3cd0a777da78e88288ea60b41;p=ceph.git os/bluestore: make 'bluestore_debug_enforce_settings' control rotational/non-rotational OSD behavior for DB/WAL devices. Prior to this commit this parameter determined what device class settings to apply for BlueStore only. OSD had partially applied actual journal/db/main device class for some operations, e.g. benchmark on init or allocmap persistence, irrespective to this setting value. This commit allows 'bluestore_debug_enforce_settings" to override the actual device class completely. Signed-off-by: Igor Fedotov --- diff --git a/src/common/options/global.yaml.in b/src/common/options/global.yaml.in index 59317a8d6b2..35b434450a9 100644 --- a/src/common/options/global.yaml.in +++ b/src/common/options/global.yaml.in @@ -5874,13 +5874,15 @@ options: type: str level: dev desc: Enforces specific hardware profile settings - long_desc: '''hdd'' enforces settings intended for BlueStore on a rotational - drive. ''ssd'' enforces settings intended for BlueStore on an SSD. ''default'' - indicates that BlueStore is to use settings based on the detected hardware.' + long_desc: '''hybrid'' enforces osd settings applicable to hybrid + (AKA main=hdd, db/wal=ssd) disk setup. + ''ssd'' enforces osd settings applicable to all-flash disk setup. + ''default'' specifies automatic settings selection based on real + detected hardware.' default: default enum_values: - default - - hdd + - hybrid - ssd with_legacy: true - name: bluestore_allocator_lookup_policy diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 84b9bac6611..eebd70a0ba0 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -903,6 +903,7 @@ public: int unlink(std::string_view dirname, std::string_view filename); int mkdir(std::string_view dirname); int rmdir(std::string_view dirname); + bool wal_is_rotational(); bool db_is_rotational(); diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index d2afa093e52..a5aa845fdec 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7681,12 +7681,13 @@ int BlueStore::_lock_fsid() return 0; } -bool BlueStore::is_rotational() +bool BlueStore::_is_main_rotational() { if (bdev) { return bdev->is_rotational(); } + // Do open main devicet if not yet opened. bool rotational = true; int r = _open_path(); if (r < 0) @@ -7713,37 +7714,58 @@ bool BlueStore::is_rotational() return rotational; } +bool BlueStore::is_rotational() +{ + return _use_rotational_settings(); +} + bool BlueStore::is_journal_rotational() { if (!bluefs) { - dout(5) << __func__ << " bluefs disabled, default to store media type" + dout(5) << __func__ << " bluefs disabled, default to main device type" << dendl; - return is_rotational(); + return _use_rotational_settings(); + } + if (cct->_conf->bluestore_debug_enforce_settings == "ssd" || + cct->_conf->bluestore_debug_enforce_settings == "hybrid") { + dout(10) << __func__ << " overriden to ssd mode." << dendl; + return false; } - dout(10) << __func__ << " " << (int)bluefs->wal_is_rotational() << dendl; - return bluefs->wal_is_rotational(); + bool r = bluefs->wal_is_rotational(); + dout(10) << __func__ << " " << (int)r << dendl; + return r; } bool BlueStore::is_db_rotational() { if (!bluefs) { - dout(5) << __func__ << " bluefs disabled, default to store media type" + dout(5) << __func__ << " bluefs disabled, default to main device type" << dendl; - return is_rotational(); + return _use_rotational_settings(); } - dout(10) << __func__ << " " << (int)bluefs->db_is_rotational() << dendl; - return bluefs->db_is_rotational(); + if (cct->_conf->bluestore_debug_enforce_settings == "ssd" || + cct->_conf->bluestore_debug_enforce_settings == "hybrid") { + dout(10) << __func__ << " overriden to ssd mode." << dendl; + return false; + } + bool r = bluefs->db_is_rotational(); + dout(10) << __func__ << " " << (int)r << dendl; + return r; } bool BlueStore::_use_rotational_settings() { - if (cct->_conf->bluestore_debug_enforce_settings == "hdd") { - return true; - } if (cct->_conf->bluestore_debug_enforce_settings == "ssd") { + dout(10) << __func__ << " overriden to ssd." << dendl; return false; } - return bdev->is_rotational(); + if (cct->_conf->bluestore_debug_enforce_settings == "hybrid") { + dout(10) << __func__ << " overriden to hdd." << dendl; + return true; + } + bool r = _is_main_rotational(); + dout(0) << __func__ << " returns " << r << dendl; + return r; } bool BlueStore::is_statfs_recoverable() const diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index c4ef3c0e9e6..7a10dcde001 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -4048,6 +4048,7 @@ private: std::array, 5> alloc_stats_history = { std::make_tuple(0ul, 0ul, 0ul) }; + bool _is_main_rotational(); inline bool _use_rotational_settings(); public: diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index 655a9d25a0c..5ba86a13e05 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -1685,7 +1685,7 @@ TEST_P(StoreTestSpecificAUSize, ReproBug41901Test) { SetVal(g_conf(), "bluestore_write_v2", "false"); SetVal(g_conf(), "bluestore_max_blob_size", "524288"); - SetVal(g_conf(), "bluestore_debug_enforce_settings", "hdd"); + SetVal(g_conf(), "bluestore_debug_enforce_settings", "hybrid"); g_conf().apply_changes(nullptr); StartDeferred(65536); @@ -10036,7 +10036,7 @@ TEST_P(StoreTestSpecificAUSize, ReproBug56488Test) { size_t alloc_size = 65536; size_t write_size = 4096; SetVal(g_conf(), "bluestore_write_v2", "false"); - SetVal(g_conf(), "bluestore_debug_enforce_settings", "hdd"); + SetVal(g_conf(), "bluestore_debug_enforce_settings", "hybrid"); SetVal(g_conf(), "bluestore_block_db_create", "true"); SetVal(g_conf(), "bluestore_block_db_size", stringify(1 << 30).c_str()); @@ -11858,7 +11858,7 @@ TEST_P(StoreTestSpecificAUSize, BluestoreEnforceHWSettingsHdd) { return; SetVal(g_conf(), "bluestore_write_v2", "false"); - SetVal(g_conf(), "bluestore_debug_enforce_settings", "hdd"); + SetVal(g_conf(), "bluestore_debug_enforce_settings", "hybrid"); StartDeferred(0x1000); int r; @@ -12216,7 +12216,7 @@ TEST_P(StoreTestSpecificAUSize, Ticket45195Repro) { SetVal(g_conf(), "bluestore_default_buffered_write", "true"); SetVal(g_conf(), "bluestore_max_blob_size", "65536"); - SetVal(g_conf(), "bluestore_debug_enforce_settings", "hdd"); + SetVal(g_conf(), "bluestore_debug_enforce_settings", "hybrid"); SetVal(g_conf(), "bluestore_fsck_on_mount", "false"); g_conf().apply_changes(nullptr);