From a5896e5c01f5998a6a4e4adc174248eff8e2dfce Mon Sep 17 00:00:00 2001 From: fang yuxiang Date: Tue, 9 Jan 2018 00:54:55 +0800 Subject: [PATCH] rgw: make radosgw object stat RGW_ATTR_COMPRESSION dump readable Signed-off-by: fang yuxiang fang.yuxiang@eisoo.com --- src/rgw/rgw_admin.cc | 2 ++ src/rgw/rgw_json_enc.cc | 14 ++++++++++++++ src/rgw/rgw_rados.h | 4 +++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 03066016731..0e990371cb0 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -5886,6 +5886,8 @@ next: handled = dump_string("tag", bl, formatter); } else if (iter->first == RGW_ATTR_ETAG) { handled = dump_string("etag", bl, formatter); + } else if (iter->first == RGW_ATTR_COMPRESSION) { + handled = decode_dump("compression", bl, formatter); } if (!handled) diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index 48690abc9da..798970723f5 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -1634,3 +1634,17 @@ void RGWLifecycleConfiguration::dump(Formatter *f) const } f->close_section(); } + +void compression_block::dump(Formatter *f) const +{ + f->dump_unsigned("old_ofs", old_ofs); + f->dump_unsigned("new_ofs", new_ofs); + f->dump_unsigned("len", len); +} + +void RGWCompressionInfo::dump(Formatter *f) const +{ + f->dump_string("compression_type", compression_type); + f->dump_unsigned("orig_size", orig_size); + ::encode_json("blocks", blocks, f); +} diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 62699a0e44d..2b9b9c468ca 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -196,6 +196,7 @@ struct compression_block { ::decode(len, bl); DECODE_FINISH(bl); } + void dump(Formatter *f) const; }; WRITE_CLASS_ENCODER(compression_block) @@ -223,7 +224,8 @@ struct RGWCompressionInfo { ::decode(orig_size, bl); ::decode(blocks, bl); DECODE_FINISH(bl); - } + } + void dump(Formatter *f) const; }; WRITE_CLASS_ENCODER(RGWCompressionInfo)