cls_method_handle_t h_rgw_bucket_prepare_op;
cls_method_handle_t h_rgw_bucket_complete_op;
cls_method_handle_t h_rgw_bucket_link_olh;
+cls_method_handle_t h_rgw_bucket_read_olh_log;
cls_method_handle_t h_rgw_bi_log_list_op;
cls_method_handle_t h_rgw_dir_suggest_changes;
cls_method_handle_t h_rgw_user_usage_log_add;
static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
{
// decode request
- cls_rgw_link_olh_op op;
+ rgw_cls_link_olh_op op;
bufferlist::iterator iter = in->begin();
try {
::decode(op, iter);
return 0;
}
+static int rgw_bucket_read_olh_log(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
+{
+ // decode request
+ rgw_cls_read_olh_log_op op;
+ bufferlist::iterator iter = in->begin();
+ try {
+ ::decode(op, iter);
+ } catch (buffer::error& err) {
+ CLS_LOG(0, "ERROR: rgw_bucket_read_olh_log(): failed to decode request\n");
+ return -EINVAL;
+ }
+
+ if (!op.olh.instance.empty()) {
+ CLS_LOG(1, "bad key passed in (non empty instance)");
+ return -EINVAL;
+ }
+
+ struct rgw_bucket_olh_entry olh_data_entry;
+ string olh_data_key;
+ encode_olh_data_key(op.olh, &olh_data_key);
+ int ret = read_index_entry(hctx, olh_data_key, &olh_data_entry);
+ if (ret < 0 && ret != -ENOENT) {
+ CLS_LOG(0, "ERROR: read_index_entry() olh_key=%s ret=%d", olh_data_key.c_str(), ret);
+ return ret;
+ }
+
+ rgw_cls_read_olh_log_ret op_ret;
+
+#define MAX_OLH_LOG_ENTRIES 1000
+ map<uint64_t, rgw_bucket_olh_log_entry>& log = olh_data_entry.pending_log;
+
+ if (log.begin()->first > op.ver_marker && log.size() <= MAX_OLH_LOG_ENTRIES) {
+ op_ret.log = log;
+ op_ret.is_truncated = false;
+ } else {
+ map<uint64_t, rgw_bucket_olh_log_entry>::iterator iter = log.upper_bound(op.ver_marker);
+
+ for (int i = 0; i < MAX_OLH_LOG_ENTRIES && iter != log.end(); ++i, ++iter) {
+ op_ret.log[iter->first] = iter->second;
+ }
+ op_ret.is_truncated = (iter != log.end());
+ }
+
+ ::encode(op_ret, *out);
+
+ return 0;
+}
+
int rgw_dir_suggest_changes(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
{
CLS_LOG(1, "rgw_dir_suggest_changes()");
cls_register_cxx_method(h_class, "bucket_prepare_op", CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_prepare_op, &h_rgw_bucket_prepare_op);
cls_register_cxx_method(h_class, "bucket_complete_op", CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_complete_op, &h_rgw_bucket_complete_op);
cls_register_cxx_method(h_class, "bucket_link_olh", CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_link_olh, &h_rgw_bucket_link_olh);
+ cls_register_cxx_method(h_class, "bucket_read_olh_log", CLS_METHOD_RD, rgw_bucket_read_olh_log, &h_rgw_bucket_read_olh_log);
+
cls_register_cxx_method(h_class, "bi_log_list", CLS_METHOD_RD, rgw_bi_log_list, &h_rgw_bi_log_list_op);
cls_register_cxx_method(h_class, "bi_log_trim", CLS_METHOD_RD | CLS_METHOD_WR, rgw_bi_log_trim, &h_rgw_bi_log_list_op);
cls_register_cxx_method(h_class, "dir_suggest_changes", CLS_METHOD_RD | CLS_METHOD_WR, rgw_dir_suggest_changes, &h_rgw_dir_suggest_changes);
bool delete_marker, const string& op_tag)
{
bufferlist in, out;
- struct cls_rgw_link_olh_op call;
+ struct rgw_cls_link_olh_op call;
call.key = key;
call.op_tag = op_tag;
call.delete_marker = delete_marker;
return 0;
}
+int cls_rgw_get_olh_log(IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, uint64_t ver_marker,
+ map<uint64_t, struct rgw_bucket_olh_log_entry> *log, bool *is_truncated)
+{
+ bufferlist in, out;
+ struct rgw_cls_read_olh_log_op call;
+ call.olh = olh;
+ call.ver_marker = ver_marker;
+ ::encode(call, in);
+ int r = io_ctx.exec(oid, "rgw", "bucket_read_olh_log", in, out);
+ if (r < 0)
+ return r;
+
+ struct rgw_cls_read_olh_log_ret ret;
+ try {
+ bufferlist::iterator iter = out.begin();
+ ::decode(ret, iter);
+ } catch (buffer::error& err) {
+ return -EIO;
+ }
+
+ if (log) {
+ *log = ret.log;
+ }
+ if (is_truncated) {
+ *is_truncated = ret.is_truncated;
+ }
+
+ return r;
+}
+
int cls_rgw_bucket_check_index_op(IoCtx& io_ctx, string& oid,
rgw_bucket_dir_header *existing_header,
rgw_bucket_dir_header *calculated_header)
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);
+int cls_rgw_get_olh_log(librados::IoCtx& io_ctx, string& oid, const cls_rgw_obj_key& olh, uint64_t ver_marker,
+ map<uint64_t, struct rgw_bucket_olh_log_entry> *log, bool *is_truncated);
int cls_rgw_bucket_check_index_op(librados::IoCtx& io_ctx, string& oid,
rgw_bucket_dir_header *existing_header,
};
WRITE_CLASS_ENCODER(rgw_cls_obj_complete_op)
-struct cls_rgw_link_olh_op {
+struct rgw_cls_link_olh_op {
cls_rgw_obj_key key;
bool delete_marker;
string op_tag;
- cls_rgw_link_olh_op() : delete_marker(false) {}
+ rgw_cls_link_olh_op() : delete_marker(false) {}
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);
}
void dump(Formatter *f) const;
+#warning implement me
};
-WRITE_CLASS_ENCODER(cls_rgw_link_olh_op)
+WRITE_CLASS_ENCODER(rgw_cls_link_olh_op)
+
+struct rgw_cls_read_olh_log_op
+{
+ cls_rgw_obj_key olh;
+ uint64_t ver_marker;
+
+ rgw_cls_read_olh_log_op() : ver_marker(0) {}
+
+ void encode(bufferlist &bl) const {
+ ENCODE_START(1, 1, bl);
+ ::encode(olh, bl);
+ ::encode(ver_marker, bl);
+ ENCODE_FINISH(bl);
+ }
+ void decode(bufferlist::iterator &bl) {
+ DECODE_START(1, bl);
+ ::decode(olh, bl);
+ ::decode(ver_marker, bl);
+ DECODE_FINISH(bl);
+ }
+ void dump(Formatter *f) const;
+#warning implement me
+};
+WRITE_CLASS_ENCODER(rgw_cls_read_olh_log_op)
+
+
+struct rgw_cls_read_olh_log_ret
+{
+ map<uint64_t, struct rgw_bucket_olh_log_entry> log;
+ bool is_truncated;
+
+ rgw_cls_read_olh_log_ret() : is_truncated(false) {}
+
+ void encode(bufferlist &bl) const {
+ ENCODE_START(2, 2, bl);
+ ::encode(log, bl);
+ ::encode(is_truncated, bl);
+ ENCODE_FINISH(bl);
+ }
+ void decode(bufferlist::iterator &bl) {
+ DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
+ ::decode(log, bl);
+ ::decode(is_truncated, bl);
+ DECODE_FINISH(bl);
+ }
+ void dump(Formatter *f) const;
+#warning implement me
+};
+WRITE_CLASS_ENCODER(rgw_cls_read_olh_log_ret)
struct rgw_cls_list_op
{
return 0;
}
+int RGWRados::bucket_index_read_olh_log(rgw_obj& obj_instance, uint64_t ver_marker,
+ map<uint64_t, rgw_bucket_olh_log_entry> *log,
+ bool *is_truncated)
+{
+ rgw_rados_ref ref;
+ rgw_bucket bucket;
+ int r = get_obj_ref(obj_instance, &ref, &bucket);
+ if (r < 0) {
+ return r;
+ }
+
+ librados::IoCtx index_ctx;
+ string oid;
+
+ int ret = open_bucket_index(bucket, index_ctx, oid);
+ if (ret < 0) {
+ return ret;
+ }
+
+ cls_rgw_obj_key key(obj_instance.get_index_key_name(), obj_instance.get_instance());
+ ret = cls_rgw_get_olh_log(index_ctx, oid, key, ver_marker, log, is_truncated);
+ if (ret < 0) {
+ return ret;
+ }
+
+ return 0;
+}
+
static void filter_attrset(map<string, bufferlist>& unfiltered_attrset, const string& check_prefix,
map<string, bufferlist> *attrset)
{
int olh_init_modification(rgw_obj& obj, string *tag);
int bucket_index_link_olh(rgw_obj& obj_instance, bool delete_marker, const string& op_tag);
+ int bucket_index_read_olh_log(rgw_obj& obj_instance, uint64_t ver_marker,
+ map<uint64_t, rgw_bucket_olh_log_entry> *log, bool *is_truncated);
int follow_olh(map<string, bufferlist>& attrset, rgw_obj& target);
int get_olh(rgw_obj& obj, RGWOLHInfo *olh);