1
0
mirror of https://github.com/ceph/ceph synced 2025-04-01 23:02:17 +00:00

tools/ceph-objectstore-tool: dump onode internal metadata.

Supported for BlueStore only.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
This commit is contained in:
Igor Fedotov 2019-04-08 13:35:48 +03:00
parent bb142b2182
commit c3968c4f03
4 changed files with 110 additions and 0 deletions

View File

@ -1705,6 +1705,24 @@ public:
virtual int fiemap(CollectionHandle& c, const ghobject_t& oid,
uint64_t offset, size_t len, std::map<uint64_t, uint64_t>& destmap) = 0;
/**
* dump_onode -- dumps onode metadata in human readable form,
intended primiarily for debugging
*
* @param cid collection for object
* @param oid oid of object
* @param section_name section name to create and print under
* @param f Formatter class instance to print to
* @returns 0 on success, negative error code on failure.
*/
virtual int dump_onode(
CollectionHandle &c,
const ghobject_t& oid,
const string& section_name,
Formatter *f) {
return -ENOTSUP;
}
/**
* getattr -- get an xattr of an object
*

View File

@ -1628,6 +1628,16 @@ void BlueStore::OnodeSpace::dump(CephContext *cct)
#undef dout_prefix
#define dout_prefix *_dout << "bluestore.sharedblob(" << this << ") "
void BlueStore::SharedBlob::dump(Formatter* f) const
{
f->dump_bool("loaded", loaded);
if (loaded) {
persistent->dump(f);
} else {
f->dump_unsigned("sbid_unloaded", sbid_unloaded);
}
}
ostream& operator<<(ostream& out, const BlueStore::SharedBlob& sb)
{
out << "SharedBlob(" << &sb;
@ -1731,6 +1741,17 @@ void BlueStore::SharedBlobSet::dump(CephContext *cct)
#undef dout_prefix
#define dout_prefix *_dout << "bluestore.blob(" << this << ") "
void BlueStore::Blob::dump(Formatter* f) const
{
if (is_spanning()) {
f->dump_unsigned("spanning_id ", id);
}
blob.dump(f);
if (shared_blob) {
f->dump_object("shared", *shared_blob);
}
}
ostream& operator<<(ostream& out, const BlueStore::Blob& b)
{
out << "Blob(" << &b;
@ -1970,6 +1991,14 @@ void BlueStore::Blob::decode(
// Extent
void BlueStore::Extent::dump(Formatter* f) const
{
f->dump_unsigned("logical_offset", logical_offset);
f->dump_unsigned("length", length);
f->dump_unsigned("blob_offset", blob_offset);
f->dump_object("blob", *blob);
}
ostream& operator<<(ostream& out, const BlueStore::Extent& e)
{
return out << std::hex << "0x" << e.logical_offset << "~" << e.length
@ -2000,6 +2029,16 @@ BlueStore::ExtentMap::ExtentMap(Onode *o)
o->c->store->cct->_conf->bluestore_extent_map_inline_shard_prealloc_size) {
}
void BlueStore::ExtentMap::dump(Formatter* f) const
{
f->open_array_section("extents");
for (auto& e : extent_map) {
f->dump_object("extent", e);
}
f->close_section();
}
void BlueStore::ExtentMap::dup(BlueStore* b, TransContext* txc,
CollectionRef& c, OnodeRef& oldo, OnodeRef& newo, uint64_t& srcoff,
uint64_t& length, uint64_t& dstoff) {
@ -3095,6 +3134,12 @@ void BlueStore::Onode::flush()
ldout(c->store->cct, 20) << __func__ << " done" << dendl;
}
void BlueStore::Onode::dump(Formatter* f) const
{
onode.dump(f);
extent_map.dump(f);
}
// =======================================================
// WriteContext
@ -8873,6 +8918,42 @@ int BlueStore::fiemap(
return r;
}
int BlueStore::dump_onode(CollectionHandle &c_,
const ghobject_t& oid,
const string& section_name,
Formatter *f)
{
Collection *c = static_cast<Collection *>(c_.get());
dout(15) << __func__ << " " << c->cid << " " << oid << dendl;
if (!c->exists)
return -ENOENT;
int r;
{
RWLock::RLocker l(c->lock);
OnodeRef o = c->get_onode(oid, false);
if (!o || !o->exists) {
r = -ENOENT;
goto out;
}
// FIXME minor: actually the next line isn't enough to
// load shared blobs. Leaving as is for now..
//
o->extent_map.fault_range(db, 0, OBJECT_MAX_SIZE);
_dump_onode<0>(o);
f->open_object_section(section_name.c_str());
o->dump(f);
f->close_section();
r = 0;
}
out:
dout(10) << __func__ << " " << c->cid << " " << oid
<< " = " << r << dendl;
return r;
}
int BlueStore::getattr(
CollectionHandle &c_,
const ghobject_t& oid,

View File

@ -411,6 +411,7 @@ public:
friend void intrusive_ptr_add_ref(SharedBlob *b) { b->get(); }
friend void intrusive_ptr_release(SharedBlob *b) { b->put(); }
void dump(Formatter* f) const;
friend ostream& operator<<(ostream& out, const SharedBlob& sb);
void get() {
@ -516,6 +517,7 @@ public:
friend void intrusive_ptr_add_ref(Blob *b) { b->get(); }
friend void intrusive_ptr_release(Blob *b) { b->put(); }
void dump(Formatter* f) const;
friend ostream& operator<<(ostream& out, const Blob &b);
const bluestore_blob_use_tracker_t& get_blob_use_tracker() const {
@ -693,6 +695,8 @@ public:
}
}
void dump(Formatter* f) const;
void assign_blob(const BlobRef& b) {
ceph_assert(!blob);
blob = b;
@ -811,6 +815,8 @@ public:
clear_needs_reshard();
}
void dump(Formatter* f) const;
bool encode_some(uint32_t offset, uint32_t length, bufferlist& bl,
unsigned *pn);
unsigned decode_some(bufferlist& bl);
@ -1065,6 +1071,8 @@ public:
extent_map(this) {
}
void dump(Formatter* f) const;
void flush();
void get() {
++nref;
@ -2523,6 +2531,8 @@ public:
int fiemap(CollectionHandle &c, const ghobject_t& oid,
uint64_t offset, size_t len, map<uint64_t, uint64_t>& destmap) override;
int dump_onode(CollectionHandle &c, const ghobject_t& oid,
const string& section_name, Formatter *f) override;
int getattr(CollectionHandle &c, const ghobject_t& oid, const char *name,
bufferptr& value) override;

View File

@ -2438,6 +2438,7 @@ int print_obj_info(ObjectStore *store, coll_t coll, ghobject_t &ghobj, Formatter
<< cpp_strerror(r) << std::endl;
}
}
gr = store->dump_onode(ch, ghobj, "onode", formatter);
formatter->close_section();
formatter->flush(cout);