From: Casey Bodley Date: Wed, 30 Nov 2016 14:45:14 +0000 (-0500) Subject: rgw: add compression_type field to RGWZonePlacementInfo X-Git-Tag: v11.1.0~105^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b31d06994c65329fb2aa248412b18e6a434aaf31;p=ceph.git rgw: add compression_type field to RGWZonePlacementInfo Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index 12f25e1742f4..ca4b1e372037 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -881,6 +881,7 @@ void RGWZonePlacementInfo::dump(Formatter *f) const encode_json("data_pool", data_pool, f); encode_json("data_extra_pool", data_extra_pool, f); encode_json("index_type", (uint32_t)index_type, f); + encode_json("compression", compression_type, f); } void RGWZonePlacementInfo::decode_json(JSONObj *obj) @@ -891,6 +892,7 @@ void RGWZonePlacementInfo::decode_json(JSONObj *obj) uint32_t it; JSONDecoder::decode_json("index_type", it, obj); index_type = (RGWBucketIndexType)it; + JSONDecoder::decode_json("compression", compression_type, obj); } void RGWZoneParams::decode_json(JSONObj *obj) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c6fb5cf36e16..979bea54b9cd 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1654,6 +1654,17 @@ int RGWZoneParams::set_as_default(bool exclusive) return RGWSystemMetaObj::set_as_default(exclusive); } +const string& RGWZoneParams::get_compression_type(const string& placement_rule) const +{ + static const std::string NONE{"none"}; + auto p = placement_pools.find(placement_rule); + if (p == placement_pools.end()) { + return NONE; + } + const auto& type = p->second.compression_type; + return !type.empty() ? type : NONE; +} + void RGWPeriodMap::encode(bufferlist& bl) const { ENCODE_START(2, 1, bl); ::encode(id, bl); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 3d44e8673c36..32856a20aaea 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -933,20 +933,22 @@ struct RGWZonePlacementInfo { string data_pool; string data_extra_pool; /* if not set we should use data_pool */ RGWBucketIndexType index_type; + std::string compression_type; RGWZonePlacementInfo() : index_type(RGWBIType_Normal) {} void encode(bufferlist& bl) const { - ENCODE_START(5, 1, bl); + ENCODE_START(6, 1, bl); ::encode(index_pool, bl); ::encode(data_pool, bl); ::encode(data_extra_pool, bl); ::encode((uint32_t)index_type, bl); + ::encode(compression_type, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { - DECODE_START(5, bl); + DECODE_START(6, bl); ::decode(index_pool, bl); ::decode(data_pool, bl); if (struct_v >= 4) { @@ -957,6 +959,9 @@ struct RGWZonePlacementInfo { ::decode(it, bl); index_type = (RGWBucketIndexType)it; } + if (struct_v >= 6) { + ::decode(compression_type, bl); + } DECODE_FINISH(bl); } const string& get_data_extra_pool() { @@ -1013,6 +1018,8 @@ struct RGWZoneParams : RGWSystemMetaObj { int create_default(bool old_format = false); int create(bool exclusive = true); int fix_pool_names(); + + const string& get_compression_type(const string& placement_rule) const; void encode(bufferlist& bl) const { ENCODE_START(8, 1, bl);