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 // note: currently only called by tesing code
96 void cls_rgw_bucket_init_index(ObjectWriteOperation
& o
)
99 o
.exec(RGW_CLASS
, RGW_BUCKET_INIT_INDEX
, in
);
102 static bool issue_bucket_index_init_op(librados::IoCtx
& io_ctx
,
104 BucketIndexAioManager
*manager
) {
106 librados::ObjectWriteOperation op
;
108 op
.exec(RGW_CLASS
, RGW_BUCKET_INIT_INDEX
, in
);
109 return manager
->aio_operate(io_ctx
, oid
, &op
);
112 static bool issue_bucket_index_clean_op(librados::IoCtx
& io_ctx
,
114 BucketIndexAioManager
*manager
) {
116 librados::ObjectWriteOperation op
;
118 return manager
->aio_operate(io_ctx
, oid
, &op
);
121 static bool issue_bucket_set_tag_timeout_op(librados::IoCtx
& io_ctx
,
122 const string
& oid
, uint64_t timeout
, BucketIndexAioManager
*manager
) {
124 struct rgw_cls_tag_timeout_op call
;
125 call
.tag_timeout
= timeout
;
127 ObjectWriteOperation op
;
128 op
.exec(RGW_CLASS
, RGW_BUCKET_SET_TAG_TIMEOUT
, in
);
129 return manager
->aio_operate(io_ctx
, oid
, &op
);
132 int CLSRGWIssueBucketIndexInit::issue_op(int shard_id
, const string
& oid
)
134 return issue_bucket_index_init_op(io_ctx
, oid
, &manager
);
137 void CLSRGWIssueBucketIndexInit::cleanup()
139 // Do best effort removal
140 for (auto citer
= objs_container
.begin(); citer
!= iter
; ++citer
) {
141 io_ctx
.remove(citer
->second
);
145 int CLSRGWIssueBucketIndexClean::issue_op(int shard_id
, const string
& oid
)
147 return issue_bucket_index_clean_op(io_ctx
, oid
, &manager
);
150 int CLSRGWIssueSetTagTimeout::issue_op(int shard_id
, const string
& oid
)
152 return issue_bucket_set_tag_timeout_op(io_ctx
, oid
, tag_timeout
, &manager
);
155 void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation
& o
, bool absolute
,
156 const map
<uint8_t, rgw_bucket_category_stats
>& stats
)
158 struct rgw_cls_bucket_update_stats_op call
;
159 call
.absolute
= absolute
;
163 o
.exec(RGW_CLASS
, RGW_BUCKET_UPDATE_STATS
, in
);
166 void cls_rgw_bucket_prepare_op(ObjectWriteOperation
& o
, RGWModifyOp op
, string
& tag
,
167 const cls_rgw_obj_key
& key
, const string
& locator
, bool log_op
,
168 uint16_t bilog_flags
, rgw_zone_set
& zones_trace
)
170 struct rgw_cls_obj_prepare_op call
;
174 call
.locator
= locator
;
175 call
.log_op
= log_op
;
176 call
.bilog_flags
= bilog_flags
;
177 call
.zones_trace
= zones_trace
;
180 o
.exec(RGW_CLASS
, RGW_BUCKET_PREPARE_OP
, in
);
183 void cls_rgw_bucket_complete_op(ObjectWriteOperation
& o
, RGWModifyOp op
, string
& tag
,
184 rgw_bucket_entry_ver
& ver
,
185 const cls_rgw_obj_key
& key
,
186 rgw_bucket_dir_entry_meta
& dir_meta
,
187 list
<cls_rgw_obj_key
> *remove_objs
, bool log_op
,
188 uint16_t bilog_flags
,
189 rgw_zone_set
*zones_trace
)
193 struct rgw_cls_obj_complete_op call
;
198 call
.meta
= dir_meta
;
199 call
.log_op
= log_op
;
200 call
.bilog_flags
= bilog_flags
;
202 call
.remove_objs
= *remove_objs
;
204 call
.zones_trace
= *zones_trace
;
207 o
.exec(RGW_CLASS
, RGW_BUCKET_COMPLETE_OP
, in
);
210 static bool issue_bucket_list_op(librados::IoCtx
& io_ctx
,
211 const string
& oid
, const cls_rgw_obj_key
& start_obj
, const string
& filter_prefix
,
212 uint32_t num_entries
, bool list_versions
, BucketIndexAioManager
*manager
,
213 struct rgw_cls_list_ret
*pdata
) {
215 struct rgw_cls_list_op call
;
216 call
.start_obj
= start_obj
;
217 call
.filter_prefix
= filter_prefix
;
218 call
.num_entries
= num_entries
;
219 call
.list_versions
= list_versions
;
222 librados::ObjectReadOperation op
;
223 op
.exec(RGW_CLASS
, RGW_BUCKET_LIST
, in
, new ClsBucketIndexOpCtx
<struct rgw_cls_list_ret
>(pdata
, NULL
));
224 return manager
->aio_operate(io_ctx
, oid
, &op
);
227 int CLSRGWIssueBucketList::issue_op(int shard_id
, const string
& oid
)
229 return issue_bucket_list_op(io_ctx
, oid
, start_obj
, filter_prefix
, num_entries
, list_versions
, &manager
, &result
[shard_id
]);
232 void cls_rgw_remove_obj(librados::ObjectWriteOperation
& o
, list
<string
>& keep_attr_prefixes
)
235 struct rgw_cls_obj_remove_op call
;
236 call
.keep_attr_prefixes
= keep_attr_prefixes
;
238 o
.exec(RGW_CLASS
, RGW_OBJ_REMOVE
, in
);
241 void cls_rgw_obj_store_pg_ver(librados::ObjectWriteOperation
& o
, const string
& attr
)
244 struct rgw_cls_obj_store_pg_ver_op call
;
247 o
.exec(RGW_CLASS
, RGW_OBJ_STORE_PG_VER
, in
);
250 void cls_rgw_obj_check_attrs_prefix(librados::ObjectOperation
& o
, const string
& prefix
, bool fail_if_exist
)
253 struct rgw_cls_obj_check_attrs_prefix call
;
254 call
.check_prefix
= prefix
;
255 call
.fail_if_exist
= fail_if_exist
;
257 o
.exec(RGW_CLASS
, RGW_OBJ_CHECK_ATTRS_PREFIX
, in
);
260 void cls_rgw_obj_check_mtime(librados::ObjectOperation
& o
, const real_time
& mtime
, bool high_precision_time
, RGWCheckMTimeType type
)
263 struct rgw_cls_obj_check_mtime call
;
265 call
.high_precision_time
= high_precision_time
;
268 o
.exec(RGW_CLASS
, RGW_OBJ_CHECK_MTIME
, in
);
271 int cls_rgw_bi_get(librados::IoCtx
& io_ctx
, const string oid
,
272 BIIndexType index_type
, cls_rgw_obj_key
& key
,
273 rgw_cls_bi_entry
*entry
)
276 struct rgw_cls_bi_get_op call
;
278 call
.type
= index_type
;
280 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_BI_GET
, in
, out
);
284 struct rgw_cls_bi_get_ret op_ret
;
285 bufferlist::iterator iter
= out
.begin();
287 ::decode(op_ret
, iter
);
288 } catch (buffer::error
& err
) {
292 *entry
= op_ret
.entry
;
297 int cls_rgw_bi_put(librados::IoCtx
& io_ctx
, const string oid
, rgw_cls_bi_entry
& entry
)
300 struct rgw_cls_bi_put_op call
;
303 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_BI_PUT
, in
, out
);
310 void cls_rgw_bi_put(ObjectWriteOperation
& op
, const string oid
, rgw_cls_bi_entry
& entry
)
313 struct rgw_cls_bi_put_op call
;
316 op
.exec(RGW_CLASS
, RGW_BI_PUT
, in
);
319 int cls_rgw_bi_list(librados::IoCtx
& io_ctx
, const string oid
,
320 const string
& name
, const string
& marker
, uint32_t max
,
321 list
<rgw_cls_bi_entry
> *entries
, bool *is_truncated
)
324 struct rgw_cls_bi_list_op call
;
326 call
.marker
= marker
;
329 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_BI_LIST
, in
, out
);
333 struct rgw_cls_bi_list_ret op_ret
;
334 bufferlist::iterator iter
= out
.begin();
336 ::decode(op_ret
, iter
);
337 } catch (buffer::error
& err
) {
341 entries
->swap(op_ret
.entries
);
342 *is_truncated
= op_ret
.is_truncated
;
347 int cls_rgw_bucket_link_olh(librados::IoCtx
& io_ctx
, librados::ObjectWriteOperation
& op
,
348 const string
& oid
, const cls_rgw_obj_key
& key
, bufferlist
& olh_tag
,
349 bool delete_marker
, const string
& op_tag
, struct rgw_bucket_dir_entry_meta
*meta
,
350 uint64_t olh_epoch
, ceph::real_time unmod_since
, bool high_precision_time
, bool log_op
, rgw_zone_set
& zones_trace
)
353 struct rgw_cls_link_olh_op call
;
355 call
.olh_tag
= string(olh_tag
.c_str(), olh_tag
.length());
356 call
.op_tag
= op_tag
;
357 call
.delete_marker
= delete_marker
;
361 call
.olh_epoch
= olh_epoch
;
362 call
.log_op
= log_op
;
363 call
.unmod_since
= unmod_since
;
364 call
.high_precision_time
= high_precision_time
;
365 call
.zones_trace
= zones_trace
;
367 op
.exec(RGW_CLASS
, RGW_BUCKET_LINK_OLH
, in
);
368 int r
= io_ctx
.operate(oid
, &op
);
375 int cls_rgw_bucket_unlink_instance(librados::IoCtx
& io_ctx
, librados::ObjectWriteOperation
& op
,
377 const cls_rgw_obj_key
& key
, const string
& op_tag
,
378 const string
& olh_tag
, uint64_t olh_epoch
, bool log_op
, rgw_zone_set
& zones_trace
)
381 struct rgw_cls_unlink_instance_op call
;
383 call
.op_tag
= op_tag
;
384 call
.olh_epoch
= olh_epoch
;
385 call
.olh_tag
= olh_tag
;
386 call
.log_op
= log_op
;
387 call
.zones_trace
= zones_trace
;
389 op
.exec(RGW_CLASS
, RGW_BUCKET_UNLINK_INSTANCE
, in
);
390 int r
= io_ctx
.operate(oid
, &op
);
397 int cls_rgw_get_olh_log(IoCtx
& io_ctx
, string
& oid
, librados::ObjectReadOperation
& op
, const cls_rgw_obj_key
& olh
, uint64_t ver_marker
,
398 const string
& olh_tag
,
399 map
<uint64_t, vector
<struct rgw_bucket_olh_log_entry
> > *log
, bool *is_truncated
)
402 struct rgw_cls_read_olh_log_op call
;
404 call
.ver_marker
= ver_marker
;
405 call
.olh_tag
= olh_tag
;
408 op
.exec(RGW_CLASS
, RGW_BUCKET_READ_OLH_LOG
, in
, &out
, &op_ret
);
409 int r
= io_ctx
.operate(oid
, &op
, NULL
);
417 struct rgw_cls_read_olh_log_ret ret
;
419 bufferlist::iterator iter
= out
.begin();
421 } catch (buffer::error
& err
) {
429 *is_truncated
= ret
.is_truncated
;
435 void cls_rgw_trim_olh_log(librados::ObjectWriteOperation
& op
, const cls_rgw_obj_key
& olh
, uint64_t ver
, const string
& olh_tag
)
438 struct rgw_cls_trim_olh_log_op call
;
441 call
.olh_tag
= olh_tag
;
443 op
.exec(RGW_CLASS
, RGW_BUCKET_TRIM_OLH_LOG
, in
);
446 int cls_rgw_clear_olh(IoCtx
& io_ctx
, librados::ObjectWriteOperation
& op
, string
& oid
, const cls_rgw_obj_key
& olh
, const string
& olh_tag
)
449 struct rgw_cls_bucket_clear_olh_op call
;
451 call
.olh_tag
= olh_tag
;
454 op
.exec(RGW_CLASS
, RGW_BUCKET_CLEAR_OLH
, in
, &out
, &op_ret
);
455 int r
= io_ctx
.operate(oid
, &op
);
462 static bool issue_bi_log_list_op(librados::IoCtx
& io_ctx
, const string
& oid
, int shard_id
,
463 BucketIndexShardsManager
& marker_mgr
, uint32_t max
, BucketIndexAioManager
*manager
,
464 struct cls_rgw_bi_log_list_ret
*pdata
) {
466 cls_rgw_bi_log_list_op call
;
467 call
.marker
= marker_mgr
.get(shard_id
, "");
471 librados::ObjectReadOperation op
;
472 op
.exec(RGW_CLASS
, RGW_BI_LOG_LIST
, in
, new ClsBucketIndexOpCtx
<struct cls_rgw_bi_log_list_ret
>(pdata
, NULL
));
473 return manager
->aio_operate(io_ctx
, oid
, &op
);
476 int CLSRGWIssueBILogList::issue_op(int shard_id
, const string
& oid
)
478 return issue_bi_log_list_op(io_ctx
, oid
, shard_id
, marker_mgr
, max
, &manager
, &result
[shard_id
]);
481 static bool issue_bi_log_trim(librados::IoCtx
& io_ctx
, const string
& oid
, int shard_id
,
482 BucketIndexShardsManager
& start_marker_mgr
,
483 BucketIndexShardsManager
& end_marker_mgr
, BucketIndexAioManager
*manager
) {
485 cls_rgw_bi_log_trim_op call
;
486 call
.start_marker
= start_marker_mgr
.get(shard_id
, "");
487 call
.end_marker
= end_marker_mgr
.get(shard_id
, "");
489 ObjectWriteOperation op
;
490 op
.exec(RGW_CLASS
, RGW_BI_LOG_TRIM
, in
);
491 return manager
->aio_operate(io_ctx
, oid
, &op
);
494 int CLSRGWIssueBILogTrim::issue_op(int shard_id
, const string
& oid
)
496 return issue_bi_log_trim(io_ctx
, oid
, shard_id
, start_marker_mgr
, end_marker_mgr
, &manager
);
499 static bool issue_bucket_check_index_op(IoCtx
& io_ctx
, const string
& oid
, BucketIndexAioManager
*manager
,
500 struct rgw_cls_check_index_ret
*pdata
) {
502 librados::ObjectReadOperation op
;
503 op
.exec(RGW_CLASS
, RGW_BUCKET_CHECK_INDEX
, in
, new ClsBucketIndexOpCtx
<struct rgw_cls_check_index_ret
>(
505 return manager
->aio_operate(io_ctx
, oid
, &op
);
508 int CLSRGWIssueBucketCheck::issue_op(int shard_id
, const string
& oid
)
510 return issue_bucket_check_index_op(io_ctx
, oid
, &manager
, &result
[shard_id
]);
513 static bool issue_bucket_rebuild_index_op(IoCtx
& io_ctx
, const string
& oid
,
514 BucketIndexAioManager
*manager
) {
516 librados::ObjectWriteOperation op
;
517 op
.exec(RGW_CLASS
, RGW_BUCKET_REBUILD_INDEX
, in
);
518 return manager
->aio_operate(io_ctx
, oid
, &op
);
521 int CLSRGWIssueBucketRebuild::issue_op(int shard_id
, const string
& oid
)
523 return issue_bucket_rebuild_index_op(io_ctx
, oid
, &manager
);
526 void cls_rgw_encode_suggestion(char op
, rgw_bucket_dir_entry
& dirent
, bufferlist
& updates
)
529 ::encode(dirent
, updates
);
532 void cls_rgw_suggest_changes(ObjectWriteOperation
& o
, bufferlist
& updates
)
534 o
.exec(RGW_CLASS
, RGW_DIR_SUGGEST_CHANGES
, updates
);
537 int CLSRGWIssueGetDirHeader::issue_op(int shard_id
, const string
& oid
)
539 cls_rgw_obj_key nokey
;
540 return issue_bucket_list_op(io_ctx
, oid
, nokey
, "", 0, false, &manager
, &result
[shard_id
]);
543 static bool issue_resync_bi_log(librados::IoCtx
& io_ctx
, const string
& oid
, BucketIndexAioManager
*manager
)
546 librados::ObjectWriteOperation op
;
547 op
.exec("rgw", "bi_log_resync", in
);
548 return manager
->aio_operate(io_ctx
, oid
, &op
);
551 int CLSRGWIssueResyncBucketBILog::issue_op(int shard_id
, const string
& oid
)
553 return issue_resync_bi_log(io_ctx
, oid
, &manager
);
556 static bool issue_bi_log_stop(librados::IoCtx
& io_ctx
, const string
& oid
, BucketIndexAioManager
*manager
)
559 librados::ObjectWriteOperation op
;
560 op
.exec("rgw", "bi_log_stop", in
);
561 return manager
->aio_operate(io_ctx
, oid
, &op
);
564 int CLSRGWIssueBucketBILogStop::issue_op(int shard_id
, const string
& oid
)
566 return issue_bi_log_stop(io_ctx
, oid
, &manager
);
569 class GetDirHeaderCompletion
: public ObjectOperationCompletion
{
570 RGWGetDirHeader_CB
*ret_ctx
;
572 explicit GetDirHeaderCompletion(RGWGetDirHeader_CB
*_ctx
) : ret_ctx(_ctx
) {}
573 ~GetDirHeaderCompletion() override
{
576 void handle_completion(int r
, bufferlist
& outbl
) override
{
577 struct rgw_cls_list_ret ret
;
579 bufferlist::iterator iter
= outbl
.begin();
581 } catch (buffer::error
& err
) {
585 ret_ctx
->handle_response(r
, ret
.dir
.header
);
589 int cls_rgw_get_dir_header_async(IoCtx
& io_ctx
, string
& oid
, RGWGetDirHeader_CB
*ctx
)
592 struct rgw_cls_list_op call
;
593 call
.num_entries
= 0;
595 ObjectReadOperation op
;
596 GetDirHeaderCompletion
*cb
= new GetDirHeaderCompletion(ctx
);
597 op
.exec(RGW_CLASS
, RGW_BUCKET_LIST
, in
, cb
);
598 AioCompletion
*c
= librados::Rados::aio_create_completion(NULL
, NULL
, NULL
);
599 int r
= io_ctx
.aio_operate(oid
, c
, &op
, NULL
);
607 int cls_rgw_usage_log_read(IoCtx
& io_ctx
, string
& oid
, string
& user
,
608 uint64_t start_epoch
, uint64_t end_epoch
, uint32_t max_entries
,
609 string
& read_iter
, map
<rgw_user_bucket
, rgw_usage_log_entry
>& usage
,
613 *is_truncated
= false;
616 rgw_cls_usage_log_read_op call
;
617 call
.start_epoch
= start_epoch
;
618 call
.end_epoch
= end_epoch
;
620 call
.max_entries
= max_entries
;
621 call
.iter
= read_iter
;
623 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_USER_USAGE_LOG_READ
, in
, out
);
628 rgw_cls_usage_log_read_ret result
;
629 bufferlist::iterator iter
= out
.begin();
630 ::decode(result
, iter
);
631 read_iter
= result
.next_iter
;
633 *is_truncated
= result
.truncated
;
635 usage
= result
.usage
;
636 } catch (buffer::error
& e
) {
643 int cls_rgw_usage_log_trim(IoCtx
& io_ctx
, const string
& oid
, string
& user
,
644 uint64_t start_epoch
, uint64_t end_epoch
)
647 rgw_cls_usage_log_trim_op call
;
648 call
.start_epoch
= start_epoch
;
649 call
.end_epoch
= end_epoch
;
655 ObjectWriteOperation op
;
656 op
.exec(RGW_CLASS
, RGW_USER_USAGE_LOG_TRIM
, in
);
657 int r
= io_ctx
.operate(oid
, &op
);
669 void cls_rgw_usage_log_add(ObjectWriteOperation
& op
, rgw_usage_log_info
& info
)
672 rgw_cls_usage_log_add_op call
;
675 op
.exec(RGW_CLASS
, RGW_USER_USAGE_LOG_ADD
, in
);
678 /* garbage collection */
680 void cls_rgw_gc_set_entry(ObjectWriteOperation
& op
, uint32_t expiration_secs
, cls_rgw_gc_obj_info
& info
)
683 cls_rgw_gc_set_entry_op call
;
684 call
.expiration_secs
= expiration_secs
;
687 op
.exec(RGW_CLASS
, RGW_GC_SET_ENTRY
, in
);
690 void cls_rgw_gc_defer_entry(ObjectWriteOperation
& op
, uint32_t expiration_secs
, const string
& tag
)
693 cls_rgw_gc_defer_entry_op call
;
694 call
.expiration_secs
= expiration_secs
;
697 op
.exec(RGW_CLASS
, RGW_GC_DEFER_ENTRY
, in
);
700 int cls_rgw_gc_list(IoCtx
& io_ctx
, string
& oid
, string
& marker
, uint32_t max
, bool expired_only
,
701 list
<cls_rgw_gc_obj_info
>& entries
, bool *truncated
, string
& next_marker
)
704 cls_rgw_gc_list_op call
;
705 call
.marker
= marker
;
707 call
.expired_only
= expired_only
;
709 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_GC_LIST
, in
, out
);
713 cls_rgw_gc_list_ret ret
;
715 bufferlist::iterator iter
= out
.begin();
717 } catch (buffer::error
& err
) {
721 entries
.swap(ret
.entries
);
724 *truncated
= ret
.truncated
;
725 next_marker
= std::move(ret
.next_marker
);
729 void cls_rgw_gc_remove(librados::ObjectWriteOperation
& op
, const list
<string
>& tags
)
732 cls_rgw_gc_remove_op call
;
735 op
.exec(RGW_CLASS
, RGW_GC_REMOVE
, in
);
738 int cls_rgw_lc_get_head(IoCtx
& io_ctx
, string
& oid
, cls_rgw_lc_obj_head
& head
)
741 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_GET_HEAD
, in
, out
);
745 cls_rgw_lc_get_head_ret ret
;
747 bufferlist::iterator iter
= out
.begin();
749 } catch (buffer::error
& err
) {
757 int cls_rgw_lc_put_head(IoCtx
& io_ctx
, string
& oid
, cls_rgw_lc_obj_head
& head
)
760 cls_rgw_lc_put_head_op call
;
763 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_PUT_HEAD
, in
, out
);
767 int cls_rgw_lc_get_next_entry(IoCtx
& io_ctx
, string
& oid
, string
& marker
, pair
<string
, int>& entry
)
770 cls_rgw_lc_get_next_entry_op call
;
771 call
.marker
= marker
;
773 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_GET_NEXT_ENTRY
, in
, out
);
777 cls_rgw_lc_get_next_entry_ret ret
;
779 bufferlist::iterator iter
= out
.begin();
781 } catch (buffer::error
& err
) {
789 int cls_rgw_lc_rm_entry(IoCtx
& io_ctx
, string
& oid
, pair
<string
, int>& entry
)
792 cls_rgw_lc_rm_entry_op call
;
795 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_RM_ENTRY
, in
, out
);
799 int cls_rgw_lc_set_entry(IoCtx
& io_ctx
, string
& oid
, pair
<string
, int>& entry
)
802 cls_rgw_lc_set_entry_op call
;
805 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_SET_ENTRY
, in
, out
);
809 int cls_rgw_lc_list(IoCtx
& io_ctx
, string
& oid
,
810 const string
& marker
,
811 uint32_t max_entries
,
812 map
<string
, int>& entries
)
815 cls_rgw_lc_list_entries_op op
;
820 op
.max_entries
= max_entries
;
824 int r
= io_ctx
.exec(oid
, RGW_CLASS
, RGW_LC_LIST_ENTRIES
, in
, out
);
828 cls_rgw_lc_list_entries_ret ret
;
830 bufferlist::iterator iter
= out
.begin();
832 } catch (buffer::error
& err
) {
835 entries
.insert(ret
.entries
.begin(),ret
.entries
.end());
840 void cls_rgw_reshard_add(librados::ObjectWriteOperation
& op
, const cls_rgw_reshard_entry
& entry
)
843 struct cls_rgw_reshard_add_op call
;
846 op
.exec("rgw", "reshard_add", in
);
849 int cls_rgw_reshard_list(librados::IoCtx
& io_ctx
, const string
& oid
, string
& marker
, uint32_t max
,
850 list
<cls_rgw_reshard_entry
>& entries
, bool* is_truncated
)
853 struct cls_rgw_reshard_list_op call
;
854 call
.marker
= marker
;
857 int r
= io_ctx
.exec(oid
, "rgw", "reshard_list", in
, out
);
861 struct cls_rgw_reshard_list_ret op_ret
;
862 bufferlist::iterator iter
= out
.begin();
864 ::decode(op_ret
, iter
);
865 } catch (buffer::error
& err
) {
869 entries
.swap(op_ret
.entries
);
870 *is_truncated
= op_ret
.is_truncated
;
875 int cls_rgw_reshard_get(librados::IoCtx
& io_ctx
, const string
& oid
, cls_rgw_reshard_entry
& entry
)
878 struct cls_rgw_reshard_get_op call
;
881 int r
= io_ctx
.exec(oid
, "rgw", "reshard_get", in
, out
);
885 struct cls_rgw_reshard_get_ret op_ret
;
886 bufferlist::iterator iter
= out
.begin();
888 ::decode(op_ret
, iter
);
889 } catch (buffer::error
& err
) {
893 entry
= op_ret
.entry
;
898 void cls_rgw_reshard_remove(librados::ObjectWriteOperation
& op
, const cls_rgw_reshard_entry
& entry
)
901 struct cls_rgw_reshard_remove_op call
;
902 call
.tenant
= entry
.tenant
;
903 call
.bucket_name
= entry
.bucket_name
;
904 call
.bucket_id
= entry
.bucket_id
;
906 op
.exec("rgw", "reshard_remove", in
);
909 int cls_rgw_set_bucket_resharding(librados::IoCtx
& io_ctx
, const string
& oid
,
910 const cls_rgw_bucket_instance_entry
& entry
)
913 struct cls_rgw_set_bucket_resharding_op call
;
916 return io_ctx
.exec(oid
, "rgw", "set_bucket_resharding", in
, out
);
919 int cls_rgw_clear_bucket_resharding(librados::IoCtx
& io_ctx
, const string
& oid
)
922 struct cls_rgw_clear_bucket_resharding_op call
;
924 return io_ctx
.exec(oid
, "rgw", "clear_bucket_resharding", in
, out
);
927 int cls_rgw_get_bucket_resharding(librados::IoCtx
& io_ctx
, const string
& oid
,
928 cls_rgw_bucket_instance_entry
*entry
)
931 struct cls_rgw_get_bucket_resharding_op call
;
933 int r
= io_ctx
.exec(oid
, "rgw", "get_bucket_resharding", in
, out
);
937 struct cls_rgw_get_bucket_resharding_ret op_ret
;
938 bufferlist::iterator iter
= out
.begin();
940 ::decode(op_ret
, iter
);
941 } catch (buffer::error
& err
) {
945 *entry
= op_ret
.new_instance
;
950 void cls_rgw_guard_bucket_resharding(librados::ObjectOperation
& op
, int ret_err
)
953 struct cls_rgw_guard_bucket_resharding_op call
;
954 call
.ret_err
= ret_err
;
956 op
.exec("rgw", "guard_bucket_resharding", in
);
959 static bool issue_set_bucket_resharding(librados::IoCtx
& io_ctx
, const string
& oid
,
960 const cls_rgw_bucket_instance_entry
& entry
,
961 BucketIndexAioManager
*manager
) {
963 struct cls_rgw_set_bucket_resharding_op call
;
966 librados::ObjectWriteOperation op
;
967 op
.exec("rgw", "set_bucket_resharding", in
);
968 return manager
->aio_operate(io_ctx
, oid
, &op
);
971 int CLSRGWIssueSetBucketResharding::issue_op(int shard_id
, const string
& oid
)
973 return issue_set_bucket_resharding(io_ctx
, oid
, entry
, &manager
);