Skip to content

Commit fbb4d43

Browse files
authored
Merge pull request ceph#61214 from aclamk/wip-aclamk-bs-fragmentation-health
os/bluestore: Add health warning for bluestore fragmentation
2 parents 5e0bb56 + 3c5ae6c commit fbb4d43

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

src/common/options/global.yaml.in

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5490,6 +5490,29 @@ options:
54905490
desc: Enable health indication when spurious read errors are observed by OSD
54915491
default: true
54925492
with_legacy: true
5493+
- name: bluestore_warn_on_free_fragmentation
5494+
type: float
5495+
level: basic
5496+
desc: Level at which disk free fragmentation causes health warning. Set "1" to disable.
5497+
This is same value as admin command "bluestore allocator score block".
5498+
default: 0.8
5499+
with_legacy: false
5500+
flags:
5501+
- runtime
5502+
see_also:
5503+
- bluestore_fragmentation_check_period
5504+
- name: bluestore_fragmentation_check_period
5505+
type: uint
5506+
level: basic
5507+
desc: The period to perform bluestore free fragmentation check.
5508+
Checking fragmentation is usually almost immediate. For highly fragmented storage,
5509+
it can take several miliseconds. It can cause a stall to a write operation.
5510+
default: 3600
5511+
with_legacy: false
5512+
flags:
5513+
- runtime
5514+
see_also:
5515+
- bluestore_warn_on_free_fragmentation
54935516
- name: bluestore_slow_ops_warn_lifetime
54945517
type: uint
54955518
level: advanced

src/os/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ endif()
4343
add_library(os STATIC ${libos_srcs})
4444
target_link_libraries(os
4545
legacy-option-headers
46-
blk)
46+
blk
47+
${FMT_LIB})
4748

4849
target_link_libraries(os heap_profiler kv)
4950

src/os/bluestore/BlueStore.cc

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,7 +5278,7 @@ void BlueStore::Collection::split_cache(
52785278
// MempoolThread
52795279

52805280
#undef dout_prefix
5281-
#define dout_prefix *_dout << "bluestore.MempoolThread(" << this << ") "
5281+
#define dout_prefix *_dout << "bluestore.MempoolThread "
52825282
#undef dout_context
52835283
#define dout_context store->cct
52845284

@@ -5405,6 +5405,23 @@ void *BlueStore::MempoolThread::entry()
54055405
interval_stats_trim = false;
54065406

54075407
store->refresh_perf_counters();
5408+
uint64_t period = store->cct->_conf.get_val<uint64_t>("bluestore_fragmentation_check_period");
5409+
if (period != 0 && store->alloc) {
5410+
auto now = mono_clock::now();
5411+
timespan elapsed = now - last_fragmentation_check;
5412+
if (elapsed > make_timespan(period)) {
5413+
last_fragmentation_check = now;
5414+
double score;
5415+
score = store->alloc->get_fragmentation_score();
5416+
store->logger->set(l_bluestore_fragmentation, score * 1e6);
5417+
now = mono_clock::now();
5418+
elapsed = now - last_fragmentation_check;
5419+
auto seconds = elapsed.count() * 1e-9;
5420+
dout(0) << std::fixed << std::setprecision(6)
5421+
<< "fragmentation_score=" << score << " took=" << seconds << "s" << dendl;
5422+
}
5423+
}
5424+
54085425
auto wait = ceph::make_timespan(
54095426
store->cct->_conf->bluestore_cache_trim_interval);
54105427
cond.wait_for(l, wait);
@@ -15110,9 +15127,6 @@ void BlueStore::_kv_finalize_thread()
1511015127

1511115128
// this is as good a place as any ...
1511215129
_reap_collections();
15113-
logger->set(l_bluestore_fragmentation,
15114-
(uint64_t)(alloc ? alloc->get_fragmentation() * 1000 : 0));
15115-
1511615130
log_latency("kv_final",
1511715131
l_bluestore_kv_final_lat,
1511815132
mono_clock::now() - start,
@@ -19106,6 +19120,11 @@ void BlueStore::_log_alerts(osd_alert_list_t& alerts)
1910619120
"BLUESTORE_NO_COMPRESSION",
1910719121
s0);
1910819122
}
19123+
if (logger->get(l_bluestore_fragmentation) >
19124+
cct->_conf.get_val<double>("bluestore_warn_on_free_fragmentation") * 1e6) {
19125+
alerts.emplace("BLUESTORE_FREE_FRAGMENTATION",
19126+
fmt::format("{0:.6f}", logger->get(l_bluestore_fragmentation) * 1e-6));
19127+
}
1910919128
}
1911019129

1911119130
void BlueStore::_collect_allocation_stats(uint64_t need, uint32_t alloc_size,

src/os/bluestore/BlueStore.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2772,6 +2772,8 @@ class BlueStore : public ObjectStore,
27722772
private:
27732773
void _update_cache_settings();
27742774
void _resize_shards(bool interval_stats);
2775+
2776+
mono_clock::time_point last_fragmentation_check;
27752777
} mempool_thread;
27762778

27772779
#ifdef WITH_BLKIN

0 commit comments

Comments
 (0)