From: Yehuda Sadeh Date: Fri, 23 Jan 2015 02:24:10 +0000 (-0800) Subject: cls_rgw; fix json decoding and encoding of certain type X-Git-Tag: v0.93~156^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5652a1df4e92a5eb6f97ad6789a239369008836f;p=ceph.git cls_rgw; fix json decoding and encoding of certain type Signed-off-by: Yehuda Sadeh --- diff --git a/src/cls/rgw/cls_rgw_types.cc b/src/cls/rgw/cls_rgw_types.cc index c830991cab2..89c8476d71d 100644 --- a/src/cls/rgw/cls_rgw_types.cc +++ b/src/cls/rgw/cls_rgw_types.cc @@ -169,7 +169,7 @@ static void dump_bi_entry(bufferlist bl, BIIndexType index_type, Formatter *form } } -void rgw_cls_bi_entry::decode_json(JSONObj *obj) { +void rgw_cls_bi_entry::decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key) { JSONDecoder::decode_json("idx", idx, obj); string s; JSONDecoder::decode_json("type", s, obj); @@ -189,13 +189,21 @@ void rgw_cls_bi_entry::decode_json(JSONObj *obj) { rgw_bucket_dir_entry entry; JSONDecoder::decode_json("entry", entry, obj); ::encode(entry, data); + + if (effective_key) { + *effective_key = entry.key; + } } break; case OLHIdx: { - rgw_bucket_dir_entry entry; + rgw_bucket_olh_entry entry; JSONDecoder::decode_json("entry", entry, obj); ::encode(entry, data); + + if (effective_key) { + *effective_key = entry.key; + } } break; default: @@ -235,6 +243,17 @@ void rgw_bucket_olh_entry::dump(Formatter *f) const encode_json("pending_removal", pending_removal, f); } +void rgw_bucket_olh_entry::decode_json(JSONObj *obj) +{ + JSONDecoder::decode_json("key", key, obj); + JSONDecoder::decode_json("delete_marker", delete_marker, obj); + JSONDecoder::decode_json("epoch", epoch, obj); + JSONDecoder::decode_json("pending_log", pending_log, obj); + JSONDecoder::decode_json("tag", tag, obj); + JSONDecoder::decode_json("exists", exists, obj); + JSONDecoder::decode_json("pending_removal", pending_removal, obj); +} + void rgw_bucket_olh_log_entry::generate_test_instances(list& o) { rgw_bucket_olh_log_entry *entry = new rgw_bucket_olh_log_entry; @@ -270,6 +289,24 @@ void rgw_bucket_olh_log_entry::dump(Formatter *f) const encode_json("delete_marker", delete_marker, f); } +void rgw_bucket_olh_log_entry::decode_json(JSONObj *obj) +{ + JSONDecoder::decode_json("epoch", epoch, obj); + string op_str; + JSONDecoder::decode_json("op", op_str, obj); + if (op_str == "link_olh") { + op = CLS_RGW_OLH_OP_LINK_OLH; + } else if (op_str == "unlink_olh") { + op = CLS_RGW_OLH_OP_UNLINK_OLH; + } else if (op_str == "remove_instance") { + op = CLS_RGW_OLH_OP_REMOVE_INSTANCE; + } else { + op = CLS_RGW_OLH_OP_UNKNOWN; + } + JSONDecoder::decode_json("op_tag", op_tag, obj); + JSONDecoder::decode_json("key", key, obj); + JSONDecoder::decode_json("delete_marker", delete_marker, obj); +} void rgw_bi_log_entry::dump(Formatter *f) const { f->dump_string("op_id", id); diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 2799de5d5e3..237c45277ea 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -374,11 +374,12 @@ struct rgw_cls_bi_entry { } void dump(Formatter *f) const; - void decode_json(JSONObj *obj); + void decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key = NULL); }; WRITE_CLASS_ENCODER(rgw_cls_bi_entry) enum OLHLogOp { + CLS_RGW_OLH_OP_UNKNOWN = 0, CLS_RGW_OLH_OP_LINK_OLH = 1, CLS_RGW_OLH_OP_UNLINK_OLH = 2, /* object does not exist */ CLS_RGW_OLH_OP_REMOVE_INSTANCE = 3, @@ -391,7 +392,7 @@ struct rgw_bucket_olh_log_entry { cls_rgw_obj_key key; bool delete_marker; - rgw_bucket_olh_log_entry() : delete_marker(false) {} + rgw_bucket_olh_log_entry() : op(CLS_RGW_OLH_OP_UNKNOWN), delete_marker(false) {} void encode(bufferlist &bl) const { @@ -416,6 +417,7 @@ struct rgw_bucket_olh_log_entry { } static void generate_test_instances(list& o); void dump(Formatter *f) const; + void decode_json(JSONObj *obj); }; WRITE_CLASS_ENCODER(rgw_bucket_olh_log_entry) @@ -453,6 +455,7 @@ struct rgw_bucket_olh_entry { DECODE_FINISH(bl); } void dump(Formatter *f) const; + void decode_json(JSONObj *obj); }; WRITE_CLASS_ENCODER(rgw_bucket_olh_entry)