From: Yehuda Sadeh Date: Mon, 26 Sep 2016 23:01:39 +0000 (-0700) Subject: cls/rgw: utilities to support raw bucket index operations X-Git-Tag: v11.1.0~548^2~18 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9b3a2a40a5732689be98a940f7e6c3c4a6e73c53;p=ceph-ci.git cls/rgw: utilities to support raw bucket index operations New flavour of bi_put() call, and a function to extract key off a raw bi entry. Signed-off-by: Yehuda Sadeh --- diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index f2dc02148bf..c91a20c24ce 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -277,6 +277,15 @@ int cls_rgw_bi_put(librados::IoCtx& io_ctx, const string oid, rgw_cls_bi_entry& return 0; } +void cls_rgw_bi_put(ObjectWriteOperation& op, const string oid, rgw_cls_bi_entry& entry) +{ + bufferlist in, out; + struct rgw_cls_bi_put_op call; + call.entry = entry; + ::encode(call, in); + op.exec("rgw", "bi_put", in); +} + int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid, const string& name, const string& marker, uint32_t max, list *entries, bool *is_truncated) diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index 4c68385f5a8..22642c52c0a 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -324,6 +324,7 @@ int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid, BIIndexType index_type, cls_rgw_obj_key& key, rgw_cls_bi_entry *entry); int cls_rgw_bi_put(librados::IoCtx& io_ctx, const string oid, rgw_cls_bi_entry& entry); +void cls_rgw_bi_put(librados::ObjectWriteOperation& op, const string oid, rgw_cls_bi_entry& entry); int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid, const string& name, const string& marker, uint32_t max, list *entries, bool *is_truncated); diff --git a/src/cls/rgw/cls_rgw_types.cc b/src/cls/rgw/cls_rgw_types.cc index 79a52722d66..428dd11fbf9 100644 --- a/src/cls/rgw/cls_rgw_types.cc +++ b/src/cls/rgw/cls_rgw_types.cc @@ -237,6 +237,30 @@ void rgw_cls_bi_entry::dump(Formatter *f) const dump_bi_entry(data, type, f); } +void rgw_cls_bi_entry::get_key(cls_rgw_obj_key *key) +{ + bufferlist::iterator iter = data.begin(); + switch (type) { + case PlainIdx: + case InstanceIdx: + { + rgw_bucket_dir_entry entry; + ::decode(entry, iter); + *key = entry.key; + } + break; + case OLHIdx: + { + rgw_bucket_olh_entry entry; + ::decode(entry, iter); + *key = entry.key; + } + break; + default: + break; + } +} + void rgw_bucket_olh_entry::dump(Formatter *f) const { encode_json("key", key, f); diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 33d273ac3ea..04383147e24 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -388,6 +388,8 @@ struct rgw_cls_bi_entry { void dump(Formatter *f) const; void decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key = NULL); + + void get_key(cls_rgw_obj_key *key); }; WRITE_CLASS_ENCODER(rgw_cls_bi_entry)