Skip to content

Commit 05b5be7

Browse files
authored
Merge pull request ceph#65375 from ifed01/wip-ifed-bluefs-ratio
os/bluestore: report metadata/data ratio in BlueFS perf counter Reviewed-by: Mark Nelson <[email protected]>
2 parents a2c3957 + b47393e commit 05b5be7

File tree

2 files changed

+53
-10
lines changed

2 files changed

+53
-10
lines changed

src/os/bluestore/BlueFS.cc

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ void BlueFS::_init_logger()
258258
b.add_u64(l_bluefs_slow_used_bytes, "slow_used_bytes",
259259
"Used bytes (slow device)",
260260
"slou", PerfCountersBuilder::PRIO_USEFUL, unit_t(UNIT_BYTES));
261+
b.add_u64(l_bluefs_meta_ratio, "meta_ratio_micros",
262+
"Actual metadata/userdata ratio * 1e3",
263+
"mera", PerfCountersBuilder::PRIO_INTERESTING);
261264
b.add_u64(l_bluefs_num_files, "num_files", "File count",
262265
"f", PerfCountersBuilder::PRIO_USEFUL);
263266
b.add_u64(l_bluefs_log_bytes, "log_bytes", "Size of the metadata log",
@@ -485,6 +488,22 @@ void BlueFS::_update_logger_stats()
485488
logger->set(l_bluefs_slow_total_bytes, _get_block_device_size(BDEV_SLOW));
486489
logger->set(l_bluefs_slow_used_bytes, _get_used(BDEV_SLOW));
487490
}
491+
double r = 0.0;
492+
int64_t in_data = 0;
493+
int64_t in_meta = 0;
494+
in_data = get_used_non_bluefs();
495+
in_meta = _get_used(BDEV_SLOW) + _get_used(BDEV_DB) + _get_used(BDEV_WAL);
496+
if (in_data > 0) {
497+
dout(10) << __func__ << " got meta ratio parameters, "
498+
<< "data: " << in_data << ", meta: " << in_meta
499+
<< dendl;
500+
r = double(in_meta) / double(in_data);
501+
} else {
502+
dout(5) << __func__ << " got weird meta ratio parameters, "
503+
<< "data: " << in_data << ", meta: " << in_meta
504+
<< dendl;
505+
}
506+
logger->set(l_bluefs_meta_ratio, r * 1000);
488507
}
489508

490509
int BlueFS::add_block_device(unsigned id, const string& path, bool trim,
@@ -574,6 +593,17 @@ uint64_t BlueFS::get_used()
574593
return used;
575594
}
576595

596+
int64_t BlueFS::get_used_non_bluefs()
597+
{
598+
uint64_t ret = 0;
599+
if (shared_alloc_id > 0 && shared_alloc && shared_alloc->a) {
600+
ret = (int64_t)_get_block_device_size(shared_alloc_id) -
601+
shared_alloc->a->get_free() -
602+
shared_alloc->bluefs_used;
603+
}
604+
return ret;
605+
}
606+
577607
uint64_t BlueFS::_get_used(unsigned id) const
578608
{
579609
uint64_t used = 0;
@@ -657,12 +687,25 @@ void BlueFS::dump_block_extents(ostream& out)
657687
}
658688
auto total = get_block_device_size(i);
659689
auto free = get_free(i);
660-
661-
out << i << " : device size 0x" << std::hex << total
662-
<< "(" << byte_u_t(total) << ")"
663-
<< " : using 0x" << total - free
664-
<< "(" << byte_u_t(total - free) << ")"
665-
<< std::dec << std::endl;
690+
if (i != shared_alloc_id) {
691+
out << i << " : device size 0x" << std::hex << total
692+
<< "(" << byte_u_t(total) << ")"
693+
<< " : using 0x" << total - free
694+
<< "(" << byte_u_t(total - free) << ")"
695+
<< std::dec << std::endl;
696+
} else {
697+
auto bluefs_used = get_used(i);
698+
auto non_bluefs_used = get_used_non_bluefs();
699+
out << i << " : device size 0x" << std::hex << total
700+
<< "(" << byte_u_t(total) << ")"
701+
<< " : using 0x" << total - free
702+
<< "(" << byte_u_t(total - free) << ")"
703+
<< " : bluefs used 0x" << bluefs_used
704+
<< "(" << byte_u_t(bluefs_used) << ")"
705+
<< " : non-bluefs used 0x" << non_bluefs_used
706+
<< "(" << byte_u_t(non_bluefs_used) << ")"
707+
<< std::dec << std::endl;
708+
}
666709
}
667710
}
668711

@@ -4729,6 +4772,7 @@ void BlueFS::collect_alerts(osd_alert_list_t& alerts) {
47294772
if (bdev[BDEV_WAL]) {
47304773
bdev[BDEV_WAL]->collect_alerts(alerts, "WAL");
47314774
}
4775+
_update_logger_stats(); // just to have it updated more frequently
47324776
}
47334777

47344778
int BlueFS::open_for_read(
@@ -5339,10 +5383,7 @@ void OriginalVolumeSelector::get_paths(const std::string& base, paths& res) cons
53395383
#define dout_prefix *_dout << "OriginalVolumeSelector: "
53405384

53415385
void OriginalVolumeSelector::dump(ostream& sout) {
5342-
sout<< "wal_total:" << wal_total
5343-
<< ", db_total:" << db_total
5344-
<< ", slow_total:" << slow_total
5345-
<< std::endl;
5386+
sout << "*** no stats ***" << std::endl;
53465387
}
53475388

53485389
// ===============================================

src/os/bluestore/BlueFS.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ enum {
3333
l_bluefs_wal_used_bytes,
3434
l_bluefs_slow_total_bytes,
3535
l_bluefs_slow_used_bytes,
36+
l_bluefs_meta_ratio,
3637
l_bluefs_num_files,
3738
l_bluefs_log_bytes,
3839
l_bluefs_log_compactions,
@@ -811,6 +812,7 @@ class BlueFS {
811812
int revert_wal_to_plain();
812813

813814
uint64_t get_used();
815+
int64_t get_used_non_bluefs();
814816
uint64_t get_block_device_size(unsigned id);
815817
uint64_t get_free(unsigned id);
816818
uint64_t get_used(unsigned id);

0 commit comments

Comments
 (0)