From 228f52cca1866c40a3840e06bd260c1d92d59caa Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 26 Sep 2016 16:01:39 -0700 Subject: [PATCH] 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 --- src/cls/rgw/cls_rgw_client.cc | 9 +++++++++ src/cls/rgw/cls_rgw_client.h | 1 + src/cls/rgw/cls_rgw_types.cc | 24 ++++++++++++++++++++++++ src/cls/rgw/cls_rgw_types.h | 2 ++ 4 files changed, 36 insertions(+) diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index 49bb840c2f980..338cc2587572a 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -257,6 +257,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 a3555e7944185..df35cce4e3d8f 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -320,6 +320,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 89c8476d71d29..dc0b6e291915e 100644 --- a/src/cls/rgw/cls_rgw_types.cc +++ b/src/cls/rgw/cls_rgw_types.cc @@ -232,6 +232,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 dfa9286c0008e..78edcaadefd68 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -375,6 +375,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) -- 2.39.5