1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
6 #include "cls/rgw/cls_rgw_const.h"
7 #include "cls/rgw/cls_rgw_client.h"
9 #include "common/debug.h"
11 using namespace librados
;
13 const string
BucketIndexShardsManager::KEY_VALUE_SEPARATOR
= "#";
14 const string
BucketIndexShardsManager::SHARDS_SEPARATOR
= ",";
17 * This class represents the bucket index object operation callback context.
20 class ClsBucketIndexOpCtx
: public ObjectOperationCompletion
{
25 ClsBucketIndexOpCtx(T
* _data
, int *_ret_code
) : data(_data
), ret_code(_ret_code
) { ceph_assert(data
); }
26 ~ClsBucketIndexOpCtx() override
{}
27 void handle_completion(int r
, bufferlist
& outbl
) override
{
30 auto iter
= outbl
.cbegin();
31 decode((*data
), iter
);
32 } catch (buffer::error
& err
) {
42 void BucketIndexAioManager::do_completion(int id
) {
43 Mutex::Locker
l(lock
);
45 map
<int, librados::AioCompletion
*>::iterator iter
= pendings
.find(id
);
46 ceph_assert(iter
!= pendings
.end());
47 completions
[id
] = iter
->second
;
50 // If the caller needs a list of finished objects, store them
51 // for further processing
52 map
<int, string
>::iterator miter
= pending_objs
.find(id
);
53 if (miter
!= pending_objs
.end()) {
54 completion_objs
[id
] = miter
->second
;
55 pending_objs
.erase(miter
);
61 bool BucketIndexAioManager::wait_for_completions(int valid_ret_code
,
62 int *num_completions
, int *ret_code
, map
<int, string
> *objs
) {
64 if (pendings
.empty() && completions
.empty()) {
69 if (completions
.empty()) {
70 // Wait for AIO completion
74 // Clear the completed AIOs
75 map
<int, librados::AioCompletion
*>::iterator iter
= completions
.begin();
76 for (; iter
!= completions
.end(); ++iter
) {
77 int r
= iter
->second
->get_return_value();
78 if (objs
&& r
== 0) { /* update list of successfully completed objs */
79 map
<int, string
>::iterator liter
= completion_objs
.find(iter
->first
);
80 if (liter
!= completion_objs
.end()) {
81 (*objs
)[liter
->first
] = liter
->second
;
84 if (ret_code
&& (r
< 0 && r
!= valid_ret_code
))
86 iter
->second
->release();
89 (*num_completions
) = completions
.size();
96 // note: currently only called by tesing code
97 void cls_rgw_bucket_init_index(ObjectWriteOperation
& o
)
100 o
.exec(RGW_CLASS
, RGW_BUCKET_INIT_INDEX
, in
);
103 static bool issue_bucket_index_init_op(librados::IoCtx
& io_ctx
,
105 BucketIndexAioManager
*manager
) {
107 librados::ObjectWriteOperation op
;
109 op
.exec(RGW_CLASS
, RGW_BUCKET_INIT_INDEX
, in
);
110 return manager
->aio_operate(io_ctx
, oid
, &op
);
113 static bool issue_bucket_index_clean_op(librados::IoCtx
& io_ctx
,
115 BucketIndexAioManager
*manager
) {
117 librados::ObjectWriteOperation op
;
119 return manager
->aio_operate(io_ctx
, oid
, &op
);
122 static bool issue_bucket_set_tag_timeout_op(librados::IoCtx
& io_ctx
,
123 const string
& oid
, uint64_t timeout
, BucketIndexAioManager
*manager
) {
125 rgw_cls_tag_timeout_op call
;
126 call
.tag_timeout
= timeout
;
128 ObjectWriteOperation op
;
129 op
.exec(RGW_CLASS
, RGW_BUCKET_SET_TAG_TIMEOUT
, in
);
130 return manager
->aio_operate(io_ctx
, oid
, &op
);
133 int CLSRGWIssueBucketIndexInit::issue_op(int shard_id
, const string
& oid
)
135 return issue_bucket_index_init_op(io_ctx
, oid
, &manager
);
138 void CLSRGWIssueBucketIndexInit::cleanup()
140 // Do best effort removal
141 for (auto citer
= objs_container
.begin(); citer
!= iter
; ++citer
) {
142 io_ctx
.remove(citer
->second
);
146 int CLSRGWIssueBucketIndexClean::issue_op(int shard_id
, const string
& oid
)
148 return issue_bucket_index_clean_op(io_ctx
, oid
, &manager
);
151 int CLSRGWIssueSetTagTimeout::issue_op(int shard_id
, const string
& oid
)
153 return issue_bucket_set_tag_timeout_op(io_ctx
, oid
, tag_timeout
, &manager
);
156 void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation
& o
,
158 const map
<RGWObjCategory
, rgw_bucket_category_stats
>& stats
)
160 rgw_cls_bucket_update_stats_op call
;
161 call
.absolute
= absolute
;
165 o
.exec(RGW_CLASS
, RGW_BUCKET_UPDATE_STATS
, in
);
168 void cls_rgw_bucket_prepare_op(ObjectWriteOperation
& o
, RGWModifyOp op
, string
& tag
,
169 const cls_rgw_obj_key
& key
, const string
& locator
, bool log_op
,
170 uint16_t bilog_flags
, rgw_zone_set
& zones_trace
)
172 rgw_cls_obj_prepare_op call
;
176 call
.locator
= locator
;
177 call
.log_op
= log_op
;
178 call
.bilog_flags
= bilog_flags
;
179 call
.zones_trace
= zones_trace
;
182 o
.exec(RGW_CLASS
, RGW_BUCKET_PREPARE_OP
, in
);
185 void cls_rgw_bucket_complete_op(ObjectWriteOperation
& o
, RGWModifyOp op
, string
& tag
,
186 rgw_bucket_entry_ver
& ver
,
187 const cls_rgw_obj_key
& key
,
188 rgw_bucket_dir_entry_meta
& dir_meta
,
189 list
<cls_rgw_obj_key
> *remove_objs
, bool log_op
,
190 uint16_t bilog_flags
,
191 rgw_zone_set
*zones_trace
)
195 rgw_cls_obj_complete_op call
;
200 call
.meta
= dir_meta
;
201 call
.log_op
= log_op
;
202 call
.bilog_flags
= bilog_flags
;
204 call
.remove_objs
= *remove_objs
;
206 call
.zones_trace
= *zones_trace
;
209 o
.exec(RGW_CLASS
, RGW_BUCKET_COMPLETE_OP
, in
);
212 static bool issue_bucket_list_op(librados::IoCtx
& io_ctx
, const string
& oid
,
213 const cls_rgw_obj_key
& start_obj
,
214 const string
& filter_prefix
,
215 uint32_t num_entries
, bool list_versions
,
216 BucketIndexAioManager
*manager
,
217 rgw_cls_list_ret
*pdata
) {
219 rgw_cls_list_op call
;
220 call
.start_obj
= start_obj
;
221 call
.filter_prefix
= filter_prefix
;
222 call
.num_entries
= num_entries
;
223 call
.list_versions
= list_versions
;
226 librados::ObjectReadOperation op
;
227 op
.exec(RGW_CLASS
, RGW_BUCKET_LIST
, in
, new ClsBucketIndexOpCtx
<rgw_cls_list_ret
>(pdata
, NULL
));
228 return manager
->aio_operate(io_ctx
, oid
, &op
);
231 int CLSRGWIssueBucketList::issue_op(int shard_id
, const string
& oid
)
233 return issue_bucket_list_op(io_ctx
, oid
, start_obj
, filter_prefix
, num_entries
, list_versions
, &manager
, &result
[shard_id
]);
236 void cls_rgw_remove_obj(librados::ObjectWriteOperation
& o
, list
<string
>& keep_attr_prefixes
)
239 rgw_cls_obj_remove_op call
;
240 call
.keep_attr_prefixes
= keep_attr_prefixes
;
242 o
.exec(RGW_CLASS
, RGW_OBJ_REMOVE
, in
);
245 void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation
& o
, const string
& attr
)
248 rgw_cls_obj_store_pg_ver_op call
;
251 o
.exec(RGW_CLASS
, RGW_OBJ_STORE_PG_VER
, in
);
254 void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation
& o
, const string
& prefix
, bool fail_if_exist
)
257 rgw_cls_obj_check_attrs_prefix call
;
258 call
.check_prefix
= prefix
;
259 call
.fail_if_exist
= fail_if_exist
;
261 o
.exec(RGW_CLASS
, RGW_OBJ_CHECK_ATTRS_PREFIX
, in
);
264 void cls_rgw_obj_check_mtime(librados::ObjectOperation
& o
, const real_time
& mtime
, bool high_precision_time
, RGWCheckMTimeType type
)
267 rgw_cls_obj_check_mtime call
;
269 call
.high_precision_time
= high_precision_time
;
272 o
.exec(RGW_CLASS
, RGW_OBJ_CHECK_MTIME
, in
);
275 int cls_rgw_bi_get(librados::IoCtx
& io_ctx
, const string oid
,
276 BIIndexType index_type
, cls_rgw_obj_key
& key
,
277 rgw_cls_bi_entry
*entry
)
280 rgw_cls_bi_get_op call
;
282 call
.type
= index_type
;
284 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_BI_GET
, in
, out
);
288 rgw_cls_bi_get_ret op_ret
;
289 auto iter
= out
.cbegin();
291 decode(op_ret
, iter
);
292 } catch (buffer::error
& err
) {
296 *entry
= op_ret
.entry
;
301 int cls_rgw_bi_put(librados::IoCtx
& io_ctx
, const string oid
, rgw_cls_bi_entry
& entry
)
304 rgw_cls_bi_put_op call
;
307 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_BI_PUT
, in
, out
);
314 void cls_rgw_bi_put(ObjectWriteOperation
& op
, const string oid
, rgw_cls_bi_entry
& entry
)
317 rgw_cls_bi_put_op call
;
320 op
.exec(RGW_CLASS
, RGW_BI_PUT
, in
);
323 int cls_rgw_bi_list(librados::IoCtx
& io_ctx
, const string oid
,
324 const string
& name
, const string
& marker
, uint32_t max
,
325 list
<rgw_cls_bi_entry
> *entries
, bool *is_truncated
)
328 rgw_cls_bi_list_op call
;
330 call
.marker
= marker
;
333 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_BI_LIST
, in
, out
);
337 rgw_cls_bi_list_ret op_ret
;
338 auto iter
= out
.cbegin();
340 decode(op_ret
, iter
);
341 } catch (buffer::error
& err
) {
345 entries
->swap(op_ret
.entries
);
346 *is_truncated
= op_ret
.is_truncated
;
351 int cls_rgw_bucket_link_olh(librados::IoCtx
& io_ctx
, librados::ObjectWriteOperation
& op
,
352 const string
& oid
, const cls_rgw_obj_key
& key
, bufferlist
& olh_tag
,
353 bool delete_marker
, const string
& op_tag
, rgw_bucket_dir_entry_meta
*meta
,
354 uint64_t olh_epoch
, ceph::real_time unmod_since
, bool high_precision_time
, bool log_op
, rgw_zone_set
& zones_trace
)
357 rgw_cls_link_olh_op call
;
359 call
.olh_tag
= string(olh_tag
.c_str(), olh_tag
.length());
360 call
.op_tag
= op_tag
;
361 call
.delete_marker
= delete_marker
;
365 call
.olh_epoch
= olh_epoch
;
366 call
.log_op
= log_op
;
367 call
.unmod_since
= unmod_since
;
368 call
.high_precision_time
= high_precision_time
;
369 call
.zones_trace
= zones_trace
;
371 op
.exec(RGW_CLASS
, RGW_BUCKET_LINK_OLH
, in
);
372 int r
= io_ctx
.operate(oid
, &op
);
379 int cls_rgw_bucket_unlink_instance(librados::IoCtx
& io_ctx
, librados::ObjectWriteOperation
& op
,
381 const cls_rgw_obj_key
& key
, const string
& op_tag
,
382 const string
& olh_tag
, uint64_t olh_epoch
, bool log_op
, rgw_zone_set
& zones_trace
)
385 rgw_cls_unlink_instance_op call
;
387 call
.op_tag
= op_tag
;
388 call
.olh_epoch
= olh_epoch
;
389 call
.olh_tag
= olh_tag
;
390 call
.log_op
= log_op
;
391 call
.zones_trace
= zones_trace
;
393 op
.exec(RGW_CLASS
, RGW_BUCKET_UNLINK_INSTANCE
, in
);
394 int r
= io_ctx
.operate(oid
, &op
);
401 int cls_rgw_get_olh_log(IoCtx
& io_ctx
, string
& oid
, librados::ObjectReadOperation
& op
, const cls_rgw_obj_key
& olh
, uint64_t ver_marker
,
402 const string
& olh_tag
,
403 map
<uint64_t, vector
<rgw_bucket_olh_log_entry
> > *log
, bool *is_truncated
)
406 rgw_cls_read_olh_log_op call
;
408 call
.ver_marker
= ver_marker
;
409 call
.olh_tag
= olh_tag
;
412 op
.exec(RGW_CLASS
, RGW_BUCKET_READ_OLH_LOG
, in
, &out
, &op_ret
);
413 int r
= io_ctx
.operate(oid
, &op
, NULL
);
421 rgw_cls_read_olh_log_ret ret
;
423 auto iter
= out
.cbegin();
425 } catch (buffer::error
& err
) {
433 *is_truncated
= ret
.is_truncated
;
439 void cls_rgw_trim_olh_log(librados::ObjectWriteOperation
& op
, const cls_rgw_obj_key
& olh
, uint64_t ver
, const string
& olh_tag
)
442 rgw_cls_trim_olh_log_op call
;
445 call
.olh_tag
= olh_tag
;
447 op
.exec(RGW_CLASS
, RGW_BUCKET_TRIM_OLH_LOG
, in
);
450 int cls_rgw_clear_olh(IoCtx
& io_ctx
, librados::ObjectWriteOperation
& op
, string
& oid
, const cls_rgw_obj_key
& olh
, const string
& olh_tag
)
453 rgw_cls_bucket_clear_olh_op call
;
455 call
.olh_tag
= olh_tag
;
458 op
.exec(RGW_CLASS
, RGW_BUCKET_CLEAR_OLH
, in
, &out
, &op_ret
);
459 int r
= io_ctx
.operate(oid
, &op
);
466 static bool issue_bi_log_list_op(librados::IoCtx
& io_ctx
, const string
& oid
, int shard_id
,
467 BucketIndexShardsManager
& marker_mgr
, uint32_t max
, BucketIndexAioManager
*manager
,
468 cls_rgw_bi_log_list_ret
*pdata
) {
470 cls_rgw_bi_log_list_op call
;
471 call
.marker
= marker_mgr
.get(shard_id
, "");
475 librados::ObjectReadOperation op
;
476 op
.exec(RGW_CLASS
, RGW_BI_LOG_LIST
, in
, new ClsBucketIndexOpCtx
<cls_rgw_bi_log_list_ret
>(pdata
, NULL
));
477 return manager
->aio_operate(io_ctx
, oid
, &op
);
480 int CLSRGWIssueBILogList::issue_op(int shard_id
, const string
& oid
)
482 return issue_bi_log_list_op(io_ctx
, oid
, shard_id
, marker_mgr
, max
, &manager
, &result
[shard_id
]);
485 static bool issue_bi_log_trim(librados::IoCtx
& io_ctx
, const string
& oid
, int shard_id
,
486 BucketIndexShardsManager
& start_marker_mgr
,
487 BucketIndexShardsManager
& end_marker_mgr
, BucketIndexAioManager
*manager
) {
489 cls_rgw_bi_log_trim_op call
;
490 call
.start_marker
= start_marker_mgr
.get(shard_id
, "");
491 call
.end_marker
= end_marker_mgr
.get(shard_id
, "");
493 ObjectWriteOperation op
;
494 op
.exec(RGW_CLASS
, RGW_BI_LOG_TRIM
, in
);
495 return manager
->aio_operate(io_ctx
, oid
, &op
);
498 int CLSRGWIssueBILogTrim::issue_op(int shard_id
, const string
& oid
)
500 return issue_bi_log_trim(io_ctx
, oid
, shard_id
, start_marker_mgr
, end_marker_mgr
, &manager
);
503 static bool issue_bucket_check_index_op(IoCtx
& io_ctx
, const string
& oid
, BucketIndexAioManager
*manager
,
504 rgw_cls_check_index_ret
*pdata
) {
506 librados::ObjectReadOperation op
;
507 op
.exec(RGW_CLASS
, RGW_BUCKET_CHECK_INDEX
, in
, new ClsBucketIndexOpCtx
<rgw_cls_check_index_ret
>(
509 return manager
->aio_operate(io_ctx
, oid
, &op
);
512 int CLSRGWIssueBucketCheck::issue_op(int shard_id
, const string
& oid
)
514 return issue_bucket_check_index_op(io_ctx
, oid
, &manager
, &result
[shard_id
]);
517 static bool issue_bucket_rebuild_index_op(IoCtx
& io_ctx
, const string
& oid
,
518 BucketIndexAioManager
*manager
) {
520 librados::ObjectWriteOperation op
;
521 op
.exec(RGW_CLASS
, RGW_BUCKET_REBUILD_INDEX
, in
);
522 return manager
->aio_operate(io_ctx
, oid
, &op
);
525 int CLSRGWIssueBucketRebuild::issue_op(int shard_id
, const string
& oid
)
527 return issue_bucket_rebuild_index_op(io_ctx
, oid
, &manager
);
530 void cls_rgw_encode_suggestion(char op
, rgw_bucket_dir_entry
& dirent
, bufferlist
& updates
)
533 encode(dirent
, updates
);
536 void cls_rgw_suggest_changes(ObjectWriteOperation
& o
, bufferlist
& updates
)
538 o
.exec(RGW_CLASS
, RGW_DIR_SUGGEST_CHANGES
, updates
);
541 int CLSRGWIssueGetDirHeader::issue_op(int shard_id
, const string
& oid
)
543 cls_rgw_obj_key nokey
;
544 return issue_bucket_list_op(io_ctx
, oid
, nokey
, "", 0, false, &manager
, &result
[shard_id
]);
547 static bool issue_resync_bi_log(librados::IoCtx
& io_ctx
, const string
& oid
, BucketIndexAioManager
*manager
)
550 librados::ObjectWriteOperation op
;
551 op
.exec("rgw", "bi_log_resync", in
);
552 return manager
->aio_operate(io_ctx
, oid
, &op
);
555 int CLSRGWIssueResyncBucketBILog::issue_op(int shard_id
, const string
& oid
)
557 return issue_resync_bi_log(io_ctx
, oid
, &manager
);
560 static bool issue_bi_log_stop(librados::IoCtx
& io_ctx
, const string
& oid
, BucketIndexAioManager
*manager
)
563 librados::ObjectWriteOperation op
;
564 op
.exec("rgw", "bi_log_stop", in
);
565 return manager
->aio_operate(io_ctx
, oid
, &op
);
568 int CLSRGWIssueBucketBILogStop::issue_op(int shard_id
, const string
& oid
)
570 return issue_bi_log_stop(io_ctx
, oid
, &manager
);
573 class GetDirHeaderCompletion
: public ObjectOperationCompletion
{
574 RGWGetDirHeader_CB
*ret_ctx
;
576 explicit GetDirHeaderCompletion(RGWGetDirHeader_CB
*_ctx
) : ret_ctx(_ctx
) {}
577 ~GetDirHeaderCompletion() override
{
580 void handle_completion(int r
, bufferlist
& outbl
) override
{
581 rgw_cls_list_ret ret
;
583 auto iter
= outbl
.cbegin();
585 } catch (buffer::error
& err
) {
589 ret_ctx
->handle_response(r
, ret
.dir
.header
);
593 int cls_rgw_get_dir_header_async(IoCtx
& io_ctx
, string
& oid
, RGWGetDirHeader_CB
*ctx
)
596 rgw_cls_list_op call
;
597 call
.num_entries
= 0;
599 ObjectReadOperation op
;
600 GetDirHeaderCompletion
*cb
= new GetDirHeaderCompletion(ctx
);
601 op
.exec(RGW_CLASS
, RGW_BUCKET_LIST
, in
, cb
);
602 AioCompletion
*c
= librados::Rados::aio_create_completion(NULL
, NULL
, NULL
);
603 int r
= io_ctx
.aio_operate(oid
, c
, &op
, NULL
);
611 int cls_rgw_usage_log_read(IoCtx
& io_ctx
, const string
& oid
, const string
& user
, const string
& bucket
,
612 uint64_t start_epoch
, uint64_t end_epoch
, uint32_t max_entries
,
613 string
& read_iter
, map
<rgw_user_bucket
, rgw_usage_log_entry
>& usage
,
617 *is_truncated
= false;
620 rgw_cls_usage_log_read_op call
;
621 call
.start_epoch
= start_epoch
;
622 call
.end_epoch
= end_epoch
;
624 call
.max_entries
= max_entries
;
625 call
.bucket
= bucket
;
626 call
.iter
= read_iter
;
628 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_USER_USAGE_LOG_READ
, in
, out
);
633 rgw_cls_usage_log_read_ret result
;
634 auto iter
= out
.cbegin();
635 decode(result
, iter
);
636 read_iter
= result
.next_iter
;
638 *is_truncated
= result
.truncated
;
640 usage
= result
.usage
;
641 } catch (buffer::error
& e
) {
648 int cls_rgw_usage_log_trim(IoCtx
& io_ctx
, const string
& oid
, const string
& user
, const string
& bucket
,
649 uint64_t start_epoch
, uint64_t end_epoch
)
652 rgw_cls_usage_log_trim_op call
;
653 call
.start_epoch
= start_epoch
;
654 call
.end_epoch
= end_epoch
;
656 call
.bucket
= bucket
;
661 ObjectWriteOperation op
;
662 op
.exec(RGW_CLASS
, RGW_USER_USAGE_LOG_TRIM
, in
);
663 int r
= io_ctx
.operate(oid
, &op
);
673 void cls_rgw_usage_log_clear(ObjectWriteOperation
& op
)
676 op
.exec(RGW_CLASS
, RGW_USAGE_LOG_CLEAR
, in
);
679 void cls_rgw_usage_log_add(ObjectWriteOperation
& op
, rgw_usage_log_info
& info
)
682 rgw_cls_usage_log_add_op call
;
685 op
.exec(RGW_CLASS
, RGW_USER_USAGE_LOG_ADD
, in
);
688 /* garbage collection */
690 void cls_rgw_gc_set_entry(ObjectWriteOperation
& op
, uint32_t expiration_secs
, cls_rgw_gc_obj_info
& info
)
693 cls_rgw_gc_set_entry_op call
;
694 call
.expiration_secs
= expiration_secs
;
697 op
.exec(RGW_CLASS
, RGW_GC_SET_ENTRY
, in
);
700 void cls_rgw_gc_defer_entry(ObjectWriteOperation
& op
, uint32_t expiration_secs
, const string
& tag
)
703 cls_rgw_gc_defer_entry_op call
;
704 call
.expiration_secs
= expiration_secs
;
707 op
.exec(RGW_CLASS
, RGW_GC_DEFER_ENTRY
, in
);
710 int cls_rgw_gc_list(IoCtx
& io_ctx
, string
& oid
, string
& marker
, uint32_t max
, bool expired_only
,
711 list
<cls_rgw_gc_obj_info
>& entries
, bool *truncated
, string
& next_marker
)
714 cls_rgw_gc_list_op call
;
715 call
.marker
= marker
;
717 call
.expired_only
= expired_only
;
719 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_GC_LIST
, in
, out
);
723 cls_rgw_gc_list_ret ret
;
725 auto iter
= out
.cbegin();
727 } catch (buffer::error
& err
) {
731 entries
.swap(ret
.entries
);
734 *truncated
= ret
.truncated
;
735 next_marker
= std::move(ret
.next_marker
);
739 void cls_rgw_gc_remove(librados::ObjectWriteOperation
& op
, const vector
<string
>& tags
)
742 cls_rgw_gc_remove_op call
;
745 op
.exec(RGW_CLASS
, RGW_GC_REMOVE
, in
);
748 int cls_rgw_lc_get_head(IoCtx
& io_ctx
, const string
& oid
, cls_rgw_lc_obj_head
& head
)
751 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_GET_HEAD
, in
, out
);
755 cls_rgw_lc_get_head_ret ret
;
757 auto iter
= out
.cbegin();
759 } catch (buffer::error
& err
) {
767 int cls_rgw_lc_put_head(IoCtx
& io_ctx
, const string
& oid
, cls_rgw_lc_obj_head
& head
)
770 cls_rgw_lc_put_head_op call
;
773 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_PUT_HEAD
, in
, out
);
777 int cls_rgw_lc_get_next_entry(IoCtx
& io_ctx
, const string
& oid
, string
& marker
, pair
<string
, int>& entry
)
780 cls_rgw_lc_get_next_entry_op call
;
781 call
.marker
= marker
;
783 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_GET_NEXT_ENTRY
, in
, out
);
787 cls_rgw_lc_get_next_entry_ret ret
;
789 auto iter
= out
.cbegin();
791 } catch (buffer::error
& err
) {
799 int cls_rgw_lc_rm_entry(IoCtx
& io_ctx
, const string
& oid
, const pair
<string
, int>& entry
)
802 cls_rgw_lc_rm_entry_op call
;
805 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_RM_ENTRY
, in
, out
);
809 int cls_rgw_lc_set_entry(IoCtx
& io_ctx
, const string
& oid
, const pair
<string
, int>& entry
)
812 cls_rgw_lc_set_entry_op call
;
815 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_SET_ENTRY
, in
, out
);
819 int cls_rgw_lc_get_entry(IoCtx
& io_ctx
, const string
& oid
, const std::string
& marker
, rgw_lc_entry_t
& entry
)
822 cls_rgw_lc_get_entry_op call
{marker
};;
824 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_GET_ENTRY
, in
, out
);
830 cls_rgw_lc_get_entry_ret ret
;
832 auto iter
= out
.cbegin();
834 } catch (buffer::error
& err
) {
838 entry
= std::move(ret
.entry
);
842 int cls_rgw_lc_list(IoCtx
& io_ctx
, const string
& oid
,
843 const string
& marker
,
844 uint32_t max_entries
,
845 map
<string
, int>& entries
)
848 cls_rgw_lc_list_entries_op op
;
853 op
.max_entries
= max_entries
;
857 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_LIST_ENTRIES
, in
, out
);
861 cls_rgw_lc_list_entries_ret ret
;
863 auto iter
= out
.cbegin();
865 } catch (buffer::error
& err
) {
868 entries
.insert(ret
.entries
.begin(),ret
.entries
.end());
873 void cls_rgw_reshard_add(librados::ObjectWriteOperation
& op
, const cls_rgw_reshard_entry
& entry
)
876 cls_rgw_reshard_add_op call
;
879 op
.exec("rgw", "reshard_add", in
);
882 int cls_rgw_reshard_list(librados::IoCtx
& io_ctx
, const string
& oid
, string
& marker
, uint32_t max
,
883 list
<cls_rgw_reshard_entry
>& entries
, bool* is_truncated
)
886 cls_rgw_reshard_list_op call
;
887 call
.marker
= marker
;
890 int r
= io_ctx
.exec(oid
, "rgw", "reshard_list", in
, out
);
894 cls_rgw_reshard_list_ret op_ret
;
895 auto iter
= out
.cbegin();
897 decode(op_ret
, iter
);
898 } catch (buffer::error
& err
) {
902 entries
.swap(op_ret
.entries
);
903 *is_truncated
= op_ret
.is_truncated
;
908 int cls_rgw_reshard_get(librados::IoCtx
& io_ctx
, const string
& oid
, cls_rgw_reshard_entry
& entry
)
911 cls_rgw_reshard_get_op call
;
914 int r
= io_ctx
.exec(oid
, "rgw", "reshard_get", in
, out
);
918 cls_rgw_reshard_get_ret op_ret
;
919 auto iter
= out
.cbegin();
921 decode(op_ret
, iter
);
922 } catch (buffer::error
& err
) {
926 entry
= op_ret
.entry
;
931 void cls_rgw_reshard_remove(librados::ObjectWriteOperation
& op
, const cls_rgw_reshard_entry
& entry
)
934 cls_rgw_reshard_remove_op call
;
935 call
.tenant
= entry
.tenant
;
936 call
.bucket_name
= entry
.bucket_name
;
937 call
.bucket_id
= entry
.bucket_id
;
939 op
.exec("rgw", "reshard_remove", in
);
942 int cls_rgw_set_bucket_resharding(librados::IoCtx
& io_ctx
, const string
& oid
,
943 const cls_rgw_bucket_instance_entry
& entry
)
946 cls_rgw_set_bucket_resharding_op call
;
949 return io_ctx
.exec(oid
, "rgw", "set_bucket_resharding", in
, out
);
952 int cls_rgw_clear_bucket_resharding(librados::IoCtx
& io_ctx
, const string
& oid
)
955 cls_rgw_clear_bucket_resharding_op call
;
957 return io_ctx
.exec(oid
, "rgw", "clear_bucket_resharding", in
, out
);
960 int cls_rgw_get_bucket_resharding(librados::IoCtx
& io_ctx
, const string
& oid
,
961 cls_rgw_bucket_instance_entry
*entry
)
964 cls_rgw_get_bucket_resharding_op call
;
966 int r
= io_ctx
.exec(oid
, "rgw", "get_bucket_resharding", in
, out
);
970 cls_rgw_get_bucket_resharding_ret op_ret
;
971 auto iter
= out
.cbegin();
973 decode(op_ret
, iter
);
974 } catch (buffer::error
& err
) {
978 *entry
= op_ret
.new_instance
;
983 void cls_rgw_guard_bucket_resharding(librados::ObjectOperation
& op
, int ret_err
)
986 cls_rgw_guard_bucket_resharding_op call
;
987 call
.ret_err
= ret_err
;
989 op
.exec("rgw", "guard_bucket_resharding", in
);
992 static bool issue_set_bucket_resharding(librados::IoCtx
& io_ctx
, const string
& oid
,
993 const cls_rgw_bucket_instance_entry
& entry
,
994 BucketIndexAioManager
*manager
) {
996 cls_rgw_set_bucket_resharding_op call
;
999 librados::ObjectWriteOperation op
;
1000 op
.exec("rgw", "set_bucket_resharding", in
);
1001 return manager
->aio_operate(io_ctx
, oid
, &op
);
1004 int CLSRGWIssueSetBucketResharding::issue_op(int shard_id
, const string
& oid
)
1006 return issue_set_bucket_resharding(io_ctx
, oid
, entry
, &manager
);