@@ -5742,7 +5742,8 @@ std::vector<std::string> BlueStore::get_tracked_keys() const noexcept
57425742 "bluestore_warn_on_no_per_pool_omap"s,
57435743 "bluestore_warn_on_no_per_pg_omap"s,
57445744 "bluestore_max_defer_interval"s,
5745- "bluestore_onode_segment_size"s
5745+ "bluestore_onode_segment_size"s,
5746+ "bluestore_allocator_lookup_policy"s
57465747 };
57475748}
57485749
@@ -5814,6 +5815,9 @@ void BlueStore::handle_conf_change(const ConfigProxy& conf,
58145815 changed.count("osd_memory_expected_fragmentation")) {
58155816 _update_osd_memory_options();
58165817 }
5818+ if (changed.count("bluestore_allocator_lookup_policy")) {
5819+ _update_allocator_lookup_policy();
5820+ }
58175821}
58185822
58195823void BlueStore::_set_compression()
@@ -5948,6 +5952,24 @@ void BlueStore::_update_osd_memory_options()
59485952 << dendl;
59495953}
59505954
5955+
5956+ void BlueStore::_update_allocator_lookup_policy()
5957+ {
5958+ auto policy = cct->_conf.get_val<string>("bluestore_allocator_lookup_policy");
5959+ if (policy == "hdd_optimized") {
5960+ use_last_allocator_lookup_position = true;
5961+ } else if (policy == "ssd_optimized") {
5962+ use_last_allocator_lookup_position = false;
5963+ } else {
5964+ // Apply "auto" policy for everything else.
5965+ // Which means reusing last lookup position for hdds.
5966+ use_last_allocator_lookup_position = _use_rotational_settings();
5967+ }
5968+ dout(5) << __func__
5969+ << " use_last_lookup_position " << use_last_allocator_lookup_position
5970+ << dendl;
5971+ }
5972+
59515973int BlueStore::_set_cache_sizes()
59525974{
59535975 ceph_assert(bdev);
@@ -11240,7 +11262,7 @@ int BlueStore::_fsck_on_open(BlueStore::FSCKDepth depth, bool repair)
1124011262 dout(5) << __func__ << "::NCB::(F)alloc=" << alloc << ", length=" << e->length << dendl;
1124111263 int64_t alloc_len =
1124211264 alloc->allocate(e->length, min_alloc_size,
11243- 0, 0 , &exts);
11265+ 0, -1 , &exts);
1124411266 if (alloc_len < 0 || alloc_len < (int64_t)e->length) {
1124511267 derr << __func__
1124611268 << " failed to allocate 0x" << std::hex << e->length
@@ -11694,7 +11716,7 @@ void BlueStore::inject_leaked(uint64_t len)
1169411716{
1169511717 PExtentVector exts;
1169611718 int64_t alloc_len = alloc->allocate(len, min_alloc_size,
11697- min_alloc_size * 256, 0 , &exts);
11719+ min_alloc_size * 256, -1 , &exts);
1169811720 ceph_assert(alloc_len >= 0); // generally we do not expect any errors
1169911721 if (fm->is_null_manager()) {
1170011722 return;
@@ -14087,6 +14109,7 @@ int BlueStore::_open_super_meta()
1408714109 _set_csum();
1408814110 _set_compression();
1408914111 _set_blob_size();
14112+ _update_allocator_lookup_policy();
1409014113
1409114114 _validate_bdev();
1409214115 return 0;
@@ -17019,7 +17042,8 @@ int BlueStore::_do_alloc_write(
1701917042 auto start = mono_clock::now();
1702017043 prealloc_left = alloc->allocate(
1702117044 need, min_alloc_size, need,
17022- 0, &prealloc);
17045+ use_last_allocator_lookup_position ? -1 : 0,
17046+ &prealloc);
1702317047 log_latency("allocator@_do_alloc_write",
1702417048 l_bluestore_allocator_lat,
1702517049 mono_clock::now() - start,
0 commit comments