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
;
747 int _send_request() override
;
749 RGWAsyncFetchRemoteObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
750 const string
& _source_zone
,
751 RGWBucketInfo
& _bucket_info
,
752 const rgw_obj_key
& _key
,
753 uint64_t _versioned_epoch
,
754 bool _if_newer
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
755 source_zone(_source_zone
),
756 bucket_info(_bucket_info
),
758 versioned_epoch(_versioned_epoch
),
759 copy_if_newer(_if_newer
) {}
762 class RGWFetchRemoteObjCR
: public RGWSimpleCoroutine
{
764 RGWAsyncRadosProcessor
*async_rados
;
768 RGWBucketInfo bucket_info
;
771 uint64_t versioned_epoch
;
777 RGWAsyncFetchRemoteObj
*req
;
780 RGWFetchRemoteObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
781 const string
& _source_zone
,
782 RGWBucketInfo
& _bucket_info
,
783 const rgw_obj_key
& _key
,
784 uint64_t _versioned_epoch
,
785 bool _if_newer
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
786 async_rados(_async_rados
), store(_store
),
787 source_zone(_source_zone
),
788 bucket_info(_bucket_info
),
790 versioned_epoch(_versioned_epoch
),
791 copy_if_newer(_if_newer
), req(NULL
) {}
794 ~RGWFetchRemoteObjCR() override
{
798 void request_cleanup() override
{
805 int send_request() override
{
806 req
= new RGWAsyncFetchRemoteObj(this, stack
->create_completion_notifier(), store
, source_zone
, bucket_info
,
807 key
, versioned_epoch
, copy_if_newer
);
808 async_rados
->queue(req
);
812 int request_complete() override
{
813 return req
->get_ret_status();
817 class RGWAsyncStatRemoteObj
: public RGWAsyncRadosRequest
{
821 RGWBucketInfo bucket_info
;
825 ceph::real_time
*pmtime
;
827 map
<string
, bufferlist
> *pattrs
;
830 int _send_request() override
;
832 RGWAsyncStatRemoteObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
833 const string
& _source_zone
,
834 RGWBucketInfo
& _bucket_info
,
835 const rgw_obj_key
& _key
,
836 ceph::real_time
*_pmtime
,
838 map
<string
, bufferlist
> *_pattrs
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
839 source_zone(_source_zone
),
840 bucket_info(_bucket_info
),
847 class RGWStatRemoteObjCR
: public RGWSimpleCoroutine
{
849 RGWAsyncRadosProcessor
*async_rados
;
853 RGWBucketInfo bucket_info
;
857 ceph::real_time
*pmtime
;
859 map
<string
, bufferlist
> *pattrs
;
861 RGWAsyncStatRemoteObj
*req
;
864 RGWStatRemoteObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
865 const string
& _source_zone
,
866 RGWBucketInfo
& _bucket_info
,
867 const rgw_obj_key
& _key
,
868 ceph::real_time
*_pmtime
,
870 map
<string
, bufferlist
> *_pattrs
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
871 async_rados(_async_rados
), store(_store
),
872 source_zone(_source_zone
),
873 bucket_info(_bucket_info
),
881 ~RGWStatRemoteObjCR() override
{
885 void request_cleanup() override
{
892 int send_request() override
{
893 req
= new RGWAsyncStatRemoteObj(this, stack
->create_completion_notifier(), store
, source_zone
,
894 bucket_info
, key
, pmtime
, psize
, pattrs
);
895 async_rados
->queue(req
);
899 int request_complete() override
{
900 return req
->get_ret_status();
904 class RGWAsyncRemoveObj
: public RGWAsyncRadosRequest
{
908 RGWBucketInfo bucket_info
;
912 string owner_display_name
;
914 uint64_t versioned_epoch
;
915 string marker_version_id
;
918 ceph::real_time timestamp
;
921 int _send_request() override
;
923 RGWAsyncRemoveObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*_store
,
924 const string
& _source_zone
,
925 RGWBucketInfo
& _bucket_info
,
926 const rgw_obj_key
& _key
,
927 const string
& _owner
,
928 const string
& _owner_display_name
,
930 uint64_t _versioned_epoch
,
933 real_time
& _timestamp
) : RGWAsyncRadosRequest(caller
, cn
), store(_store
),
934 source_zone(_source_zone
),
935 bucket_info(_bucket_info
),
938 owner_display_name(_owner_display_name
),
939 versioned(_versioned
),
940 versioned_epoch(_versioned_epoch
),
941 del_if_older(_if_older
),
942 timestamp(_timestamp
) {
943 if (_delete_marker
) {
944 marker_version_id
= key
.instance
;
949 class RGWRemoveObjCR
: public RGWSimpleCoroutine
{
951 RGWAsyncRadosProcessor
*async_rados
;
955 RGWBucketInfo bucket_info
;
959 uint64_t versioned_epoch
;
962 string owner_display_name
;
967 RGWAsyncRemoveObj
*req
;
970 RGWRemoveObjCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
971 const string
& _source_zone
,
972 RGWBucketInfo
& _bucket_info
,
973 const rgw_obj_key
& _key
,
975 uint64_t _versioned_epoch
,
977 string
*_owner_display_name
,
979 real_time
*_timestamp
) : RGWSimpleCoroutine(_store
->ctx()), cct(_store
->ctx()),
980 async_rados(_async_rados
), store(_store
),
981 source_zone(_source_zone
),
982 bucket_info(_bucket_info
),
984 versioned(_versioned
),
985 versioned_epoch(_versioned_epoch
),
986 delete_marker(_delete_marker
), req(NULL
) {
987 del_if_older
= (_timestamp
!= NULL
);
989 timestamp
= *_timestamp
;
996 if (_owner_display_name
) {
997 owner_display_name
= *_owner_display_name
;
1000 ~RGWRemoveObjCR() override
{
1004 void request_cleanup() override
{
1011 int send_request() override
{
1012 req
= new RGWAsyncRemoveObj(this, stack
->create_completion_notifier(), store
, source_zone
, bucket_info
,
1013 key
, owner
, owner_display_name
, versioned
, versioned_epoch
,
1014 delete_marker
, del_if_older
, timestamp
);
1015 async_rados
->queue(req
);
1019 int request_complete() override
{
1020 return req
->get_ret_status();
1024 class RGWContinuousLeaseCR
: public RGWCoroutine
{
1025 RGWAsyncRadosProcessor
*async_rados
;
1028 const rgw_raw_obj obj
;
1030 const string lock_name
;
1031 const string cookie
;
1036 std::atomic
<bool> going_down
= { false };
1039 RGWCoroutine
*caller
;
1041 bool aborted
{false};
1044 RGWContinuousLeaseCR(RGWAsyncRadosProcessor
*_async_rados
, RGWRados
*_store
,
1045 const rgw_raw_obj
& _obj
,
1046 const string
& _lock_name
, int _interval
, RGWCoroutine
*_caller
)
1047 : RGWCoroutine(_store
->ctx()), async_rados(_async_rados
), store(_store
),
1048 obj(_obj
), lock_name(_lock_name
),
1049 cookie(RGWSimpleRadosLockCR::gen_random_cookie(cct
)),
1050 interval(_interval
), lock("RGWContinuousLeaseCR"), caller(_caller
)
1053 int operate() override
;
1056 Mutex::Locker
l(lock
);
1060 void set_locked(bool status
) {
1061 Mutex::Locker
l(lock
);
1075 class RGWRadosTimelogAddCR
: public RGWSimpleCoroutine
{
1077 list
<cls_log_entry
> entries
;
1081 RGWAioCompletionNotifier
*cn
;
1084 RGWRadosTimelogAddCR(RGWRados
*_store
, const string
& _oid
,
1085 const cls_log_entry
& entry
);
1086 ~RGWRadosTimelogAddCR() override
;
1088 int send_request() override
;
1089 int request_complete() override
;
1092 class RGWRadosTimelogTrimCR
: public RGWSimpleCoroutine
{
1094 RGWAioCompletionNotifier
*cn
{nullptr};
1097 real_time start_time
;
1099 std::string from_marker
;
1100 std::string to_marker
;
1103 RGWRadosTimelogTrimCR(RGWRados
*store
, const std::string
& oid
,
1104 const real_time
& start_time
, const real_time
& end_time
,
1105 const std::string
& from_marker
,
1106 const std::string
& to_marker
);
1107 ~RGWRadosTimelogTrimCR() override
;
1109 int send_request() override
;
1110 int request_complete() override
;
1113 // wrapper to update last_trim_marker on success
1114 class RGWSyncLogTrimCR
: public RGWRadosTimelogTrimCR
{
1116 std::string
*last_trim_marker
;
1118 RGWSyncLogTrimCR(RGWRados
*store
, const std::string
& oid
,
1119 const std::string
& to_marker
, std::string
*last_trim_marker
);
1120 int request_complete() override
;
1123 class RGWAsyncStatObj
: public RGWAsyncRadosRequest
{
1125 RGWBucketInfo bucket_info
;
1130 RGWObjVersionTracker
*objv_tracker
;
1132 int _send_request() override
;
1134 RGWAsyncStatObj(RGWCoroutine
*caller
, RGWAioCompletionNotifier
*cn
, RGWRados
*store
,
1135 const RGWBucketInfo
& _bucket_info
, const rgw_obj
& obj
, uint64_t *psize
= nullptr,
1136 real_time
*pmtime
= nullptr, uint64_t *pepoch
= nullptr,
1137 RGWObjVersionTracker
*objv_tracker
= nullptr)
1138 : RGWAsyncRadosRequest(caller
, cn
), store(store
), obj(obj
), psize(psize
),
1139 pmtime(pmtime
), pepoch(pepoch
), objv_tracker(objv_tracker
) {}
1142 class RGWStatObjCR
: public RGWSimpleCoroutine
{
1144 RGWAsyncRadosProcessor
*async_rados
;
1145 RGWBucketInfo bucket_info
;
1150 RGWObjVersionTracker
*objv_tracker
;
1151 RGWAsyncStatObj
*req
= nullptr;
1153 RGWStatObjCR(RGWAsyncRadosProcessor
*async_rados
, RGWRados
*store
,
1154 const RGWBucketInfo
& _bucket_info
, const rgw_obj
& obj
, uint64_t *psize
= nullptr,
1155 real_time
* pmtime
= nullptr, uint64_t *pepoch
= nullptr,
1156 RGWObjVersionTracker
*objv_tracker
= nullptr);
1157 ~RGWStatObjCR() override
{
1160 void request_cleanup() override
;
1162 int send_request() override
;
1163 int request_complete() override
;