From: Yehuda Sadeh Date: Tue, 11 Oct 2016 22:44:17 +0000 (-0700) Subject: rgw: decode rgw_raw_obj as rgw_obj when it's old object X-Git-Tag: v12.0.1~111^2~24 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3583d67d61ee9b95f1aae9121b216d014f476190;p=ceph.git rgw: decode rgw_raw_obj as rgw_obj when it's old object Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 19c55b31131db..a91c89e0a9a9e 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -14,6 +14,7 @@ #include "rgw_common.h" #include "rgw_acl.h" #include "rgw_string.h" +#include "rgw_rados.h" #include "common/ceph_crypto.h" #include "common/armor.h" @@ -1434,6 +1435,14 @@ bool RGWUserCaps::is_valid_cap_type(const string& tp) return false; } +void rgw_raw_obj::decode_from_rgw_obj(bufferlist::iterator& bl) +{ + rgw_obj old_obj; + ::decode(old_obj, bl); + + RGWRados::obj_to_raw(old_obj, this); +} + std::string rgw_bucket::get_key(char tenant_delim, char id_delim) const { static constexpr size_t shard_len{12}; // ":4294967295\0" diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 5cd07b5ab3abc..53b01dc61979f 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -861,9 +861,21 @@ struct rgw_raw_obj { ::encode(loc, bl); ENCODE_FINISH(bl); } + + void decode_from_rgw_obj(bufferlist::iterator& bl); + void decode(bufferlist::iterator& bl) { - DECODE_START(6, bl); -#warning decode old rgw_obj + unsigned ofs = bl.get_off(); + DECODE_START(6, bl); + if (struct_v < 6) { + /* + * this object was encoded as rgw_obj, prior to rgw_raw_obj been split out of it, + * let's decode it as rgw_obj and convert it + */ + bl.seek(ofs); + decode_from_rgw_obj(bl); + return; + } ::decode(pool, bl); ::decode(oid, bl); ::decode(loc, bl); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 5a63bb802f885..45388c2c95151 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -2272,7 +2272,7 @@ public: } int get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool = NULL); - void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj); + static void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj); int list_raw_objects(const rgw_pool& pool, const string& prefix_filter, int max, RGWListRawObjsCtx& ctx, list& oids,