rgw_cls_bi_get_ret op_ret;
- op_ret.type = op.type;
- op_ret.idx = idx;
+ rgw_cls_bi_entry& entry = op_ret.entry;
- int r = cls_cxx_map_get_val(hctx, idx, &op_ret.data);
+ entry.type = op.type;
+ entry.idx = idx;
+
+ int r = cls_cxx_map_get_val(hctx, idx, &entry.data);
if (r < 0) {
CLS_LOG(10, "%s(): cls_cxx_map_get_val() returned %d", __func__, r);
return r;
int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid,
BIIndexType index_type, cls_rgw_obj_key& key,
- string *idx,
- bufferlist *data)
+ rgw_cls_bi_entry *entry)
{
bufferlist in, out;
struct rgw_cls_bi_get_op call;
return -EIO;
}
- *idx = op_ret.idx;
- data->swap(op_ret.data);
+ *entry = op_ret.entry;
return 0;
}
int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid,
BIIndexType index_type, cls_rgw_obj_key& key,
- string *idx, bufferlist *data);
+ rgw_cls_bi_entry *entry);
int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key,
bool delete_marker, const string& op_tag);
WRITE_CLASS_ENCODER(rgw_cls_bi_get_op)
struct rgw_cls_bi_get_ret {
- BIIndexType type;
- string idx;
- bufferlist data;
+ rgw_cls_bi_entry entry;
- rgw_cls_bi_get_ret() : type(PlainIdx) {}
+ rgw_cls_bi_get_ret() {}
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
- ::encode((uint8_t)type, bl);
- ::encode(idx, bl);
- ::encode(data, bl);
+ ::encode(entry, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
DECODE_START(1, bl);
- uint8_t c;
- ::decode(c, bl);
- type = (BIIndexType)c;
- ::decode(idx, bl);
- ::decode(data, bl);
+ ::decode(entry, bl);
DECODE_FINISH(bl);
}
};
WRITE_CLASS_ENCODER(rgw_cls_bi_get_ret)
-
struct rgw_cls_usage_log_read_op {
uint64_t start_epoch;
uint64_t end_epoch;
f->close_section();
}
+static void dump_bi_entry(bufferlist bl, BIIndexType index_type, Formatter *formatter)
+{
+ bufferlist::iterator iter = bl.begin();
+ switch (index_type) {
+ case PlainIdx:
+ case InstanceIdx:
+ {
+ rgw_bucket_dir_entry entry;
+ ::decode(entry, iter);
+ encode_json("entry", entry, formatter);
+ }
+ break;
+ case OLHIdx:
+ {
+ rgw_bucket_olh_entry entry;
+ ::decode(entry, iter);
+ encode_json("entry", entry, formatter);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void rgw_cls_bi_entry::dump(Formatter *f) const
+{
+ string type_str;
+ switch (type) {
+ case PlainIdx:
+ type_str = "plain";
+ break;
+ case InstanceIdx:
+ type_str = "instance";
+ break;
+ case OLHIdx:
+ type_str = "olh";
+ break;
+ default:
+ type_str = "invalid";
+ }
+ encode_json("type", type_str, f);
+ encode_json("idx", idx, f);
+ dump_bi_entry(data, type, f);
+}
+
void rgw_bucket_olh_entry::dump(Formatter *f) const
{
encode_json("key", key, f);
OLHIdx = 3,
};
+struct rgw_cls_bi_entry {
+ BIIndexType type;
+ string idx;
+ bufferlist data;
+
+ rgw_cls_bi_entry() : type(InvalidIdx) {}
+
+ void encode(bufferlist& bl) const {
+ ENCODE_START(1, 1, bl);
+ ::encode((uint8_t)type, bl);
+ ::encode(idx, bl);
+ ::encode(data, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(bufferlist::iterator& bl) {
+ DECODE_START(1, bl);
+ uint8_t c;
+ ::decode(c, bl);
+ type = (BIIndexType)c;
+ ::decode(idx, bl);
+ ::decode(data, bl);
+ DECODE_FINISH(bl);
+ }
+
+ void dump(Formatter *f) const;
+};
+WRITE_CLASS_ENCODER(rgw_cls_bi_entry)
+
enum OLHLogOp {
CLS_RGW_OLH_OP_LINK_OLH = 1,
CLS_RGW_OLH_OP_REMOVE_INSTANCE = 2,
obj.set_instance(object_version);
}
- string idx;
- bufferlist bl;
+ rgw_cls_bi_entry entry;
- ret = store->bi_get(bucket, obj, bi_index_type, &idx, &bl);
+ ret = store->bi_get(bucket, obj, bi_index_type, &entry);
if (ret < 0) {
cerr << "ERROR: bi_get(): " << cpp_strerror(-ret) << std::endl;
return -ret;
}
- formatter->open_object_section("result");
- encode_json("idx", idx, formatter);
- dump_bi_entry(bl, bi_index_type, formatter);
- formatter->close_section();
+ encode_json("entry", entry, formatter);
formatter->flush(cout);
}
return 0;
}
-int RGWRados::bi_get(rgw_bucket& bucket, rgw_obj& obj, BIIndexType index_type, string *idx, bufferlist *data)
+int RGWRados::bi_get(rgw_bucket& bucket, rgw_obj& obj, BIIndexType index_type, rgw_cls_bi_entry *entry)
{
librados::IoCtx index_ctx;
string oid;
cls_rgw_obj_key key(obj.get_index_key_name(), obj.get_instance());
- int ret = cls_rgw_bi_get(index_ctx, oid, index_type, key, idx, data);
+ int ret = cls_rgw_bi_get(index_ctx, oid, index_type, key, entry);
if (ret < 0)
return ret;
int list_bi_log_entries(rgw_bucket& bucket, string& marker, uint32_t max, std::list<rgw_bi_log_entry>& result, bool *truncated);
int trim_bi_log_entries(rgw_bucket& bucket, string& marker, string& end_marker);
- int bi_get(rgw_bucket& bucket, rgw_obj& obj, BIIndexType index_type, string *idx, bufferlist *data);
+ int bi_get(rgw_bucket& bucket, rgw_obj& obj, BIIndexType index_type, rgw_cls_bi_entry *entry);
int cls_obj_usage_log_add(const string& oid, rgw_usage_log_info& info);
int cls_obj_usage_log_read(string& oid, string& user, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,