1 #ifndef CEPH_RGW_CR_RADOS_H
2 #define CEPH_RGW_CR_RADOS_H
4 #include <boost/intrusive_ptr.hpp>
5 #include "include/assert.h"
6 #include "rgw_coroutine.h"
8 #include "common/WorkQueue.h"
9 #include "common/Throttle.h"
13 class RGWAsyncRadosRequest
: public RefCountedObject
{
15 RGWAioCompletionNotifier
*notifier
;
22 virtual int _send_request() = 0;
24 RGWAsyncRadosRequest(RGWCoroutine
*_caller
, RGWAioCompletionNotifier
*_cn
) : caller(_caller
), notifier(_cn
), retcode(0),
25 lock("RGWAsyncRadosRequest::lock") {
27 ~RGWAsyncRadosRequest() override
{
35 retcode
= _send_request();
37 Mutex::Locker
l(lock
);
39 notifier
->cb(); // drops its own ref
46 int get_ret_status() { return retcode
; }
50 Mutex::Locker
l(lock
);
52 // we won't call notifier->cb() to drop its ref, so drop it here
62 class RGWAsyncRadosProcessor
{
63 deque
<RGWAsyncRadosRequest
*> m_req_queue
;
64 std::atomic
<bool> going_down
= { false };
68 Throttle req_throttle
;
70 struct RGWWQ
: public ThreadPool::WorkQueue
<RGWAsyncRadosRequest
> {
71 RGWAsyncRadosProcessor
*processor
;
72 RGWWQ(RGWAsyncRadosProcessor
*p
, time_t timeout
, time_t suicide_timeout
, ThreadPool
*tp
)
73 : ThreadPool::WorkQueue
<RGWAsyncRadosRequest
>("RGWWQ", timeout
, suicide_timeout
, tp
), processor(p
) {}
75 bool _enqueue(RGWAsyncRadosRequest
*req
) override
;
76 void _dequeue(RGWAsyncRadosRequest
*req
) override
{
79 bool _empty() override
;
80 RGWAsyncRadosRequest
*_dequeue() override
;
81 using ThreadPool::WorkQueue
<RGWAsyncRadosRequest
>::_process
;
82 void _process(RGWAsyncRadosRequest
*req
, ThreadPool::TPHandle
& handle
) override
;
84 void _clear() override
{
85 assert(processor
->m_req_queue
.empty());
90 RGWAsyncRadosProcessor(RGWRados
*_store
, int num_threads
);
91 ~RGWAsyncRadosProcessor() {}
94 void handle_request(RGWAsyncRadosRequest
*req
);
95 void queue(RGWAsyncRadosRequest
*req
);
97 bool is_going_down() {
103 class RGWAsyncGetSystemObj
: public RGWAsyncRadosRequest
{
105 RGWObjectCtx
*obj_ctx
;
106 RGWRados::SystemObject::Read::GetObjState read_state
;
107 RGWObjVersionTracker
*objv_tracker
;
110 map
<string
, bufferlist
> *pattrs
;
114 int _send_request() override
;
116 RGWAsyncGetSystemObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
, RGWObjectCtx
*_obj_ctx
,
117 RGWObjVersionTracker
*_objv_tracker
, const rgw_raw_obj
& _obj
,
118 bufferlist
*_pbl
, off_t _ofs
, off_t _end
);
119 void set_read_attrs(map
<string
, bufferlist
> *_pattrs
) { pattrs
= _pattrs
; }
122 class RGWAsyncPutSystemObj
: public RGWAsyncRadosRequest
{
124 RGWObjVersionTracker
*objv_tracker
;
130 int _send_request() override
;
132 RGWAsyncPutSystemObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
133 RGWObjVersionTracker
*_objv_tracker
, rgw_raw_obj
& _obj
,
134 bool _exclusive
, bufferlist
& _bl
);
137 class RGWAsyncPutSystemObjAttrs
: public RGWAsyncRadosRequest
{
139 RGWObjVersionTracker
*objv_tracker
;
141 map
<string
, bufferlist
> *attrs
;
144 int _send_request() override
;
146 RGWAsyncPutSystemObjAttrs(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
147 RGWObjVersionTracker
*_objv_tracker
, const rgw_raw_obj
& _obj
,
148 map
<string
, bufferlist
> *_attrs
);
151 class RGWAsyncLockSystemObj
: public RGWAsyncRadosRequest
{
156 uint32_t duration_secs
;
159 int _send_request() override
;
161 RGWAsyncLockSystemObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
162 RGWObjVersionTracker
*_objv_tracker
, const rgw_raw_obj
& _obj
,
163 const string
& _name
, const string
& _cookie
, uint32_t _duration_secs
);
166 class RGWAsyncUnlockSystemObj
: public RGWAsyncRadosRequest
{
173 int _send_request() override
;
175 RGWAsyncUnlockSystemObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
176 RGWObjVersionTracker
*_objv_tracker
, const rgw_raw_obj
& _obj
,
177 const string
& _name
, const string
& _cookie
);
181 class RGWSimpleRadosReadCR
: public RGWSimpleCoroutine
{
182 RGWAsyncRadosProcessor
*async_rados
;
184 RGWObjectCtx obj_ctx
;
189 map
<string
, bufferlist
> *pattrs
{nullptr};
192 /// on ENOENT, call handle_data() with an empty object instead of failing
193 const bool empty_on_enoent
;
194 RGWObjVersionTracker
*objv_tracker
;
196 RGWAsyncGetSystemObj
*req
{nullptr};
199 RGWSimpleRadosReadCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
200 const rgw_raw_obj
& _obj
,
201 T
*_result
, bool empty_on_enoent
= true,
202 RGWObjVersionTracker
*objv_tracker
= nullptr)
203 : RGWSimpleCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
204 obj_ctx(store
), obj(_obj
), result(_result
),
205 empty_on_enoent(empty_on_enoent
), objv_tracker(objv_tracker
) {}
206 ~RGWSimpleRadosReadCR() override
{
210 void request_cleanup() override
{
217 int send_request() override
;
218 int request_complete() override
;
220 virtual int handle_data(T
& data
) {
226 int RGWSimpleRadosReadCR
<T
>::send_request()
228 req
= new RGWAsyncGetSystemObj(this, stack
->create_completion_notifier(),
229 store
, &obj_ctx
, objv_tracker
,
233 req
->set_read_attrs(pattrs
);
235 async_rados
->queue(req
);
240 int RGWSimpleRadosReadCR
<T
>::request_complete()
242 int ret
= req
->get_ret_status();
244 if (ret
== -ENOENT
&& empty_on_enoent
) {
251 bufferlist::iterator iter
= bl
.begin();
253 // allow successful reads with empty buffers. ReadSyncStatus coroutines
254 // depend on this to be able to read without locking, because the
255 // cls lock from InitSyncStatus will create an empty object if it didnt
259 ::decode(*result
, iter
);
261 } catch (buffer::error
& err
) {
266 return handle_data(*result
);
269 class RGWSimpleRadosReadAttrsCR
: public RGWSimpleCoroutine
{
270 RGWAsyncRadosProcessor
*async_rados
;
272 RGWObjectCtx obj_ctx
;
277 map
<string
, bufferlist
> *pattrs
;
279 RGWAsyncGetSystemObj
*req
;
282 RGWSimpleRadosReadAttrsCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
283 const rgw_raw_obj
& _obj
,
284 map
<string
, bufferlist
> *_pattrs
) : RGWSimpleCoroutine(_store
->ctx()),
285 async_rados(_async_rados
), store(_store
),
290 ~RGWSimpleRadosReadAttrsCR() override
{
294 void request_cleanup() override
{
301 int send_request() override
;
302 int request_complete() override
;
306 class RGWSimpleRadosWriteCR
: public RGWSimpleCoroutine
{
307 RGWAsyncRadosProcessor
*async_rados
;
312 RGWObjVersionTracker
*objv_tracker
;
314 RGWAsyncPutSystemObj
*req
{nullptr};
317 RGWSimpleRadosWriteCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
318 const rgw_raw_obj
& _obj
,
319 const T
& _data
, RGWObjVersionTracker
*objv_tracker
= nullptr)
320 : RGWSimpleCoroutine(_store
->ctx()), async_rados(_async_rados
),
321 store(_store
), obj(_obj
), objv_tracker(objv_tracker
) {
325 ~RGWSimpleRadosWriteCR() override
{
329 void request_cleanup() override
{
336 int send_request() override
{
337 req
= new RGWAsyncPutSystemObj(this, stack
->create_completion_notifier(),
338 store
, objv_tracker
, obj
, false, bl
);
339 async_rados
->queue(req
);
343 int request_complete() override
{
344 return req
->get_ret_status();
348 class RGWSimpleRadosWriteAttrsCR
: public RGWSimpleCoroutine
{
349 RGWAsyncRadosProcessor
*async_rados
;
354 map
<string
, bufferlist
> attrs
;
356 RGWAsyncPutSystemObjAttrs
*req
;
359 RGWSimpleRadosWriteAttrsCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
360 const rgw_raw_obj
& _obj
,
361 map
<string
, bufferlist
>& _attrs
) : RGWSimpleCoroutine(_store
->ctx()),
362 async_rados(_async_rados
),
365 attrs(_attrs
), req(NULL
) {
367 ~RGWSimpleRadosWriteAttrsCR() override
{
371 void request_cleanup() override
{
378 int send_request() override
{
379 req
= new RGWAsyncPutSystemObjAttrs(this, stack
->create_completion_notifier(),
380 store
, NULL
, obj
, &attrs
);
381 async_rados
->queue(req
);
385 int request_complete() override
{
386 return req
->get_ret_status();
390 class RGWRadosSetOmapKeysCR
: public RGWSimpleCoroutine
{
392 map
<string
, bufferlist
> entries
;
398 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
401 RGWRadosSetOmapKeysCR(RGWRados
*_store
,
402 const rgw_raw_obj
& _obj
,
403 map
<string
, bufferlist
>& _entries
);
405 int send_request() override
;
406 int request_complete() override
;
409 class RGWRadosGetOmapKeysCR
: public RGWSimpleCoroutine
{
413 std::set
<std::string
> *entries
;
420 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
423 RGWRadosGetOmapKeysCR(RGWRados
*_store
,
424 const rgw_raw_obj
& _obj
,
425 const string
& _marker
,
426 std::set
<std::string
> *_entries
, int _max_entries
);
428 int send_request() override
;
429 int request_complete() override
;
432 class RGWRadosRemoveOmapKeysCR
: public RGWSimpleCoroutine
{
441 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
444 RGWRadosRemoveOmapKeysCR(RGWRados
*_store
,
445 const rgw_raw_obj
& _obj
,
446 const set
<string
>& _keys
);
448 int send_request() override
;
450 int request_complete() override
;
453 class RGWRadosRemoveCR
: public RGWSimpleCoroutine
{
455 librados::IoCtx ioctx
;
456 const rgw_raw_obj obj
;
457 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
460 RGWRadosRemoveCR(RGWRados
*store
, const rgw_raw_obj
& obj
);
463 int request_complete();
466 class RGWSimpleRadosLockCR
: public RGWSimpleCoroutine
{
467 RGWAsyncRadosProcessor
*async_rados
;
475 RGWAsyncLockSystemObj
*req
;
478 RGWSimpleRadosLockCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
479 const rgw_raw_obj
& _obj
,
480 const string
& _lock_name
,
481 const string
& _cookie
,
483 ~RGWSimpleRadosLockCR() override
{
486 void request_cleanup() override
;
488 int send_request() override
;
489 int request_complete() override
;
491 static std::string
gen_random_cookie(CephContext
* cct
) {
492 #define COOKIE_LEN 16
493 char buf
[COOKIE_LEN
+ 1];
494 gen_rand_alphanumeric(cct
, buf
, sizeof(buf
) - 1);
499 class RGWSimpleRadosUnlockCR
: public RGWSimpleCoroutine
{
500 RGWAsyncRadosProcessor
*async_rados
;
507 RGWAsyncUnlockSystemObj
*req
;
510 RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
511 const rgw_raw_obj
& _obj
,
512 const string
& _lock_name
,
513 const string
& _cookie
);
514 ~RGWSimpleRadosUnlockCR() override
{
517 void request_cleanup() override
;
519 int send_request() override
;
520 int request_complete() override
;
523 #define OMAP_APPEND_MAX_ENTRIES_DEFAULT 100
525 class RGWOmapAppend
: public RGWConsumerCR
<string
> {
526 RGWAsyncRadosProcessor
*async_rados
;
533 int num_pending_entries
;
534 list
<string
> pending_entries
;
536 map
<string
, bufferlist
> entries
;
538 uint64_t window_size
;
539 uint64_t total_entries
;
541 RGWOmapAppend(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
542 const rgw_raw_obj
& _obj
,
543 uint64_t _window_size
= OMAP_APPEND_MAX_ENTRIES_DEFAULT
);
544 int operate() override
;
545 void flush_pending();
546 bool append(const string
& s
);
549 uint64_t get_total_entries() {
550 return total_entries
;
553 const rgw_raw_obj
& get_obj() {
558 class RGWAsyncWait
: public RGWAsyncRadosRequest
{
564 int _send_request() override
{
565 Mutex::Locker
l(*lock
);
566 return cond
->WaitInterval(*lock
, interval
);
569 RGWAsyncWait(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, CephContext
*_cct
,
570 Mutex
*_lock
, Cond
*_cond
, int _secs
) : RGWAsyncRadosRequest(caller
, cn
),
572 lock(_lock
), cond(_cond
), interval(_secs
, 0) {}
575 Mutex::Locker
l(*lock
);
580 class RGWWaitCR
: public RGWSimpleCoroutine
{
582 RGWAsyncRadosProcessor
*async_rados
;
590 RGWWaitCR(RGWAsyncRadosProcessor
*_async_rados
, CephContext
*_cct
,
591 Mutex
*_lock
, Cond
*_cond
,
592 int _secs
) : RGWSimpleCoroutine(_cct
), cct(_cct
),
593 async_rados(_async_rados
), lock(_lock
), cond(_cond
), secs(_secs
), req(NULL
) {
595 ~RGWWaitCR() override
{
599 void request_cleanup() override
{
607 int send_request() override
{
608 req
= new RGWAsyncWait(this, stack
->create_completion_notifier(), cct
, lock
, cond
, secs
);
609 async_rados
->queue(req
);
613 int request_complete() override
{
614 return req
->get_ret_status();
622 class RGWShardedOmapCRManager
{
623 RGWAsyncRadosProcessor
*async_rados
;
629 vector
<RGWOmapAppend
*> shards
;
631 RGWShardedOmapCRManager(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
, RGWCoroutine
*_op
, int _num_shards
, const rgw_pool
& pool
, const string
& oid_prefix
)
632 : async_rados(_async_rados
),
633 store(_store
), op(_op
), num_shards(_num_shards
) {
634 shards
.reserve(num_shards
);
635 for (int i
= 0; i
< num_shards
; ++i
) {
636 char buf
[oid_prefix
.size() + 16];
637 snprintf(buf
, sizeof(buf
), "%s.%d", oid_prefix
.c_str(), i
);
638 RGWOmapAppend
*shard
= new RGWOmapAppend(async_rados
, store
, rgw_raw_obj(pool
, buf
));
640 shards
.push_back(shard
);
641 op
->spawn(shard
, false);
645 ~RGWShardedOmapCRManager() {
646 for (auto shard
: shards
) {
651 bool append(const string
& entry
, int shard_id
) {
652 return shards
[shard_id
]->append(entry
);
656 for (vector
<RGWOmapAppend
*>::iterator iter
= shards
.begin(); iter
!= shards
.end(); ++iter
) {
657 success
&= ((*iter
)->finish() && (!(*iter
)->is_error()));
662 uint64_t get_total_entries(int shard_id
) {
663 return shards
[shard_id
]->get_total_entries();
667 class RGWAsyncGetBucketInstanceInfo
: public RGWAsyncRadosRequest
{
669 const std::string oid
;
670 RGWBucketInfo
*bucket_info
;
673 int _send_request() override
;
675 RGWAsyncGetBucketInstanceInfo(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
,
676 RGWRados
*_store
, const std::string
& oid
,
677 RGWBucketInfo
*_bucket_info
)
678 : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
679 oid(oid
), bucket_info(_bucket_info
) {}
682 class RGWGetBucketInstanceInfoCR
: public RGWSimpleCoroutine
{
683 RGWAsyncRadosProcessor
*async_rados
;
685 const std::string oid
;
686 RGWBucketInfo
*bucket_info
;
688 RGWAsyncGetBucketInstanceInfo
*req
{nullptr};
691 // metadata key constructor
692 RGWGetBucketInstanceInfoCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
693 const std::string
& meta_key
, RGWBucketInfo
*_bucket_info
)
694 : RGWSimpleCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
695 oid(RGW_BUCKET_INSTANCE_MD_PREFIX
+ meta_key
),
696 bucket_info(_bucket_info
) {}
697 // rgw_bucket constructor
698 RGWGetBucketInstanceInfoCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
699 const rgw_bucket
& bucket
, RGWBucketInfo
*_bucket_info
)
700 : RGWSimpleCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
701 oid(RGW_BUCKET_INSTANCE_MD_PREFIX
+ bucket
.get_key(':')),
702 bucket_info(_bucket_info
) {}
703 ~RGWGetBucketInstanceInfoCR() override
{
706 void request_cleanup() override
{
713 int send_request() override
{
714 req
= new RGWAsyncGetBucketInstanceInfo(this, stack
->create_completion_notifier(), store
, oid
, bucket_info
);
715 async_rados
->queue(req
);
718 int request_complete() override
{
719 return req
->get_ret_status();
723 class RGWRadosBILogTrimCR
: public RGWSimpleCoroutine
{
724 RGWRados::BucketShard bs
;
725 std::string start_marker
;
726 std::string end_marker
;
727 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
729 RGWRadosBILogTrimCR(RGWRados
*store
, const RGWBucketInfo
& bucket_info
,
730 int shard_id
, const std::string
& start_marker
,
731 const std::string
& end_marker
);
733 int send_request() override
;
734 int request_complete() override
;
737 class RGWAsyncFetchRemoteObj
: public RGWAsyncRadosRequest
{
741 RGWBucketInfo bucket_info
;
744 uint64_t versioned_epoch
;
749 rgw_zone_set
*zones_trace
;
752 int _send_request() override
;
754 RGWAsyncFetchRemoteObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
755 const string
& _source_zone
,
756 RGWBucketInfo
& _bucket_info
,
757 const rgw_obj_key
& _key
,
758 uint64_t _versioned_epoch
,
759 bool _if_newer
, rgw_zone_set
*_zones_trace
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
760 source_zone(_source_zone
),
761 bucket_info(_bucket_info
),
763 versioned_epoch(_versioned_epoch
),
764 copy_if_newer(_if_newer
), zones_trace(_zones_trace
) {}
767 class RGWFetchRemoteObjCR
: public RGWSimpleCoroutine
{
769 RGWAsyncRadosProcessor
*async_rados
;
773 RGWBucketInfo bucket_info
;
776 uint64_t versioned_epoch
;
782 RGWAsyncFetchRemoteObj
*req
;
783 rgw_zone_set
*zones_trace
;
786 RGWFetchRemoteObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
787 const string
& _source_zone
,
788 RGWBucketInfo
& _bucket_info
,
789 const rgw_obj_key
& _key
,
790 uint64_t _versioned_epoch
,
791 bool _if_newer
, rgw_zone_set
*_zones_trace
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
792 async_rados(_async_rados
), store(_store
),
793 source_zone(_source_zone
),
794 bucket_info(_bucket_info
),
796 versioned_epoch(_versioned_epoch
),
797 copy_if_newer(_if_newer
), req(NULL
), zones_trace(_zones_trace
) {}
800 ~RGWFetchRemoteObjCR() override
{
804 void request_cleanup() override
{
811 int send_request() override
{
812 req
= new RGWAsyncFetchRemoteObj(this, stack
->create_completion_notifier(), store
, source_zone
, bucket_info
,
813 key
, versioned_epoch
, copy_if_newer
, zones_trace
);
814 async_rados
->queue(req
);
818 int request_complete() override
{
819 return req
->get_ret_status();
823 class RGWAsyncStatRemoteObj
: public RGWAsyncRadosRequest
{
827 RGWBucketInfo bucket_info
;
831 ceph::real_time
*pmtime
;
833 map
<string
, bufferlist
> *pattrs
;
836 int _send_request() override
;
838 RGWAsyncStatRemoteObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
839 const string
& _source_zone
,
840 RGWBucketInfo
& _bucket_info
,
841 const rgw_obj_key
& _key
,
842 ceph::real_time
*_pmtime
,
844 map
<string
, bufferlist
> *_pattrs
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
845 source_zone(_source_zone
),
846 bucket_info(_bucket_info
),
853 class RGWStatRemoteObjCR
: public RGWSimpleCoroutine
{
855 RGWAsyncRadosProcessor
*async_rados
;
859 RGWBucketInfo bucket_info
;
863 ceph::real_time
*pmtime
;
865 map
<string
, bufferlist
> *pattrs
;
867 RGWAsyncStatRemoteObj
*req
;
870 RGWStatRemoteObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
871 const string
& _source_zone
,
872 RGWBucketInfo
& _bucket_info
,
873 const rgw_obj_key
& _key
,
874 ceph::real_time
*_pmtime
,
876 map
<string
, bufferlist
> *_pattrs
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
877 async_rados(_async_rados
), store(_store
),
878 source_zone(_source_zone
),
879 bucket_info(_bucket_info
),
887 ~RGWStatRemoteObjCR() override
{
891 void request_cleanup() override
{
898 int send_request() override
{
899 req
= new RGWAsyncStatRemoteObj(this, stack
->create_completion_notifier(), store
, source_zone
,
900 bucket_info
, key
, pmtime
, psize
, pattrs
);
901 async_rados
->queue(req
);
905 int request_complete() override
{
906 return req
->get_ret_status();
910 class RGWAsyncRemoveObj
: public RGWAsyncRadosRequest
{
914 RGWBucketInfo bucket_info
;
918 string owner_display_name
;
920 uint64_t versioned_epoch
;
921 string marker_version_id
;
924 ceph::real_time timestamp
;
925 rgw_zone_set
*zones_trace
;
928 int _send_request() override
;
930 RGWAsyncRemoveObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
931 const string
& _source_zone
,
932 RGWBucketInfo
& _bucket_info
,
933 const rgw_obj_key
& _key
,
934 const string
& _owner
,
935 const string
& _owner_display_name
,
937 uint64_t _versioned_epoch
,
940 real_time
& _timestamp
,
941 rgw_zone_set
* _zones_trace
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
942 source_zone(_source_zone
),
943 bucket_info(_bucket_info
),
946 owner_display_name(_owner_display_name
),
947 versioned(_versioned
),
948 versioned_epoch(_versioned_epoch
),
949 del_if_older(_if_older
),
950 timestamp(_timestamp
), zones_trace(_zones_trace
) {
951 if (_delete_marker
) {
952 marker_version_id
= key
.instance
;
957 class RGWRemoveObjCR
: public RGWSimpleCoroutine
{
959 RGWAsyncRadosProcessor
*async_rados
;
963 RGWBucketInfo bucket_info
;
967 uint64_t versioned_epoch
;
970 string owner_display_name
;
975 RGWAsyncRemoveObj
*req
;
977 rgw_zone_set
*zones_trace
;
980 RGWRemoveObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
981 const string
& _source_zone
,
982 RGWBucketInfo
& _bucket_info
,
983 const rgw_obj_key
& _key
,
985 uint64_t _versioned_epoch
,
987 string
*_owner_display_name
,
989 real_time
*_timestamp
,
990 rgw_zone_set
*_zones_trace
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
991 async_rados(_async_rados
), store(_store
),
992 source_zone(_source_zone
),
993 bucket_info(_bucket_info
),
995 versioned(_versioned
),
996 versioned_epoch(_versioned_epoch
),
997 delete_marker(_delete_marker
), req(NULL
), zones_trace(_zones_trace
) {
998 del_if_older
= (_timestamp
!= NULL
);
1000 timestamp
= *_timestamp
;
1007 if (_owner_display_name
) {
1008 owner_display_name
= *_owner_display_name
;
1011 ~RGWRemoveObjCR() override
{
1015 void request_cleanup() override
{
1022 int send_request() override
{
1023 req
= new RGWAsyncRemoveObj(this, stack
->create_completion_notifier(), store
, source_zone
, bucket_info
,
1024 key
, owner
, owner_display_name
, versioned
, versioned_epoch
,
1025 delete_marker
, del_if_older
, timestamp
, zones_trace
);
1026 async_rados
->queue(req
);
1030 int request_complete() override
{
1031 return req
->get_ret_status();
1035 class RGWContinuousLeaseCR
: public RGWCoroutine
{
1036 RGWAsyncRadosProcessor
*async_rados
;
1039 const rgw_raw_obj obj
;
1041 const string lock_name
;
1042 const string cookie
;
1047 std::atomic
<bool> going_down
= { false };
1050 RGWCoroutine
*caller
;
1052 bool aborted
{false};
1055 RGWContinuousLeaseCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
1056 const rgw_raw_obj
& _obj
,
1057 const string
& _lock_name
, int _interval
, RGWCoroutine
*_caller
)
1058 : RGWCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
1059 obj(_obj
), lock_name(_lock_name
),
1060 cookie(RGWSimpleRadosLockCR::gen_random_cookie(cct
)),
1061 interval(_interval
), lock("RGWContinuousLeaseCR"), caller(_caller
)
1064 int operate() override
;
1067 Mutex::Locker
l(lock
);
1071 void set_locked(bool status
) {
1072 Mutex::Locker
l(lock
);
1086 class RGWRadosTimelogAddCR
: public RGWSimpleCoroutine
{
1088 list
<cls_log_entry
> entries
;
1092 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
1095 RGWRadosTimelogAddCR(RGWRados
*_store
, const string
& _oid
,
1096 const cls_log_entry
& entry
);
1098 int send_request() override
;
1099 int request_complete() override
;
1102 class RGWRadosTimelogTrimCR
: public RGWSimpleCoroutine
{
1104 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
1107 real_time start_time
;
1109 std::string from_marker
;
1110 std::string to_marker
;
1113 RGWRadosTimelogTrimCR(RGWRados
*store
, const std::string
& oid
,
1114 const real_time
& start_time
, const real_time
& end_time
,
1115 const std::string
& from_marker
,
1116 const std::string
& to_marker
);
1118 int send_request() override
;
1119 int request_complete() override
;
1122 // wrapper to update last_trim_marker on success
1123 class RGWSyncLogTrimCR
: public RGWRadosTimelogTrimCR
{
1125 std::string
*last_trim_marker
;
1127 RGWSyncLogTrimCR(RGWRados
*store
, const std::string
& oid
,
1128 const std::string
& to_marker
, std::string
*last_trim_marker
);
1129 int request_complete() override
;
1132 class RGWAsyncStatObj
: public RGWAsyncRadosRequest
{
1134 RGWBucketInfo bucket_info
;
1139 RGWObjVersionTracker
*objv_tracker
;
1141 int _send_request() override
;
1143 RGWAsyncStatObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*store
,
1144 const RGWBucketInfo
& _bucket_info
, const rgw_obj
& obj
, uint64_t *psize
= nullptr,
1145 real_time
*pmtime
= nullptr, uint64_t *pepoch
= nullptr,
1146 RGWObjVersionTracker
*objv_tracker
= nullptr)
1147 : RGWAsyncRadosRequest(caller
, cn
), store(store
), obj(obj
), psize(psize
),
1148 pmtime(pmtime
), pepoch(pepoch
), objv_tracker(objv_tracker
) {}
1151 class RGWStatObjCR
: public RGWSimpleCoroutine
{
1153 RGWAsyncRadosProcessor
*async_rados
;
1154 RGWBucketInfo bucket_info
;
1159 RGWObjVersionTracker
*objv_tracker
;
1160 RGWAsyncStatObj
*req
= nullptr;
1162 RGWStatObjCR(RGWAsyncRadosProcessor
*async_rados
, RGWRados
*store
,
1163 const RGWBucketInfo
& _bucket_info
, const rgw_obj
& obj
, uint64_t *psize
= nullptr,
1164 real_time
* pmtime
= nullptr, uint64_t *pepoch
= nullptr,
1165 RGWObjVersionTracker
*objv_tracker
= nullptr);
1166 ~RGWStatObjCR() override
{
1169 void request_cleanup() override
;
1171 int send_request() override
;
1172 int request_complete() override
;
1175 /// coroutine wrapper for IoCtx::aio_notify()
1176 class RGWRadosNotifyCR
: public RGWSimpleCoroutine
{
1177 RGWRados
*const store
;
1178 const rgw_raw_obj obj
;
1180 const uint64_t timeout_ms
;
1181 bufferlist
*response
;
1183 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
1186 RGWRadosNotifyCR(RGWRados
*store
, const rgw_raw_obj
& obj
,
1187 bufferlist
& request
, uint64_t timeout_ms
,
1188 bufferlist
*response
);
1190 int send_request() override
;
1191 int request_complete() override
;