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
);
182 class RGWSimpleRadosReadCR
: public RGWSimpleCoroutine
{
183 RGWAsyncRadosProcessor
*async_rados
;
185 RGWObjectCtx obj_ctx
;
190 map
<string
, bufferlist
> *pattrs
{nullptr};
193 /// on ENOENT, call handle_data() with an empty object instead of failing
194 const bool empty_on_enoent
;
195 RGWObjVersionTracker
*objv_tracker
;
197 RGWAsyncGetSystemObj
*req
{nullptr};
200 RGWSimpleRadosReadCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
201 const rgw_raw_obj
& _obj
,
202 T
*_result
, bool empty_on_enoent
= true,
203 RGWObjVersionTracker
*objv_tracker
= nullptr)
204 : RGWSimpleCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
205 obj_ctx(store
), obj(_obj
), result(_result
),
206 empty_on_enoent(empty_on_enoent
), objv_tracker(objv_tracker
) {}
207 ~RGWSimpleRadosReadCR() override
{
211 void request_cleanup() override
{
218 int send_request() override
;
219 int request_complete() override
;
221 virtual int handle_data(T
& data
) {
227 int RGWSimpleRadosReadCR
<T
>::send_request()
229 req
= new RGWAsyncGetSystemObj(this, stack
->create_completion_notifier(),
230 store
, &obj_ctx
, objv_tracker
,
234 req
->set_read_attrs(pattrs
);
236 async_rados
->queue(req
);
241 int RGWSimpleRadosReadCR
<T
>::request_complete()
243 int ret
= req
->get_ret_status();
245 if (ret
== -ENOENT
&& empty_on_enoent
) {
252 bufferlist::iterator iter
= bl
.begin();
254 // allow successful reads with empty buffers. ReadSyncStatus coroutines
255 // depend on this to be able to read without locking, because the
256 // cls lock from InitSyncStatus will create an empty object if it didnt
260 ::decode(*result
, iter
);
262 } catch (buffer::error
& err
) {
267 return handle_data(*result
);
270 class RGWSimpleRadosReadAttrsCR
: public RGWSimpleCoroutine
{
271 RGWAsyncRadosProcessor
*async_rados
;
273 RGWObjectCtx obj_ctx
;
278 map
<string
, bufferlist
> *pattrs
;
280 RGWAsyncGetSystemObj
*req
;
283 RGWSimpleRadosReadAttrsCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
284 const rgw_raw_obj
& _obj
,
285 map
<string
, bufferlist
> *_pattrs
) : RGWSimpleCoroutine(_store
->ctx()),
286 async_rados(_async_rados
), store(_store
),
291 ~RGWSimpleRadosReadAttrsCR() override
{
295 void request_cleanup() override
{
302 int send_request() override
;
303 int request_complete() override
;
307 class RGWSimpleRadosWriteCR
: public RGWSimpleCoroutine
{
308 RGWAsyncRadosProcessor
*async_rados
;
313 RGWObjVersionTracker
*objv_tracker
;
315 RGWAsyncPutSystemObj
*req
{nullptr};
318 RGWSimpleRadosWriteCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
319 const rgw_raw_obj
& _obj
,
320 const T
& _data
, RGWObjVersionTracker
*objv_tracker
= nullptr)
321 : RGWSimpleCoroutine(_store
->ctx()), async_rados(_async_rados
),
322 store(_store
), obj(_obj
), objv_tracker(objv_tracker
) {
326 ~RGWSimpleRadosWriteCR() override
{
330 void request_cleanup() override
{
337 int send_request() override
{
338 req
= new RGWAsyncPutSystemObj(this, stack
->create_completion_notifier(),
339 store
, objv_tracker
, obj
, false, bl
);
340 async_rados
->queue(req
);
344 int request_complete() override
{
345 return req
->get_ret_status();
349 class RGWSimpleRadosWriteAttrsCR
: public RGWSimpleCoroutine
{
350 RGWAsyncRadosProcessor
*async_rados
;
355 map
<string
, bufferlist
> attrs
;
357 RGWAsyncPutSystemObjAttrs
*req
;
360 RGWSimpleRadosWriteAttrsCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
361 const rgw_raw_obj
& _obj
,
362 map
<string
, bufferlist
>& _attrs
) : RGWSimpleCoroutine(_store
->ctx()),
363 async_rados(_async_rados
),
366 attrs(_attrs
), req(NULL
) {
368 ~RGWSimpleRadosWriteAttrsCR() override
{
372 void request_cleanup() override
{
379 int send_request() override
{
380 req
= new RGWAsyncPutSystemObjAttrs(this, stack
->create_completion_notifier(),
381 store
, NULL
, obj
, &attrs
);
382 async_rados
->queue(req
);
386 int request_complete() override
{
387 return req
->get_ret_status();
391 class RGWRadosSetOmapKeysCR
: public RGWSimpleCoroutine
{
393 map
<string
, bufferlist
> entries
;
399 RGWAioCompletionNotifier
*cn
;
402 RGWRadosSetOmapKeysCR(RGWRados
*_store
,
403 const rgw_raw_obj
& _obj
,
404 map
<string
, bufferlist
>& _entries
);
406 ~RGWRadosSetOmapKeysCR() override
;
408 int send_request() override
;
409 int request_complete() override
;
412 class RGWRadosGetOmapKeysCR
: public RGWSimpleCoroutine
{
416 map
<string
, bufferlist
> *entries
;
424 RGWAioCompletionNotifier
*cn
;
427 RGWRadosGetOmapKeysCR(RGWRados
*_store
,
428 const rgw_raw_obj
& _obj
,
429 const string
& _marker
,
430 map
<string
, bufferlist
> *_entries
, int _max_entries
);
432 ~RGWRadosGetOmapKeysCR() override
;
434 int send_request() override
;
436 int request_complete() override
{
441 class RGWRadosRemoveOmapKeysCR
: public RGWSimpleCoroutine
{
445 map
<string
, bufferlist
> *entries
;
455 RGWAioCompletionNotifier
*cn
;
458 RGWRadosRemoveOmapKeysCR(RGWRados
*_store
,
459 const rgw_raw_obj
& _obj
,
460 const set
<string
>& _keys
);
462 ~RGWRadosRemoveOmapKeysCR() override
;
464 int send_request() override
;
466 int request_complete() override
{
471 class RGWRadosRemoveCR
: public RGWSimpleCoroutine
{
473 librados::IoCtx ioctx
;
474 const rgw_raw_obj obj
;
475 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
478 RGWRadosRemoveCR(RGWRados
*store
, const rgw_raw_obj
& obj
);
481 int request_complete();
484 class RGWSimpleRadosLockCR
: public RGWSimpleCoroutine
{
485 RGWAsyncRadosProcessor
*async_rados
;
493 RGWAsyncLockSystemObj
*req
;
496 RGWSimpleRadosLockCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
497 const rgw_raw_obj
& _obj
,
498 const string
& _lock_name
,
499 const string
& _cookie
,
501 ~RGWSimpleRadosLockCR() override
{
504 void request_cleanup() override
;
506 int send_request() override
;
507 int request_complete() override
;
509 static std::string
gen_random_cookie(CephContext
* cct
) {
510 #define COOKIE_LEN 16
511 char buf
[COOKIE_LEN
+ 1];
512 gen_rand_alphanumeric(cct
, buf
, sizeof(buf
) - 1);
517 class RGWSimpleRadosUnlockCR
: public RGWSimpleCoroutine
{
518 RGWAsyncRadosProcessor
*async_rados
;
525 RGWAsyncUnlockSystemObj
*req
;
528 RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
529 const rgw_raw_obj
& _obj
,
530 const string
& _lock_name
,
531 const string
& _cookie
);
532 ~RGWSimpleRadosUnlockCR() override
{
535 void request_cleanup() override
;
537 int send_request() override
;
538 int request_complete() override
;
541 #define OMAP_APPEND_MAX_ENTRIES_DEFAULT 100
543 class RGWOmapAppend
: public RGWConsumerCR
<string
> {
544 RGWAsyncRadosProcessor
*async_rados
;
551 int num_pending_entries
;
552 list
<string
> pending_entries
;
554 map
<string
, bufferlist
> entries
;
556 uint64_t window_size
;
557 uint64_t total_entries
;
559 RGWOmapAppend(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
560 const rgw_raw_obj
& _obj
,
561 uint64_t _window_size
= OMAP_APPEND_MAX_ENTRIES_DEFAULT
);
562 int operate() override
;
563 void flush_pending();
564 bool append(const string
& s
);
567 uint64_t get_total_entries() {
568 return total_entries
;
571 const rgw_raw_obj
& get_obj() {
576 class RGWAsyncWait
: public RGWAsyncRadosRequest
{
582 int _send_request() override
{
583 Mutex::Locker
l(*lock
);
584 return cond
->WaitInterval(*lock
, interval
);
587 RGWAsyncWait(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, CephContext
*_cct
,
588 Mutex
*_lock
, Cond
*_cond
, int _secs
) : RGWAsyncRadosRequest(caller
, cn
),
590 lock(_lock
), cond(_cond
), interval(_secs
, 0) {}
593 Mutex::Locker
l(*lock
);
598 class RGWWaitCR
: public RGWSimpleCoroutine
{
600 RGWAsyncRadosProcessor
*async_rados
;
608 RGWWaitCR(RGWAsyncRadosProcessor
*_async_rados
, CephContext
*_cct
,
609 Mutex
*_lock
, Cond
*_cond
,
610 int _secs
) : RGWSimpleCoroutine(_cct
), cct(_cct
),
611 async_rados(_async_rados
), lock(_lock
), cond(_cond
), secs(_secs
), req(NULL
) {
613 ~RGWWaitCR() override
{
617 void request_cleanup() override
{
625 int send_request() override
{
626 req
= new RGWAsyncWait(this, stack
->create_completion_notifier(), cct
, lock
, cond
, secs
);
627 async_rados
->queue(req
);
631 int request_complete() override
{
632 return req
->get_ret_status();
640 class RGWShardedOmapCRManager
{
641 RGWAsyncRadosProcessor
*async_rados
;
647 vector
<RGWOmapAppend
*> shards
;
649 RGWShardedOmapCRManager(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
, RGWCoroutine
*_op
, int _num_shards
, const rgw_pool
& pool
, const string
& oid_prefix
)
650 : async_rados(_async_rados
),
651 store(_store
), op(_op
), num_shards(_num_shards
) {
652 shards
.reserve(num_shards
);
653 for (int i
= 0; i
< num_shards
; ++i
) {
654 char buf
[oid_prefix
.size() + 16];
655 snprintf(buf
, sizeof(buf
), "%s.%d", oid_prefix
.c_str(), i
);
656 RGWOmapAppend
*shard
= new RGWOmapAppend(async_rados
, store
, rgw_raw_obj(pool
, buf
));
658 shards
.push_back(shard
);
659 op
->spawn(shard
, false);
663 ~RGWShardedOmapCRManager() {
664 for (auto shard
: shards
) {
669 bool append(const string
& entry
, int shard_id
) {
670 return shards
[shard_id
]->append(entry
);
674 for (vector
<RGWOmapAppend
*>::iterator iter
= shards
.begin(); iter
!= shards
.end(); ++iter
) {
675 success
&= ((*iter
)->finish() && (!(*iter
)->is_error()));
680 uint64_t get_total_entries(int shard_id
) {
681 return shards
[shard_id
]->get_total_entries();
685 class RGWAsyncGetBucketInstanceInfo
: public RGWAsyncRadosRequest
{
688 RGWBucketInfo
*bucket_info
;
691 int _send_request() override
;
693 RGWAsyncGetBucketInstanceInfo(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
,
694 RGWRados
*_store
, const rgw_bucket
& bucket
,
695 RGWBucketInfo
*_bucket_info
)
696 : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
697 bucket(bucket
), bucket_info(_bucket_info
) {}
700 class RGWGetBucketInstanceInfoCR
: public RGWSimpleCoroutine
{
701 RGWAsyncRadosProcessor
*async_rados
;
704 RGWBucketInfo
*bucket_info
;
706 RGWAsyncGetBucketInstanceInfo
*req
;
709 RGWGetBucketInstanceInfoCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
710 const rgw_bucket
& bucket
, RGWBucketInfo
*_bucket_info
)
711 : RGWSimpleCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
712 bucket(bucket
), bucket_info(_bucket_info
), req(NULL
) {}
713 ~RGWGetBucketInstanceInfoCR() override
{
716 void request_cleanup() override
{
723 int send_request() override
{
724 req
= new RGWAsyncGetBucketInstanceInfo(this, stack
->create_completion_notifier(), store
, bucket
, bucket_info
);
725 async_rados
->queue(req
);
728 int request_complete() override
{
729 return req
->get_ret_status();
733 class RGWAsyncFetchRemoteObj
: public RGWAsyncRadosRequest
{
737 RGWBucketInfo bucket_info
;
740 uint64_t versioned_epoch
;
745 rgw_zone_set
*zones_trace
;
748 int _send_request() override
;
750 RGWAsyncFetchRemoteObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
751 const string
& _source_zone
,
752 RGWBucketInfo
& _bucket_info
,
753 const rgw_obj_key
& _key
,
754 uint64_t _versioned_epoch
,
755 bool _if_newer
, rgw_zone_set
*_zones_trace
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
756 source_zone(_source_zone
),
757 bucket_info(_bucket_info
),
759 versioned_epoch(_versioned_epoch
),
760 copy_if_newer(_if_newer
), zones_trace(_zones_trace
) {}
763 class RGWFetchRemoteObjCR
: public RGWSimpleCoroutine
{
765 RGWAsyncRadosProcessor
*async_rados
;
769 RGWBucketInfo bucket_info
;
772 uint64_t versioned_epoch
;
778 RGWAsyncFetchRemoteObj
*req
;
779 rgw_zone_set
*zones_trace
;
782 RGWFetchRemoteObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
783 const string
& _source_zone
,
784 RGWBucketInfo
& _bucket_info
,
785 const rgw_obj_key
& _key
,
786 uint64_t _versioned_epoch
,
787 bool _if_newer
, rgw_zone_set
*_zones_trace
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
788 async_rados(_async_rados
), store(_store
),
789 source_zone(_source_zone
),
790 bucket_info(_bucket_info
),
792 versioned_epoch(_versioned_epoch
),
793 copy_if_newer(_if_newer
), req(NULL
), zones_trace(_zones_trace
) {}
796 ~RGWFetchRemoteObjCR() override
{
800 void request_cleanup() override
{
807 int send_request() override
{
808 req
= new RGWAsyncFetchRemoteObj(this, stack
->create_completion_notifier(), store
, source_zone
, bucket_info
,
809 key
, versioned_epoch
, copy_if_newer
, zones_trace
);
810 async_rados
->queue(req
);
814 int request_complete() override
{
815 return req
->get_ret_status();
819 class RGWAsyncStatRemoteObj
: public RGWAsyncRadosRequest
{
823 RGWBucketInfo bucket_info
;
827 ceph::real_time
*pmtime
;
829 map
<string
, bufferlist
> *pattrs
;
832 int _send_request() override
;
834 RGWAsyncStatRemoteObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
835 const string
& _source_zone
,
836 RGWBucketInfo
& _bucket_info
,
837 const rgw_obj_key
& _key
,
838 ceph::real_time
*_pmtime
,
840 map
<string
, bufferlist
> *_pattrs
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
841 source_zone(_source_zone
),
842 bucket_info(_bucket_info
),
849 class RGWStatRemoteObjCR
: public RGWSimpleCoroutine
{
851 RGWAsyncRadosProcessor
*async_rados
;
855 RGWBucketInfo bucket_info
;
859 ceph::real_time
*pmtime
;
861 map
<string
, bufferlist
> *pattrs
;
863 RGWAsyncStatRemoteObj
*req
;
866 RGWStatRemoteObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
867 const string
& _source_zone
,
868 RGWBucketInfo
& _bucket_info
,
869 const rgw_obj_key
& _key
,
870 ceph::real_time
*_pmtime
,
872 map
<string
, bufferlist
> *_pattrs
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
873 async_rados(_async_rados
), store(_store
),
874 source_zone(_source_zone
),
875 bucket_info(_bucket_info
),
883 ~RGWStatRemoteObjCR() override
{
887 void request_cleanup() override
{
894 int send_request() override
{
895 req
= new RGWAsyncStatRemoteObj(this, stack
->create_completion_notifier(), store
, source_zone
,
896 bucket_info
, key
, pmtime
, psize
, pattrs
);
897 async_rados
->queue(req
);
901 int request_complete() override
{
902 return req
->get_ret_status();
906 class RGWAsyncRemoveObj
: public RGWAsyncRadosRequest
{
910 RGWBucketInfo bucket_info
;
914 string owner_display_name
;
916 uint64_t versioned_epoch
;
917 string marker_version_id
;
920 ceph::real_time timestamp
;
921 rgw_zone_set
*zones_trace
;
924 int _send_request() override
;
926 RGWAsyncRemoveObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
927 const string
& _source_zone
,
928 RGWBucketInfo
& _bucket_info
,
929 const rgw_obj_key
& _key
,
930 const string
& _owner
,
931 const string
& _owner_display_name
,
933 uint64_t _versioned_epoch
,
936 real_time
& _timestamp
,
937 rgw_zone_set
* _zones_trace
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
938 source_zone(_source_zone
),
939 bucket_info(_bucket_info
),
942 owner_display_name(_owner_display_name
),
943 versioned(_versioned
),
944 versioned_epoch(_versioned_epoch
),
945 del_if_older(_if_older
),
946 timestamp(_timestamp
), zones_trace(_zones_trace
) {
947 if (_delete_marker
) {
948 marker_version_id
= key
.instance
;
953 class RGWRemoveObjCR
: public RGWSimpleCoroutine
{
955 RGWAsyncRadosProcessor
*async_rados
;
959 RGWBucketInfo bucket_info
;
963 uint64_t versioned_epoch
;
966 string owner_display_name
;
971 RGWAsyncRemoveObj
*req
;
973 rgw_zone_set
*zones_trace
;
976 RGWRemoveObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
977 const string
& _source_zone
,
978 RGWBucketInfo
& _bucket_info
,
979 const rgw_obj_key
& _key
,
981 uint64_t _versioned_epoch
,
983 string
*_owner_display_name
,
985 real_time
*_timestamp
,
986 rgw_zone_set
*_zones_trace
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
987 async_rados(_async_rados
), store(_store
),
988 source_zone(_source_zone
),
989 bucket_info(_bucket_info
),
991 versioned(_versioned
),
992 versioned_epoch(_versioned_epoch
),
993 delete_marker(_delete_marker
), req(NULL
), zones_trace(_zones_trace
) {
994 del_if_older
= (_timestamp
!= NULL
);
996 timestamp
= *_timestamp
;
1003 if (_owner_display_name
) {
1004 owner_display_name
= *_owner_display_name
;
1007 ~RGWRemoveObjCR() override
{
1011 void request_cleanup() override
{
1018 int send_request() override
{
1019 req
= new RGWAsyncRemoveObj(this, stack
->create_completion_notifier(), store
, source_zone
, bucket_info
,
1020 key
, owner
, owner_display_name
, versioned
, versioned_epoch
,
1021 delete_marker
, del_if_older
, timestamp
, zones_trace
);
1022 async_rados
->queue(req
);
1026 int request_complete() override
{
1027 return req
->get_ret_status();
1031 class RGWContinuousLeaseCR
: public RGWCoroutine
{
1032 RGWAsyncRadosProcessor
*async_rados
;
1035 const rgw_raw_obj obj
;
1037 const string lock_name
;
1038 const string cookie
;
1043 std::atomic
<bool> going_down
= { false };
1046 RGWCoroutine
*caller
;
1048 bool aborted
{false};
1051 RGWContinuousLeaseCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
1052 const rgw_raw_obj
& _obj
,
1053 const string
& _lock_name
, int _interval
, RGWCoroutine
*_caller
)
1054 : RGWCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
1055 obj(_obj
), lock_name(_lock_name
),
1056 cookie(RGWSimpleRadosLockCR::gen_random_cookie(cct
)),
1057 interval(_interval
), lock("RGWContinuousLeaseCR"), caller(_caller
)
1060 int operate() override
;
1063 Mutex::Locker
l(lock
);
1067 void set_locked(bool status
) {
1068 Mutex::Locker
l(lock
);
1082 class RGWRadosTimelogAddCR
: public RGWSimpleCoroutine
{
1084 list
<cls_log_entry
> entries
;
1088 RGWAioCompletionNotifier
*cn
;
1091 RGWRadosTimelogAddCR(RGWRados
*_store
, const string
& _oid
,
1092 const cls_log_entry
& entry
);
1093 ~RGWRadosTimelogAddCR() override
;
1095 int send_request() override
;
1096 int request_complete() override
;
1099 class RGWRadosTimelogTrimCR
: public RGWSimpleCoroutine
{
1101 RGWAioCompletionNotifier
*cn
{nullptr};
1104 real_time start_time
;
1106 std::string from_marker
;
1107 std::string to_marker
;
1110 RGWRadosTimelogTrimCR(RGWRados
*store
, const std::string
& oid
,
1111 const real_time
& start_time
, const real_time
& end_time
,
1112 const std::string
& from_marker
,
1113 const std::string
& to_marker
);
1114 ~RGWRadosTimelogTrimCR() override
;
1116 int send_request() override
;
1117 int request_complete() override
;
1120 // wrapper to update last_trim_marker on success
1121 class RGWSyncLogTrimCR
: public RGWRadosTimelogTrimCR
{
1123 std::string
*last_trim_marker
;
1125 RGWSyncLogTrimCR(RGWRados
*store
, const std::string
& oid
,
1126 const std::string
& to_marker
, std::string
*last_trim_marker
);
1127 int request_complete() override
;
1130 class RGWAsyncStatObj
: public RGWAsyncRadosRequest
{
1132 RGWBucketInfo bucket_info
;
1137 RGWObjVersionTracker
*objv_tracker
;
1139 int _send_request() override
;
1141 RGWAsyncStatObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*store
,
1142 const RGWBucketInfo
& _bucket_info
, const rgw_obj
& obj
, uint64_t *psize
= nullptr,
1143 real_time
*pmtime
= nullptr, uint64_t *pepoch
= nullptr,
1144 RGWObjVersionTracker
*objv_tracker
= nullptr)
1145 : RGWAsyncRadosRequest(caller
, cn
), store(store
), obj(obj
), psize(psize
),
1146 pmtime(pmtime
), pepoch(pepoch
), objv_tracker(objv_tracker
) {}
1149 class RGWStatObjCR
: public RGWSimpleCoroutine
{
1151 RGWAsyncRadosProcessor
*async_rados
;
1152 RGWBucketInfo bucket_info
;
1157 RGWObjVersionTracker
*objv_tracker
;
1158 RGWAsyncStatObj
*req
= nullptr;
1160 RGWStatObjCR(RGWAsyncRadosProcessor
*async_rados
, RGWRados
*store
,
1161 const RGWBucketInfo
& _bucket_info
, const rgw_obj
& obj
, uint64_t *psize
= nullptr,
1162 real_time
* pmtime
= nullptr, uint64_t *pepoch
= nullptr,
1163 RGWObjVersionTracker
*objv_tracker
= nullptr);
1164 ~RGWStatObjCR() override
{
1167 void request_cleanup() override
;
1169 int send_request() override
;
1170 int request_complete() override
;