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 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
402 RGWRadosSetOmapKeysCR(RGWRados
*_store
,
403 const rgw_raw_obj
& _obj
,
404 map
<string
, bufferlist
>& _entries
);
406 int send_request() override
;
407 int request_complete() override
;
410 class RGWRadosGetOmapKeysCR
: public RGWSimpleCoroutine
{
414 map
<string
, bufferlist
> *entries
;
422 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
425 RGWRadosGetOmapKeysCR(RGWRados
*_store
,
426 const rgw_raw_obj
& _obj
,
427 const string
& _marker
,
428 map
<string
, bufferlist
> *_entries
, int _max_entries
);
430 int send_request() override
;
432 int request_complete() override
{
437 class RGWRadosRemoveOmapKeysCR
: public RGWSimpleCoroutine
{
446 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
449 RGWRadosRemoveOmapKeysCR(RGWRados
*_store
,
450 const rgw_raw_obj
& _obj
,
451 const set
<string
>& _keys
);
453 int send_request() override
;
455 int request_complete() override
;
458 class RGWRadosRemoveCR
: public RGWSimpleCoroutine
{
460 librados::IoCtx ioctx
;
461 const rgw_raw_obj obj
;
462 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
465 RGWRadosRemoveCR(RGWRados
*store
, const rgw_raw_obj
& obj
);
468 int request_complete();
471 class RGWSimpleRadosLockCR
: public RGWSimpleCoroutine
{
472 RGWAsyncRadosProcessor
*async_rados
;
480 RGWAsyncLockSystemObj
*req
;
483 RGWSimpleRadosLockCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
484 const rgw_raw_obj
& _obj
,
485 const string
& _lock_name
,
486 const string
& _cookie
,
488 ~RGWSimpleRadosLockCR() override
{
491 void request_cleanup() override
;
493 int send_request() override
;
494 int request_complete() override
;
496 static std::string
gen_random_cookie(CephContext
* cct
) {
497 #define COOKIE_LEN 16
498 char buf
[COOKIE_LEN
+ 1];
499 gen_rand_alphanumeric(cct
, buf
, sizeof(buf
) - 1);
504 class RGWSimpleRadosUnlockCR
: public RGWSimpleCoroutine
{
505 RGWAsyncRadosProcessor
*async_rados
;
512 RGWAsyncUnlockSystemObj
*req
;
515 RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
516 const rgw_raw_obj
& _obj
,
517 const string
& _lock_name
,
518 const string
& _cookie
);
519 ~RGWSimpleRadosUnlockCR() override
{
522 void request_cleanup() override
;
524 int send_request() override
;
525 int request_complete() override
;
528 #define OMAP_APPEND_MAX_ENTRIES_DEFAULT 100
530 class RGWOmapAppend
: public RGWConsumerCR
<string
> {
531 RGWAsyncRadosProcessor
*async_rados
;
538 int num_pending_entries
;
539 list
<string
> pending_entries
;
541 map
<string
, bufferlist
> entries
;
543 uint64_t window_size
;
544 uint64_t total_entries
;
546 RGWOmapAppend(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
547 const rgw_raw_obj
& _obj
,
548 uint64_t _window_size
= OMAP_APPEND_MAX_ENTRIES_DEFAULT
);
549 int operate() override
;
550 void flush_pending();
551 bool append(const string
& s
);
554 uint64_t get_total_entries() {
555 return total_entries
;
558 const rgw_raw_obj
& get_obj() {
563 class RGWAsyncWait
: public RGWAsyncRadosRequest
{
569 int _send_request() override
{
570 Mutex::Locker
l(*lock
);
571 return cond
->WaitInterval(*lock
, interval
);
574 RGWAsyncWait(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, CephContext
*_cct
,
575 Mutex
*_lock
, Cond
*_cond
, int _secs
) : RGWAsyncRadosRequest(caller
, cn
),
577 lock(_lock
), cond(_cond
), interval(_secs
, 0) {}
580 Mutex::Locker
l(*lock
);
585 class RGWWaitCR
: public RGWSimpleCoroutine
{
587 RGWAsyncRadosProcessor
*async_rados
;
595 RGWWaitCR(RGWAsyncRadosProcessor
*_async_rados
, CephContext
*_cct
,
596 Mutex
*_lock
, Cond
*_cond
,
597 int _secs
) : RGWSimpleCoroutine(_cct
), cct(_cct
),
598 async_rados(_async_rados
), lock(_lock
), cond(_cond
), secs(_secs
), req(NULL
) {
600 ~RGWWaitCR() override
{
604 void request_cleanup() override
{
612 int send_request() override
{
613 req
= new RGWAsyncWait(this, stack
->create_completion_notifier(), cct
, lock
, cond
, secs
);
614 async_rados
->queue(req
);
618 int request_complete() override
{
619 return req
->get_ret_status();
627 class RGWShardedOmapCRManager
{
628 RGWAsyncRadosProcessor
*async_rados
;
634 vector
<RGWOmapAppend
*> shards
;
636 RGWShardedOmapCRManager(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
, RGWCoroutine
*_op
, int _num_shards
, const rgw_pool
& pool
, const string
& oid_prefix
)
637 : async_rados(_async_rados
),
638 store(_store
), op(_op
), num_shards(_num_shards
) {
639 shards
.reserve(num_shards
);
640 for (int i
= 0; i
< num_shards
; ++i
) {
641 char buf
[oid_prefix
.size() + 16];
642 snprintf(buf
, sizeof(buf
), "%s.%d", oid_prefix
.c_str(), i
);
643 RGWOmapAppend
*shard
= new RGWOmapAppend(async_rados
, store
, rgw_raw_obj(pool
, buf
));
645 shards
.push_back(shard
);
646 op
->spawn(shard
, false);
650 ~RGWShardedOmapCRManager() {
651 for (auto shard
: shards
) {
656 bool append(const string
& entry
, int shard_id
) {
657 return shards
[shard_id
]->append(entry
);
661 for (vector
<RGWOmapAppend
*>::iterator iter
= shards
.begin(); iter
!= shards
.end(); ++iter
) {
662 success
&= ((*iter
)->finish() && (!(*iter
)->is_error()));
667 uint64_t get_total_entries(int shard_id
) {
668 return shards
[shard_id
]->get_total_entries();
672 class RGWAsyncGetBucketInstanceInfo
: public RGWAsyncRadosRequest
{
675 RGWBucketInfo
*bucket_info
;
678 int _send_request() override
;
680 RGWAsyncGetBucketInstanceInfo(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
,
681 RGWRados
*_store
, const rgw_bucket
& bucket
,
682 RGWBucketInfo
*_bucket_info
)
683 : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
684 bucket(bucket
), bucket_info(_bucket_info
) {}
687 class RGWGetBucketInstanceInfoCR
: public RGWSimpleCoroutine
{
688 RGWAsyncRadosProcessor
*async_rados
;
691 RGWBucketInfo
*bucket_info
;
693 RGWAsyncGetBucketInstanceInfo
*req
;
696 RGWGetBucketInstanceInfoCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
697 const rgw_bucket
& bucket
, RGWBucketInfo
*_bucket_info
)
698 : RGWSimpleCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
699 bucket(bucket
), bucket_info(_bucket_info
), req(NULL
) {}
700 ~RGWGetBucketInstanceInfoCR() override
{
703 void request_cleanup() override
{
710 int send_request() override
{
711 req
= new RGWAsyncGetBucketInstanceInfo(this, stack
->create_completion_notifier(), store
, bucket
, bucket_info
);
712 async_rados
->queue(req
);
715 int request_complete() override
{
716 return req
->get_ret_status();
720 class RGWAsyncFetchRemoteObj
: public RGWAsyncRadosRequest
{
724 RGWBucketInfo bucket_info
;
727 uint64_t versioned_epoch
;
732 rgw_zone_set
*zones_trace
;
735 int _send_request() override
;
737 RGWAsyncFetchRemoteObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
738 const string
& _source_zone
,
739 RGWBucketInfo
& _bucket_info
,
740 const rgw_obj_key
& _key
,
741 uint64_t _versioned_epoch
,
742 bool _if_newer
, rgw_zone_set
*_zones_trace
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
743 source_zone(_source_zone
),
744 bucket_info(_bucket_info
),
746 versioned_epoch(_versioned_epoch
),
747 copy_if_newer(_if_newer
), zones_trace(_zones_trace
) {}
750 class RGWFetchRemoteObjCR
: public RGWSimpleCoroutine
{
752 RGWAsyncRadosProcessor
*async_rados
;
756 RGWBucketInfo bucket_info
;
759 uint64_t versioned_epoch
;
765 RGWAsyncFetchRemoteObj
*req
;
766 rgw_zone_set
*zones_trace
;
769 RGWFetchRemoteObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
770 const string
& _source_zone
,
771 RGWBucketInfo
& _bucket_info
,
772 const rgw_obj_key
& _key
,
773 uint64_t _versioned_epoch
,
774 bool _if_newer
, rgw_zone_set
*_zones_trace
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
775 async_rados(_async_rados
), store(_store
),
776 source_zone(_source_zone
),
777 bucket_info(_bucket_info
),
779 versioned_epoch(_versioned_epoch
),
780 copy_if_newer(_if_newer
), req(NULL
), zones_trace(_zones_trace
) {}
783 ~RGWFetchRemoteObjCR() override
{
787 void request_cleanup() override
{
794 int send_request() override
{
795 req
= new RGWAsyncFetchRemoteObj(this, stack
->create_completion_notifier(), store
, source_zone
, bucket_info
,
796 key
, versioned_epoch
, copy_if_newer
, zones_trace
);
797 async_rados
->queue(req
);
801 int request_complete() override
{
802 return req
->get_ret_status();
806 class RGWAsyncStatRemoteObj
: public RGWAsyncRadosRequest
{
810 RGWBucketInfo bucket_info
;
814 ceph::real_time
*pmtime
;
816 map
<string
, bufferlist
> *pattrs
;
819 int _send_request() override
;
821 RGWAsyncStatRemoteObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
822 const string
& _source_zone
,
823 RGWBucketInfo
& _bucket_info
,
824 const rgw_obj_key
& _key
,
825 ceph::real_time
*_pmtime
,
827 map
<string
, bufferlist
> *_pattrs
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
828 source_zone(_source_zone
),
829 bucket_info(_bucket_info
),
836 class RGWStatRemoteObjCR
: public RGWSimpleCoroutine
{
838 RGWAsyncRadosProcessor
*async_rados
;
842 RGWBucketInfo bucket_info
;
846 ceph::real_time
*pmtime
;
848 map
<string
, bufferlist
> *pattrs
;
850 RGWAsyncStatRemoteObj
*req
;
853 RGWStatRemoteObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
854 const string
& _source_zone
,
855 RGWBucketInfo
& _bucket_info
,
856 const rgw_obj_key
& _key
,
857 ceph::real_time
*_pmtime
,
859 map
<string
, bufferlist
> *_pattrs
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
860 async_rados(_async_rados
), store(_store
),
861 source_zone(_source_zone
),
862 bucket_info(_bucket_info
),
870 ~RGWStatRemoteObjCR() override
{
874 void request_cleanup() override
{
881 int send_request() override
{
882 req
= new RGWAsyncStatRemoteObj(this, stack
->create_completion_notifier(), store
, source_zone
,
883 bucket_info
, key
, pmtime
, psize
, pattrs
);
884 async_rados
->queue(req
);
888 int request_complete() override
{
889 return req
->get_ret_status();
893 class RGWAsyncRemoveObj
: public RGWAsyncRadosRequest
{
897 RGWBucketInfo bucket_info
;
901 string owner_display_name
;
903 uint64_t versioned_epoch
;
904 string marker_version_id
;
907 ceph::real_time timestamp
;
908 rgw_zone_set
*zones_trace
;
911 int _send_request() override
;
913 RGWAsyncRemoveObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
914 const string
& _source_zone
,
915 RGWBucketInfo
& _bucket_info
,
916 const rgw_obj_key
& _key
,
917 const string
& _owner
,
918 const string
& _owner_display_name
,
920 uint64_t _versioned_epoch
,
923 real_time
& _timestamp
,
924 rgw_zone_set
* _zones_trace
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
925 source_zone(_source_zone
),
926 bucket_info(_bucket_info
),
929 owner_display_name(_owner_display_name
),
930 versioned(_versioned
),
931 versioned_epoch(_versioned_epoch
),
932 del_if_older(_if_older
),
933 timestamp(_timestamp
), zones_trace(_zones_trace
) {
934 if (_delete_marker
) {
935 marker_version_id
= key
.instance
;
940 class RGWRemoveObjCR
: public RGWSimpleCoroutine
{
942 RGWAsyncRadosProcessor
*async_rados
;
946 RGWBucketInfo bucket_info
;
950 uint64_t versioned_epoch
;
953 string owner_display_name
;
958 RGWAsyncRemoveObj
*req
;
960 rgw_zone_set
*zones_trace
;
963 RGWRemoveObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
964 const string
& _source_zone
,
965 RGWBucketInfo
& _bucket_info
,
966 const rgw_obj_key
& _key
,
968 uint64_t _versioned_epoch
,
970 string
*_owner_display_name
,
972 real_time
*_timestamp
,
973 rgw_zone_set
*_zones_trace
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
974 async_rados(_async_rados
), store(_store
),
975 source_zone(_source_zone
),
976 bucket_info(_bucket_info
),
978 versioned(_versioned
),
979 versioned_epoch(_versioned_epoch
),
980 delete_marker(_delete_marker
), req(NULL
), zones_trace(_zones_trace
) {
981 del_if_older
= (_timestamp
!= NULL
);
983 timestamp
= *_timestamp
;
990 if (_owner_display_name
) {
991 owner_display_name
= *_owner_display_name
;
994 ~RGWRemoveObjCR() override
{
998 void request_cleanup() override
{
1005 int send_request() override
{
1006 req
= new RGWAsyncRemoveObj(this, stack
->create_completion_notifier(), store
, source_zone
, bucket_info
,
1007 key
, owner
, owner_display_name
, versioned
, versioned_epoch
,
1008 delete_marker
, del_if_older
, timestamp
, zones_trace
);
1009 async_rados
->queue(req
);
1013 int request_complete() override
{
1014 return req
->get_ret_status();
1018 class RGWContinuousLeaseCR
: public RGWCoroutine
{
1019 RGWAsyncRadosProcessor
*async_rados
;
1022 const rgw_raw_obj obj
;
1024 const string lock_name
;
1025 const string cookie
;
1030 std::atomic
<bool> going_down
= { false };
1033 RGWCoroutine
*caller
;
1035 bool aborted
{false};
1038 RGWContinuousLeaseCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
1039 const rgw_raw_obj
& _obj
,
1040 const string
& _lock_name
, int _interval
, RGWCoroutine
*_caller
)
1041 : RGWCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
1042 obj(_obj
), lock_name(_lock_name
),
1043 cookie(RGWSimpleRadosLockCR::gen_random_cookie(cct
)),
1044 interval(_interval
), lock("RGWContinuousLeaseCR"), caller(_caller
)
1047 int operate() override
;
1050 Mutex::Locker
l(lock
);
1054 void set_locked(bool status
) {
1055 Mutex::Locker
l(lock
);
1069 class RGWRadosTimelogAddCR
: public RGWSimpleCoroutine
{
1071 list
<cls_log_entry
> entries
;
1075 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
1078 RGWRadosTimelogAddCR(RGWRados
*_store
, const string
& _oid
,
1079 const cls_log_entry
& entry
);
1081 int send_request() override
;
1082 int request_complete() override
;
1085 class RGWRadosTimelogTrimCR
: public RGWSimpleCoroutine
{
1087 boost::intrusive_ptr
<RGWAioCompletionNotifier
> cn
;
1090 real_time start_time
;
1092 std::string from_marker
;
1093 std::string to_marker
;
1096 RGWRadosTimelogTrimCR(RGWRados
*store
, const std::string
& oid
,
1097 const real_time
& start_time
, const real_time
& end_time
,
1098 const std::string
& from_marker
,
1099 const std::string
& to_marker
);
1101 int send_request() override
;
1102 int request_complete() override
;
1105 // wrapper to update last_trim_marker on success
1106 class RGWSyncLogTrimCR
: public RGWRadosTimelogTrimCR
{
1108 std::string
*last_trim_marker
;
1110 RGWSyncLogTrimCR(RGWRados
*store
, const std::string
& oid
,
1111 const std::string
& to_marker
, std::string
*last_trim_marker
);
1112 int request_complete() override
;
1115 class RGWAsyncStatObj
: public RGWAsyncRadosRequest
{
1117 RGWBucketInfo bucket_info
;
1122 RGWObjVersionTracker
*objv_tracker
;
1124 int _send_request() override
;
1126 RGWAsyncStatObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*store
,
1127 const RGWBucketInfo
& _bucket_info
, const rgw_obj
& obj
, uint64_t *psize
= nullptr,
1128 real_time
*pmtime
= nullptr, uint64_t *pepoch
= nullptr,
1129 RGWObjVersionTracker
*objv_tracker
= nullptr)
1130 : RGWAsyncRadosRequest(caller
, cn
), store(store
), obj(obj
), psize(psize
),
1131 pmtime(pmtime
), pepoch(pepoch
), objv_tracker(objv_tracker
) {}
1134 class RGWStatObjCR
: public RGWSimpleCoroutine
{
1136 RGWAsyncRadosProcessor
*async_rados
;
1137 RGWBucketInfo bucket_info
;
1142 RGWObjVersionTracker
*objv_tracker
;
1143 RGWAsyncStatObj
*req
= nullptr;
1145 RGWStatObjCR(RGWAsyncRadosProcessor
*async_rados
, RGWRados
*store
,
1146 const RGWBucketInfo
& _bucket_info
, const rgw_obj
& obj
, uint64_t *psize
= nullptr,
1147 real_time
* pmtime
= nullptr, uint64_t *pepoch
= nullptr,
1148 RGWObjVersionTracker
*objv_tracker
= nullptr);
1149 ~RGWStatObjCR() override
{
1152 void request_cleanup() override
;
1154 int send_request() override
;
1155 int request_complete() override
;