1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
5 #include "cls/rgw/cls_rgw_const.h"
6 #include "cls/rgw/cls_rgw_client.h"
8 #include "common/debug.h"
10 using namespace librados;
12 const string BucketIndexShardsManager::KEY_VALUE_SEPARATOR = "#";
13 const string BucketIndexShardsManager::SHARDS_SEPARATOR = ",";
16 * This class represents the bucket index object operation callback context.
19 class ClsBucketIndexOpCtx : public ObjectOperationCompletion {
24 ClsBucketIndexOpCtx(T* _data, int *_ret_code) : data(_data), ret_code(_ret_code) { assert(data); }
25 ~ClsBucketIndexOpCtx() override {}
26 void handle_completion(int r, bufferlist& outbl) override {
29 bufferlist::iterator iter = outbl.begin();
30 ::decode((*data), iter);
31 } catch (buffer::error& err) {
41 void BucketIndexAioManager::do_completion(int id) {
42 Mutex::Locker l(lock);
44 map<int, librados::AioCompletion*>::iterator iter = pendings.find(id);
45 assert(iter != pendings.end());
46 completions[id] = iter->second;
49 // If the caller needs a list of finished objects, store them
50 // for further processing
51 map<int, string>::iterator miter = pending_objs.find(id);
52 if (miter != pending_objs.end()) {
53 completion_objs[id] = miter->second;
54 pending_objs.erase(miter);
60 bool BucketIndexAioManager::wait_for_completions(int valid_ret_code,
61 int *num_completions, int *ret_code, map<int, string> *objs) {
63 if (pendings.empty() && completions.empty()) {
68 if (completions.empty()) {
69 // Wait for AIO completion
73 // Clear the completed AIOs
74 map<int, librados::AioCompletion*>::iterator iter = completions.begin();
75 for (; iter != completions.end(); ++iter) {
76 int r = iter->second->get_return_value();
77 if (objs && r == 0) { /* update list of successfully completed objs */
78 map<int, string>::iterator liter = completion_objs.find(iter->first);
79 if (liter != completion_objs.end()) {
80 (*objs)[liter->first] = liter->second;
83 if (ret_code && (r < 0 && r != valid_ret_code))
85 iter->second->release();
88 (*num_completions) = completions.size();
95 void cls_rgw_bucket_init(ObjectWriteOperation& o)
98 o.exec(RGW_CLASS, RGW_BUCKET_INIT_INDEX, in);
101 static bool issue_bucket_index_init_op(librados::IoCtx& io_ctx,
102 const string& oid, BucketIndexAioManager *manager) {
104 librados::ObjectWriteOperation op;
106 op.exec(RGW_CLASS, RGW_BUCKET_INIT_INDEX, in);
107 return manager->aio_operate(io_ctx, oid, &op);
110 static bool issue_bucket_set_tag_timeout_op(librados::IoCtx& io_ctx,
111 const string& oid, uint64_t timeout, BucketIndexAioManager *manager) {
113 struct rgw_cls_tag_timeout_op call;
114 call.tag_timeout = timeout;
116 ObjectWriteOperation op;
117 op.exec(RGW_CLASS, RGW_BUCKET_SET_TAG_TIMEOUT, in);
118 return manager->aio_operate(io_ctx, oid, &op);
121 int CLSRGWIssueBucketIndexInit::issue_op(int shard_id, const string& oid)
123 return issue_bucket_index_init_op(io_ctx, oid, &manager);
126 void CLSRGWIssueBucketIndexInit::cleanup()
128 // Do best effort removal
129 for (map<int, string>::iterator citer = objs_container.begin(); citer != iter; ++citer) {
130 io_ctx.remove(citer->second);
134 int CLSRGWIssueSetTagTimeout::issue_op(int shard_id, const string& oid)
136 return issue_bucket_set_tag_timeout_op(io_ctx, oid, tag_timeout, &manager);
139 void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o, bool absolute,
140 const map<uint8_t, rgw_bucket_category_stats>& stats)
142 struct rgw_cls_bucket_update_stats_op call;
143 call.absolute = absolute;
147 o.exec(RGW_CLASS, RGW_BUCKET_UPDATE_STATS, in);
150 void cls_rgw_bucket_prepare_op(ObjectWriteOperation& o, RGWModifyOp op, string& tag,
151 const cls_rgw_obj_key& key, const string& locator, bool log_op,
152 uint16_t bilog_flags, rgw_zone_set& zones_trace)
154 struct rgw_cls_obj_prepare_op call;
158 call.locator = locator;
159 call.log_op = log_op;
160 call.bilog_flags = bilog_flags;
161 call.zones_trace = zones_trace;
164 o.exec(RGW_CLASS, RGW_BUCKET_PREPARE_OP, in);
167 void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, string& tag,
168 rgw_bucket_entry_ver& ver,
169 const cls_rgw_obj_key& key,
170 rgw_bucket_dir_entry_meta& dir_meta,
171 list<cls_rgw_obj_key> *remove_objs, bool log_op,
172 uint16_t bilog_flags,
173 rgw_zone_set *zones_trace)
177 struct rgw_cls_obj_complete_op call;
182 call.meta = dir_meta;
183 call.log_op = log_op;
184 call.bilog_flags = bilog_flags;
186 call.remove_objs = *remove_objs;
188 call.zones_trace = *zones_trace;
191 o.exec(RGW_CLASS, RGW_BUCKET_COMPLETE_OP, in);
194 static bool issue_bucket_list_op(librados::IoCtx& io_ctx,
195 const string& oid, const cls_rgw_obj_key& start_obj, const string& filter_prefix,
196 uint32_t num_entries, bool list_versions, BucketIndexAioManager *manager,
197 struct rgw_cls_list_ret *pdata) {
199 struct rgw_cls_list_op call;
200 call.start_obj = start_obj;
201 call.filter_prefix = filter_prefix;
202 call.num_entries = num_entries;
203 call.list_versions = list_versions;
206 librados::ObjectReadOperation op;
207 op.exec(RGW_CLASS, RGW_BUCKET_LIST, in, new ClsBucketIndexOpCtx<struct rgw_cls_list_ret>(pdata, NULL));
208 return manager->aio_operate(io_ctx, oid, &op);
211 int CLSRGWIssueBucketList::issue_op(int shard_id, const string& oid)
213 return issue_bucket_list_op(io_ctx, oid, start_obj, filter_prefix, num_entries, list_versions, &manager, &result[shard_id]);
216 void cls_rgw_remove_obj(librados::ObjectWriteOperation& o, list<string>& keep_attr_prefixes)
219 struct rgw_cls_obj_remove_op call;
220 call.keep_attr_prefixes = keep_attr_prefixes;
222 o.exec(RGW_CLASS, RGW_OBJ_REMOVE, in);
225 void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation& o, const string& attr)
228 struct rgw_cls_obj_store_pg_ver_op call;
231 o.exec(RGW_CLASS, RGW_OBJ_STORE_PG_VER, in);
234 void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation& o, const string& prefix, bool fail_if_exist)
237 struct rgw_cls_obj_check_attrs_prefix call;
238 call.check_prefix = prefix;
239 call.fail_if_exist = fail_if_exist;
241 o.exec(RGW_CLASS, RGW_OBJ_CHECK_ATTRS_PREFIX, in);
244 void cls_rgw_obj_check_mtime(librados::ObjectOperation& o, const real_time& mtime, bool high_precision_time, RGWCheckMTimeType type)
247 struct rgw_cls_obj_check_mtime call;
249 call.high_precision_time = high_precision_time;
252 o.exec(RGW_CLASS, RGW_OBJ_CHECK_MTIME, in);
255 int cls_rgw_bi_get(librados::IoCtx& io_ctx, const string oid,
256 BIIndexType index_type, cls_rgw_obj_key& key,
257 rgw_cls_bi_entry *entry)
260 struct rgw_cls_bi_get_op call;
262 call.type = index_type;
264 int r = io_ctx.exec(oid, RGW_CLASS, RGW_BI_GET, in, out);
268 struct rgw_cls_bi_get_ret op_ret;
269 bufferlist::iterator iter = out.begin();
271 ::decode(op_ret, iter);
272 } catch (buffer::error& err) {
276 *entry = op_ret.entry;
281 int cls_rgw_bi_put(librados::IoCtx& io_ctx, const string oid, rgw_cls_bi_entry& entry)
284 struct rgw_cls_bi_put_op call;
287 int r = io_ctx.exec(oid, RGW_CLASS, RGW_BI_PUT, in, out);
294 void cls_rgw_bi_put(ObjectWriteOperation& op, const string oid, rgw_cls_bi_entry& entry)
297 struct rgw_cls_bi_put_op call;
300 op.exec(RGW_CLASS, RGW_BI_PUT, in);
303 int cls_rgw_bi_list(librados::IoCtx& io_ctx, const string oid,
304 const string& name, const string& marker, uint32_t max,
305 list<rgw_cls_bi_entry> *entries, bool *is_truncated)
308 struct rgw_cls_bi_list_op call;
310 call.marker = marker;
313 int r = io_ctx.exec(oid, RGW_CLASS, RGW_BI_LIST, in, out);
317 struct rgw_cls_bi_list_ret op_ret;
318 bufferlist::iterator iter = out.begin();
320 ::decode(op_ret, iter);
321 } catch (buffer::error& err) {
325 entries->swap(op_ret.entries);
326 *is_truncated = op_ret.is_truncated;
331 int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op,
332 const string& oid, const cls_rgw_obj_key& key, bufferlist& olh_tag,
333 bool delete_marker, const string& op_tag, struct rgw_bucket_dir_entry_meta *meta,
334 uint64_t olh_epoch, ceph::real_time unmod_since, bool high_precision_time, bool log_op, rgw_zone_set& zones_trace)
337 struct rgw_cls_link_olh_op call;
339 call.olh_tag = string(olh_tag.c_str(), olh_tag.length());
340 call.op_tag = op_tag;
341 call.delete_marker = delete_marker;
345 call.olh_epoch = olh_epoch;
346 call.log_op = log_op;
347 call.unmod_since = unmod_since;
348 call.high_precision_time = high_precision_time;
349 call.zones_trace = zones_trace;
351 op.exec(RGW_CLASS, RGW_BUCKET_LINK_OLH, in);
352 int r = io_ctx.operate(oid, &op);
359 int cls_rgw_bucket_unlink_instance(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op,
361 const cls_rgw_obj_key& key, const string& op_tag,
362 const string& olh_tag, uint64_t olh_epoch, bool log_op, rgw_zone_set& zones_trace)
365 struct rgw_cls_unlink_instance_op call;
367 call.op_tag = op_tag;
368 call.olh_epoch = olh_epoch;
369 call.olh_tag = olh_tag;
370 call.log_op = log_op;
371 call.zones_trace = zones_trace;
373 op.exec(RGW_CLASS, RGW_BUCKET_UNLINK_INSTANCE, in);
374 int r = io_ctx.operate(oid, &op);
381 int cls_rgw_get_olh_log(IoCtx& io_ctx, string& oid, librados::ObjectReadOperation& op, const cls_rgw_obj_key& olh, uint64_t ver_marker,
382 const string& olh_tag,
383 map<uint64_t, vector<struct rgw_bucket_olh_log_entry> > *log, bool *is_truncated)
386 struct rgw_cls_read_olh_log_op call;
388 call.ver_marker = ver_marker;
389 call.olh_tag = olh_tag;
392 op.exec(RGW_CLASS, RGW_BUCKET_READ_OLH_LOG, in, &out, &op_ret);
393 int r = io_ctx.operate(oid, &op, NULL);
401 struct rgw_cls_read_olh_log_ret ret;
403 bufferlist::iterator iter = out.begin();
405 } catch (buffer::error& err) {
413 *is_truncated = ret.is_truncated;
419 void cls_rgw_trim_olh_log(librados::ObjectWriteOperation& op, const cls_rgw_obj_key& olh, uint64_t ver, const string& olh_tag)
422 struct rgw_cls_trim_olh_log_op call;
425 call.olh_tag = olh_tag;
427 op.exec(RGW_CLASS, RGW_BUCKET_TRIM_OLH_LOG, in);
430 int cls_rgw_clear_olh(IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid, const cls_rgw_obj_key& olh, const string& olh_tag)
433 struct rgw_cls_bucket_clear_olh_op call;
435 call.olh_tag = olh_tag;
438 op.exec(RGW_CLASS, RGW_BUCKET_CLEAR_OLH, in, &out, &op_ret);
439 int r = io_ctx.operate(oid, &op);
446 static bool issue_bi_log_list_op(librados::IoCtx& io_ctx, const string& oid, int shard_id,
447 BucketIndexShardsManager& marker_mgr, uint32_t max, BucketIndexAioManager *manager,
448 struct cls_rgw_bi_log_list_ret *pdata) {
450 cls_rgw_bi_log_list_op call;
451 call.marker = marker_mgr.get(shard_id, "");
455 librados::ObjectReadOperation op;
456 op.exec(RGW_CLASS, RGW_BI_LOG_LIST, in, new ClsBucketIndexOpCtx<struct cls_rgw_bi_log_list_ret>(pdata, NULL));
457 return manager->aio_operate(io_ctx, oid, &op);
460 int CLSRGWIssueBILogList::issue_op(int shard_id, const string& oid)
462 return issue_bi_log_list_op(io_ctx, oid, shard_id, marker_mgr, max, &manager, &result[shard_id]);
465 static bool issue_bi_log_trim(librados::IoCtx& io_ctx, const string& oid, int shard_id,
466 BucketIndexShardsManager& start_marker_mgr,
467 BucketIndexShardsManager& end_marker_mgr, BucketIndexAioManager *manager) {
469 cls_rgw_bi_log_trim_op call;
470 call.start_marker = start_marker_mgr.get(shard_id, "");
471 call.end_marker = end_marker_mgr.get(shard_id, "");
473 ObjectWriteOperation op;
474 op.exec(RGW_CLASS, RGW_BI_LOG_TRIM, in);
475 return manager->aio_operate(io_ctx, oid, &op);
478 int CLSRGWIssueBILogTrim::issue_op(int shard_id, const string& oid)
480 return issue_bi_log_trim(io_ctx, oid, shard_id, start_marker_mgr, end_marker_mgr, &manager);
483 static bool issue_bucket_check_index_op(IoCtx& io_ctx, const string& oid, BucketIndexAioManager *manager,
484 struct rgw_cls_check_index_ret *pdata) {
486 librados::ObjectReadOperation op;
487 op.exec(RGW_CLASS, RGW_BUCKET_CHECK_INDEX, in, new ClsBucketIndexOpCtx<struct rgw_cls_check_index_ret>(
489 return manager->aio_operate(io_ctx, oid, &op);
492 int CLSRGWIssueBucketCheck::issue_op(int shard_id, const string& oid)
494 return issue_bucket_check_index_op(io_ctx, oid, &manager, &result[shard_id]);
497 static bool issue_bucket_rebuild_index_op(IoCtx& io_ctx, const string& oid,
498 BucketIndexAioManager *manager) {
500 librados::ObjectWriteOperation op;
501 op.exec(RGW_CLASS, RGW_BUCKET_REBUILD_INDEX, in);
502 return manager->aio_operate(io_ctx, oid, &op);
505 int CLSRGWIssueBucketRebuild::issue_op(int shard_id, const string& oid)
507 return issue_bucket_rebuild_index_op(io_ctx, oid, &manager);
510 void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, bufferlist& updates)
513 ::encode(dirent, updates);
516 void cls_rgw_suggest_changes(ObjectWriteOperation& o, bufferlist& updates)
518 o.exec(RGW_CLASS, RGW_DIR_SUGGEST_CHANGES, updates);
521 int CLSRGWIssueGetDirHeader::issue_op(int shard_id, const string& oid)
523 cls_rgw_obj_key nokey;
524 return issue_bucket_list_op(io_ctx, oid, nokey, "", 0, false, &manager, &result[shard_id]);
527 static bool issue_resync_bi_log(librados::IoCtx& io_ctx, const string& oid, BucketIndexAioManager *manager)
530 librados::ObjectWriteOperation op;
531 op.exec("rgw", "bi_log_resync", in);
532 return manager->aio_operate(io_ctx, oid, &op);
535 int CLSRGWIssueResyncBucketBILog::issue_op(int shard_id, const string& oid)
537 return issue_resync_bi_log(io_ctx, oid, &manager);
540 static bool issue_bi_log_stop(librados::IoCtx& io_ctx, const string& oid, BucketIndexAioManager *manager)
543 librados::ObjectWriteOperation op;
544 op.exec("rgw", "bi_log_stop", in);
545 return manager->aio_operate(io_ctx, oid, &op);
548 int CLSRGWIssueBucketBILogStop::issue_op(int shard_id, const string& oid)
550 return issue_bi_log_stop(io_ctx, oid, &manager);
553 class GetDirHeaderCompletion : public ObjectOperationCompletion {
554 RGWGetDirHeader_CB *ret_ctx;
556 explicit GetDirHeaderCompletion(RGWGetDirHeader_CB *_ctx) : ret_ctx(_ctx) {}
557 ~GetDirHeaderCompletion() override {
560 void handle_completion(int r, bufferlist& outbl) override {
561 struct rgw_cls_list_ret ret;
563 bufferlist::iterator iter = outbl.begin();
565 } catch (buffer::error& err) {
569 ret_ctx->handle_response(r, ret.dir.header);
573 int cls_rgw_get_dir_header_async(IoCtx& io_ctx, string& oid, RGWGetDirHeader_CB *ctx)
576 struct rgw_cls_list_op call;
577 call.num_entries = 0;
579 ObjectReadOperation op;
580 GetDirHeaderCompletion *cb = new GetDirHeaderCompletion(ctx);
581 op.exec(RGW_CLASS, RGW_BUCKET_LIST, in, cb);
582 AioCompletion *c = librados::Rados::aio_create_completion(NULL, NULL, NULL);
583 int r = io_ctx.aio_operate(oid, c, &op, NULL);
591 int cls_rgw_usage_log_read(IoCtx& io_ctx, string& oid, string& user,
592 uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries,
593 string& read_iter, map<rgw_user_bucket, rgw_usage_log_entry>& usage,
597 *is_truncated = false;
600 rgw_cls_usage_log_read_op call;
601 call.start_epoch = start_epoch;
602 call.end_epoch = end_epoch;
604 call.max_entries = max_entries;
605 call.iter = read_iter;
607 int r = io_ctx.exec(oid, RGW_CLASS, RGW_USER_USAGE_LOG_READ, in, out);
612 rgw_cls_usage_log_read_ret result;
613 bufferlist::iterator iter = out.begin();
614 ::decode(result, iter);
615 read_iter = result.next_iter;
617 *is_truncated = result.truncated;
619 usage = result.usage;
620 } catch (buffer::error& e) {
627 void cls_rgw_usage_log_trim(ObjectWriteOperation& op, string& user,
628 uint64_t start_epoch, uint64_t end_epoch)
631 rgw_cls_usage_log_trim_op call;
632 call.start_epoch = start_epoch;
633 call.end_epoch = end_epoch;
636 op.exec(RGW_CLASS, RGW_USER_USAGE_LOG_TRIM, in);
639 void cls_rgw_usage_log_add(ObjectWriteOperation& op, rgw_usage_log_info& info)
642 rgw_cls_usage_log_add_op call;
645 op.exec(RGW_CLASS, RGW_USER_USAGE_LOG_ADD, in);
648 /* garbage collection */
650 void cls_rgw_gc_set_entry(ObjectWriteOperation& op, uint32_t expiration_secs, cls_rgw_gc_obj_info& info)
653 cls_rgw_gc_set_entry_op call;
654 call.expiration_secs = expiration_secs;
657 op.exec(RGW_CLASS, RGW_GC_SET_ENTRY, in);
660 void cls_rgw_gc_defer_entry(ObjectWriteOperation& op, uint32_t expiration_secs, const string& tag)
663 cls_rgw_gc_defer_entry_op call;
664 call.expiration_secs = expiration_secs;
667 op.exec(RGW_CLASS, RGW_GC_DEFER_ENTRY, in);
670 int cls_rgw_gc_list(IoCtx& io_ctx, string& oid, string& marker, uint32_t max, bool expired_only,
671 list<cls_rgw_gc_obj_info>& entries, bool *truncated, string& next_marker)
674 cls_rgw_gc_list_op call;
675 call.marker = marker;
677 call.expired_only = expired_only;
679 int r = io_ctx.exec(oid, RGW_CLASS, RGW_GC_LIST, in, out);
683 cls_rgw_gc_list_ret ret;
685 bufferlist::iterator iter = out.begin();
687 } catch (buffer::error& err) {
691 entries.swap(ret.entries);
694 *truncated = ret.truncated;
695 next_marker = std::move(ret.next_marker);
699 void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const list<string>& tags)
702 cls_rgw_gc_remove_op call;
705 op.exec(RGW_CLASS, RGW_GC_REMOVE, in);
708 int cls_rgw_lc_get_head(IoCtx& io_ctx, string& oid, cls_rgw_lc_obj_head& head)
711 int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_GET_HEAD, in, out);
715 cls_rgw_lc_get_head_ret ret;
717 bufferlist::iterator iter = out.begin();
719 } catch (buffer::error& err) {
727 int cls_rgw_lc_put_head(IoCtx& io_ctx, string& oid, cls_rgw_lc_obj_head& head)
730 cls_rgw_lc_put_head_op call;
733 int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_PUT_HEAD, in, out);
737 int cls_rgw_lc_get_next_entry(IoCtx& io_ctx, string& oid, string& marker, pair<string, int>& entry)
740 cls_rgw_lc_get_next_entry_op call;
741 call.marker = marker;
743 int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_GET_NEXT_ENTRY, in, out);
747 cls_rgw_lc_get_next_entry_ret ret;
749 bufferlist::iterator iter = out.begin();
751 } catch (buffer::error& err) {
759 int cls_rgw_lc_rm_entry(IoCtx& io_ctx, string& oid, pair<string, int>& entry)
762 cls_rgw_lc_rm_entry_op call;
765 int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_RM_ENTRY, in, out);
769 int cls_rgw_lc_set_entry(IoCtx& io_ctx, string& oid, pair<string, int>& entry)
772 cls_rgw_lc_set_entry_op call;
775 int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_SET_ENTRY, in, out);
779 int cls_rgw_lc_list(IoCtx& io_ctx, string& oid,
780 const string& marker,
781 uint32_t max_entries,
782 map<string, int>& entries)
785 cls_rgw_lc_list_entries_op op;
790 op.max_entries = max_entries;
794 int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_LIST_ENTRIES, in, out);
798 cls_rgw_lc_list_entries_ret ret;
800 bufferlist::iterator iter = out.begin();
802 } catch (buffer::error& err) {
805 entries.insert(ret.entries.begin(),ret.entries.end());
810 void cls_rgw_reshard_add(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry)
813 struct cls_rgw_reshard_add_op call;
816 op.exec("rgw", "reshard_add", in);
819 int cls_rgw_reshard_list(librados::IoCtx& io_ctx, const string& oid, string& marker, uint32_t max,
820 list<cls_rgw_reshard_entry>& entries, bool* is_truncated)
823 struct cls_rgw_reshard_list_op call;
824 call.marker = marker;
827 int r = io_ctx.exec(oid, "rgw", "reshard_list", in, out);
831 struct cls_rgw_reshard_list_ret op_ret;
832 bufferlist::iterator iter = out.begin();
834 ::decode(op_ret, iter);
835 } catch (buffer::error& err) {
839 entries.swap(op_ret.entries);
840 *is_truncated = op_ret.is_truncated;
845 int cls_rgw_reshard_get(librados::IoCtx& io_ctx, const string& oid, cls_rgw_reshard_entry& entry)
848 struct cls_rgw_reshard_get_op call;
851 int r = io_ctx.exec(oid, "rgw", "reshard_get", in, out);
855 struct cls_rgw_reshard_get_ret op_ret;
856 bufferlist::iterator iter = out.begin();
858 ::decode(op_ret, iter);
859 } catch (buffer::error& err) {
863 entry = op_ret.entry;
868 void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry)
871 struct cls_rgw_reshard_remove_op call;
872 call.tenant = entry.tenant;
873 call.bucket_name = entry.bucket_name;
874 call.bucket_id = entry.bucket_id;
876 op.exec("rgw", "reshard_remove", in);
879 int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
880 const cls_rgw_bucket_instance_entry& entry)
883 struct cls_rgw_set_bucket_resharding_op call;
886 return io_ctx.exec(oid, "rgw", "set_bucket_resharding", in, out);
889 int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid)
892 struct cls_rgw_clear_bucket_resharding_op call;
894 return io_ctx.exec(oid, "rgw", "clear_bucket_resharding", in, out);
897 int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
898 cls_rgw_bucket_instance_entry *entry)
901 struct cls_rgw_get_bucket_resharding_op call;
903 int r= io_ctx.exec(oid, "rgw", "get_bucket_resharding", in, out);
907 struct cls_rgw_get_bucket_resharding_ret op_ret;
908 bufferlist::iterator iter = out.begin();
910 ::decode(op_ret, iter);
911 } catch (buffer::error& err) {
915 *entry = op_ret.new_instance;
920 void cls_rgw_guard_bucket_resharding(librados::ObjectOperation& op, int ret_err)
923 struct cls_rgw_guard_bucket_resharding_op call;
924 call.ret_err = ret_err;
926 op.exec("rgw", "guard_bucket_resharding", in);
929 static bool issue_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
930 const cls_rgw_bucket_instance_entry& entry,
931 BucketIndexAioManager *manager) {
933 struct cls_rgw_set_bucket_resharding_op call;
936 librados::ObjectWriteOperation op;
937 op.exec("rgw", "set_bucket_resharding", in);
938 return manager->aio_operate(io_ctx, oid, &op);
941 int CLSRGWIssueSetBucketResharding::issue_op(int shard_id, const string& oid)
943 return issue_set_bucket_resharding(io_ctx, oid, entry, &manager);