// vim: ts=8 sw=2 smarttab
#include "BlueAdmin.h"
+#include "Compression.h"
#include "common/pretty_binary.h"
#include "common/debug.h"
#include <asm-generic/errno-base.h>
this,
"print object internals");
ceph_assert(r == 0);
+ r = admin_socket->register_command(
+ "bluestore compression stats "
+ "name=collection,type=CephString,req=false",
+ this,
+ "print compression stats, per collection");
+ ceph_assert(r == 0);
}
}
}
r = -ENOENT;
ss << "No collection that can hold such object" << std::endl;
+ } else if (command == "bluestore compression stats") {
+ std::vector<CollectionRef> copied;
+ {
+ std::shared_lock l(store.coll_lock);
+ copied.reserve(store.coll_map.size());
+ for (const auto& c : store.coll_map) {
+ copied.push_back(c.second);
+ }
+ }
+ std::string coll;
+ cmd_getval(cmdmap, "collection", coll);
+ f->open_array_section("compression");
+ for (const auto& c : copied) {
+ std::shared_lock l(c->lock);
+ if ((coll.empty() && bool(c->estimator))
+ || coll == c->get_cid().c_str()) {
+ f->open_object_section("collection");
+ f->dump_string("cid", c->get_cid().c_str());
+ f->open_object_section("estimator");
+ if (c->estimator) {
+ c->estimator->dump(f);
+ }
+ f->close_section();
+ f->close_section();
+ }
+ }
+ f->close_section();
+ return 0;
} else {
ss << "Invalid command" << std::endl;
r = -ENOSYS;
cleanup();
}
+void Estimator::dump(Formatter *f) const {
+ f->dump_float("expected_compression_now", expected_compression_factor);
+ f->dump_float("expected_recompression_error", expected_recompression_error);
+ f->dump_float("expected_pad_expansion", expected_pad_expansion);
+}
+
Estimator* BlueStore::create_estimator()
{
return new Estimator(this);