From: Igor Fedotov Date: Wed, 19 Dec 2018 17:01:07 +0000 (+0300) Subject: os/bluestore: indicate BlueFS spillover and lacking compressor alerts X-Git-Tag: v14.1.0~227^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a7013a67549f3698ea101265ef8bf2e7e09a5ec1;p=ceph.git os/bluestore: indicate BlueFS spillover and lacking compressor alerts Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 8b0ae602f174..06f9544c919f 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4017,6 +4017,7 @@ void BlueStore::_set_compression() { auto m = Compressor::get_comp_mode_type(cct->_conf->bluestore_compression_mode); if (m) { + _clear_compression_alert(); comp_mode = *m; } else { derr << __func__ << " unrecognized value '" @@ -4024,6 +4025,9 @@ void BlueStore::_set_compression() << "' for bluestore_compression_mode, reverting to 'none'" << dendl; comp_mode = Compressor::COMP_NONE; + string s("unknown mode: "); + s += cct->_conf->bluestore_compression_mode; + _set_compression_alert(true, s.c_str()); } compressor = nullptr; @@ -4062,6 +4066,7 @@ void BlueStore::_set_compression() if (!compressor) { derr << __func__ << " unable to initialize " << alg_name.c_str() << " compressor" << dendl; + _set_compression_alert(false, alg_name.c_str()); } } @@ -5565,6 +5570,20 @@ int BlueStore::_balance_bluefs_freespace() bluefs->get_usage(&bluefs_usage); ceph_assert(bluefs_usage.size() > bluefs_shared_bdev); + bool clear_alert = true; + if (bluefs_shared_bdev == BlueFS::BDEV_SLOW) { + auto& p = bluefs_usage[bluefs_shared_bdev]; + if (p.first != p.second) { + string s("spilled over to slow device: "); + s += stringify(byte_u_t(p.second - p.first)); + _set_spillover_alert(s.c_str()); + clear_alert = false; + } + } + if (clear_alert) { + _clear_spillover_alert(); + } + // fixme: look at primary bdev only for now int64_t delta = _get_bluefs_size_delta( bluefs_usage[bluefs_shared_bdev].first, @@ -7991,6 +8010,7 @@ int BlueStore::statfs(struct store_statfs_t *buf, { if (alerts) { alerts->clear(); + _log_alerts(*alerts); } _get_statfs_overall(buf); { @@ -8700,7 +8720,10 @@ int BlueStore::_decompress(bufferlist& source, bufferlist* result) if (!cp.get()) { // if compressor isn't available - error, because cannot return // decompressed data? - derr << __func__ << " can't load decompressor " << alg << dendl; + + const char* alg_name = Compressor::get_comp_alg_name(alg); + derr << __func__ << " can't load decompressor " << alg_name << dendl; + _set_compression_alert(false, alg_name); r = -EIO; } else { r = cp->decompress(i, chdr.length, *result); @@ -11729,6 +11752,12 @@ int BlueStore::_do_alloc_write( CompressorRef cp = compressor; if (!cp || cp->get_type_name() != val) { cp = Compressor::create(cct, val); + if (!cp) { + if (_set_compression_alert(false, val.c_str())) { + derr << __func__ << " unable to initialize " << val.c_str() + << " compressor" << dendl; + } + } } return boost::optional(cp); } @@ -13579,6 +13608,37 @@ void BlueStore::_record_onode(OnodeRef &o, KeyValueDB::Transaction &txn) txn->set(PREFIX_OBJ, o->key.c_str(), o->key.size(), bl); } +void BlueStore::_log_alerts(osd_alert_list_t& alerts) +{ + std::lock_guard l(qlock); + + if (!spillover_alert.empty()) { + alerts.emplace( + "BLUEFS_SPILLOVER", + spillover_alert); + } + string s0(failed_cmode); + + if (!failed_compressors.empty()) { + if (!s0.empty()) { + s0 += ", "; + } + s0 += "unable to load:"; + bool first = true; + for (auto& s : failed_compressors) { + if (first) { + first = false; + } else { + s0 += ", "; + } + s0 += s; + } + alerts.emplace( + "BLUESTORE_NO_COMPRESSION", + s0); + } +} + // =========================================== // BlueStoreRepairer diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 8bf9f6f5effc..9e8b30954b4a 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2677,6 +2677,37 @@ private: debug_mdata_error_objects.erase(o); } } +private: + ceph::mutex qlock = ceph::make_mutex("BlueStore::Alerts::qlock"); + string failed_cmode; + set failed_compressors; + string spillover_alert; + + void _log_alerts(osd_alert_list_t& alerts); + bool _set_compression_alert(bool cmode, const char* s) { + std::lock_guard l(qlock); + if (cmode) { + bool ret = failed_cmode.empty(); + failed_cmode = s; + return ret; + } + return failed_compressors.emplace(s).second; + } + void _clear_compression_alert() { + std::lock_guard l(qlock); + failed_compressors.clear(); + failed_cmode.clear(); + } + + void _set_spillover_alert(const char* s) { + std::lock_guard l(qlock); + spillover_alert = s; + } + void _clear_spillover_alert() { + std::lock_guard l(qlock); + spillover_alert.clear(); + } + private: // --------------------------------------------------------