]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: indicate BlueFS spillover and lacking compressor alerts
authorIgor Fedotov <ifedotov@suse.com>
Wed, 19 Dec 2018 17:01:07 +0000 (20:01 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Sat, 26 Jan 2019 14:21:45 +0000 (17:21 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 8b0ae602f1743ed1291e5da8a9f7633765b12ffe..06f9544c919fbdd467515dfaf1465a8573c01ba9 100644 (file)
@@ -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<CompressorRef>(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
 
index 8bf9f6f5effcc0450ca3b79f0c349dd3f537311d..9e8b30954b4abd76fef5cd7d1e004db342766f0c 100644 (file)
@@ -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<string> 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:
 
   // --------------------------------------------------------