]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_cr_rados.cc
update sources to v12.2.3
[ceph.git] / ceph / src / rgw / rgw_cr_rados.cc
CommitLineData
7c673cae
FG
1#include "rgw_rados.h"
2#include "rgw_coroutine.h"
7c673cae
FG
3#include "rgw_cr_rados.h"
4
5#include "cls/lock/cls_lock_client.h"
b32b8144 6#include "cls/rgw/cls_rgw_client.h"
7c673cae 7
31f18b77
FG
8#include <boost/asio/yield.hpp>
9
7c673cae
FG
10#define dout_context g_ceph_context
11#define dout_subsys ceph_subsys_rgw
12
13bool RGWAsyncRadosProcessor::RGWWQ::_enqueue(RGWAsyncRadosRequest *req) {
14 if (processor->is_going_down()) {
15 return false;
16 }
17 req->get();
18 processor->m_req_queue.push_back(req);
19 dout(20) << "enqueued request req=" << hex << req << dec << dendl;
20 _dump_queue();
21 return true;
22}
23
24bool RGWAsyncRadosProcessor::RGWWQ::_empty() {
25 return processor->m_req_queue.empty();
26}
27
28RGWAsyncRadosRequest *RGWAsyncRadosProcessor::RGWWQ::_dequeue() {
29 if (processor->m_req_queue.empty())
30 return NULL;
31 RGWAsyncRadosRequest *req = processor->m_req_queue.front();
32 processor->m_req_queue.pop_front();
33 dout(20) << "dequeued request req=" << hex << req << dec << dendl;
34 _dump_queue();
35 return req;
36}
37
38void RGWAsyncRadosProcessor::RGWWQ::_process(RGWAsyncRadosRequest *req, ThreadPool::TPHandle& handle) {
39 processor->handle_request(req);
40 processor->req_throttle.put(1);
41}
42
43void RGWAsyncRadosProcessor::RGWWQ::_dump_queue() {
44 if (!g_conf->subsys.should_gather(ceph_subsys_rgw, 20)) {
45 return;
46 }
47 deque<RGWAsyncRadosRequest *>::iterator iter;
48 if (processor->m_req_queue.empty()) {
49 dout(20) << "RGWWQ: empty" << dendl;
50 return;
51 }
52 dout(20) << "RGWWQ:" << dendl;
53 for (iter = processor->m_req_queue.begin(); iter != processor->m_req_queue.end(); ++iter) {
54 dout(20) << "req: " << hex << *iter << dec << dendl;
55 }
56}
57
58RGWAsyncRadosProcessor::RGWAsyncRadosProcessor(RGWRados *_store, int num_threads)
59 : store(_store), m_tp(store->ctx(), "RGWAsyncRadosProcessor::m_tp", "rados_async", num_threads),
60 req_throttle(store->ctx(), "rgw_async_rados_ops", num_threads * 2),
61 req_wq(this, g_conf->rgw_op_thread_timeout,
62 g_conf->rgw_op_thread_suicide_timeout, &m_tp) {
63}
64
65void RGWAsyncRadosProcessor::start() {
66 m_tp.start();
67}
68
69void RGWAsyncRadosProcessor::stop() {
70 going_down = true;
71 m_tp.drain(&req_wq);
72 m_tp.stop();
73 for (auto iter = m_req_queue.begin(); iter != m_req_queue.end(); ++iter) {
74 (*iter)->put();
75 }
76}
77
78void RGWAsyncRadosProcessor::handle_request(RGWAsyncRadosRequest *req) {
79 req->send_request();
80 req->put();
81}
82
83void RGWAsyncRadosProcessor::queue(RGWAsyncRadosRequest *req) {
84 req_throttle.get(1);
85 req_wq.queue(req);
86}
87
88int RGWAsyncGetSystemObj::_send_request()
89{
90 return store->get_system_obj(*obj_ctx, read_state, objv_tracker, obj, *pbl, ofs, end, pattrs, NULL);
91}
92
93RGWAsyncGetSystemObj::RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjectCtx *_obj_ctx,
94 RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
95 bufferlist *_pbl, off_t _ofs, off_t _end) : RGWAsyncRadosRequest(caller, cn), store(_store), obj_ctx(_obj_ctx),
96 objv_tracker(_objv_tracker), obj(_obj), pbl(_pbl), pattrs(NULL),
97 ofs(_ofs), end(_end)
98{
99}
100
101int RGWSimpleRadosReadAttrsCR::send_request()
102{
103 req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(),
104 store, &obj_ctx, NULL,
105 obj,
106 &bl, 0, -1);
107 if (pattrs) {
108 req->set_read_attrs(pattrs);
109 }
110 async_rados->queue(req);
111 return 0;
112}
113
114int RGWSimpleRadosReadAttrsCR::request_complete()
115{
116 return req->get_ret_status();
117}
118
119int RGWAsyncPutSystemObj::_send_request()
120{
121 return store->put_system_obj_data(NULL, obj, bl, -1, exclusive, objv_tracker);
122}
123
124RGWAsyncPutSystemObj::RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
125 RGWObjVersionTracker *_objv_tracker, rgw_raw_obj& _obj,
126 bool _exclusive, bufferlist& _bl)
127 : RGWAsyncRadosRequest(caller, cn), store(_store), objv_tracker(_objv_tracker),
128 obj(_obj), exclusive(_exclusive), bl(_bl)
129{
130}
131
132int RGWAsyncPutSystemObjAttrs::_send_request()
133{
134 return store->system_obj_set_attrs(NULL, obj, *attrs, NULL, objv_tracker);
135}
136
137RGWAsyncPutSystemObjAttrs::RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
138 RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
139 map<string, bufferlist> *_attrs) : RGWAsyncRadosRequest(caller, cn), store(_store),
140 objv_tracker(_objv_tracker), obj(_obj),
141 attrs(_attrs)
142{
143}
144
145
146RGWOmapAppend::RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, const rgw_raw_obj& _obj,
147 uint64_t _window_size)
148 : RGWConsumerCR<string>(_store->ctx()), async_rados(_async_rados),
149 store(_store), obj(_obj), going_down(false), num_pending_entries(0), window_size(_window_size), total_entries(0)
150{
151}
152
153int RGWAsyncLockSystemObj::_send_request()
154{
155 rgw_rados_ref ref;
156 int r = store->get_raw_obj_ref(obj, &ref);
157 if (r < 0) {
158 lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
159 return r;
160 }
161
162 rados::cls::lock::Lock l(lock_name);
163 utime_t duration(duration_secs, 0);
164 l.set_duration(duration);
165 l.set_cookie(cookie);
166 l.set_renew(true);
167
168 return l.lock_exclusive(&ref.ioctx, ref.oid);
169}
170
171RGWAsyncLockSystemObj::RGWAsyncLockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
172 RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
173 const string& _name, const string& _cookie, uint32_t _duration_secs) : RGWAsyncRadosRequest(caller, cn), store(_store),
174 obj(_obj),
175 lock_name(_name),
176 cookie(_cookie),
177 duration_secs(_duration_secs)
178{
179}
180
181int RGWAsyncUnlockSystemObj::_send_request()
182{
183 rgw_rados_ref ref;
184 int r = store->get_raw_obj_ref(obj, &ref);
185 if (r < 0) {
186 lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
187 return r;
188 }
189
190 rados::cls::lock::Lock l(lock_name);
191
192 l.set_cookie(cookie);
193
194 return l.unlock(&ref.ioctx, ref.oid);
195}
196
197RGWAsyncUnlockSystemObj::RGWAsyncUnlockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
198 RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
199 const string& _name, const string& _cookie) : RGWAsyncRadosRequest(caller, cn), store(_store),
200 obj(_obj),
201 lock_name(_name), cookie(_cookie)
202{
203}
204
7c673cae
FG
205RGWRadosSetOmapKeysCR::RGWRadosSetOmapKeysCR(RGWRados *_store,
206 const rgw_raw_obj& _obj,
207 map<string, bufferlist>& _entries) : RGWSimpleCoroutine(_store->ctx()),
208 store(_store),
209 entries(_entries),
210 obj(_obj), cn(NULL)
211{
212 stringstream& s = set_description();
213 s << "set omap keys dest=" << obj << " keys=[" << s.str() << "]";
214 for (auto i = entries.begin(); i != entries.end(); ++i) {
215 if (i != entries.begin()) {
216 s << ", ";
217 }
218 s << i->first;
219 }
220 s << "]";
221}
222
7c673cae
FG
223int RGWRadosSetOmapKeysCR::send_request()
224{
225 int r = store->get_raw_obj_ref(obj, &ref);
226 if (r < 0) {
227 lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
228 return r;
229 }
230
231 set_status() << "sending request";
232
233 librados::ObjectWriteOperation op;
234 op.omap_set(entries);
235
236 cn = stack->create_completion_notifier();
7c673cae
FG
237 return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op);
238}
239
240int RGWRadosSetOmapKeysCR::request_complete()
241{
242 int r = cn->completion()->get_return_value();
243
244 set_status() << "request complete; ret=" << r;
245
246 return r;
247}
248
249RGWRadosGetOmapKeysCR::RGWRadosGetOmapKeysCR(RGWRados *_store,
250 const rgw_raw_obj& _obj,
251 const string& _marker,
252 map<string, bufferlist> *_entries, int _max_entries) : RGWSimpleCoroutine(_store->ctx()),
253 store(_store),
254 marker(_marker),
255 entries(_entries), max_entries(_max_entries), rval(0),
256 obj(_obj), cn(NULL)
257{
258 set_description() << "set omap keys dest=" << obj << " marker=" << marker;
259}
260
7c673cae
FG
261int RGWRadosGetOmapKeysCR::send_request() {
262 int r = store->get_raw_obj_ref(obj, &ref);
263 if (r < 0) {
264 lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
265 return r;
266 }
267
268 set_status() << "send request";
269
270 librados::ObjectReadOperation op;
271 op.omap_get_vals2(marker, max_entries, entries, nullptr, &rval);
272
273 cn = stack->create_completion_notifier();
274 return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op, NULL);
275}
276
277RGWRadosRemoveOmapKeysCR::RGWRadosRemoveOmapKeysCR(RGWRados *_store,
278 const rgw_raw_obj& _obj,
279 const set<string>& _keys) : RGWSimpleCoroutine(_store->ctx()),
280 store(_store),
281 keys(_keys),
282 obj(_obj), cn(NULL)
283{
284 set_description() << "remove omap keys dest=" << obj << " keys=" << keys;
285}
286
7c673cae
FG
287int RGWRadosRemoveOmapKeysCR::send_request() {
288 int r = store->get_raw_obj_ref(obj, &ref);
289 if (r < 0) {
290 lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
291 return r;
292 }
293
294 set_status() << "send request";
295
296 librados::ObjectWriteOperation op;
297 op.omap_rm_keys(keys);
298
299 cn = stack->create_completion_notifier();
300 return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op);
301}
302
224ce89b
WB
303int RGWRadosRemoveOmapKeysCR::request_complete()
304{
305 int r = cn->completion()->get_return_value();
306
307 set_status() << "request complete; ret=" << r;
308
309 return r;
310}
311
7c673cae
FG
312RGWRadosRemoveCR::RGWRadosRemoveCR(RGWRados *store, const rgw_raw_obj& obj)
313 : RGWSimpleCoroutine(store->ctx()), store(store), obj(obj)
314{
315 set_description() << "remove dest=" << obj;
316}
317
318int RGWRadosRemoveCR::send_request()
319{
320 auto rados = store->get_rados_handle();
321 int r = rados->ioctx_create(obj.pool.name.c_str(), ioctx);
322 if (r < 0) {
323 lderr(cct) << "ERROR: failed to open pool (" << obj.pool.name << ") ret=" << r << dendl;
324 return r;
325 }
326 ioctx.locator_set_key(obj.loc);
327
328 set_status() << "send request";
329
330 librados::ObjectWriteOperation op;
331 op.remove();
332
333 cn = stack->create_completion_notifier();
334 return ioctx.aio_operate(obj.oid, cn->completion(), &op);
335}
336
337int RGWRadosRemoveCR::request_complete()
338{
339 int r = cn->completion()->get_return_value();
340
341 set_status() << "request complete; ret=" << r;
342
343 return r;
344}
345
346RGWSimpleRadosLockCR::RGWSimpleRadosLockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
347 const rgw_raw_obj& _obj,
348 const string& _lock_name,
349 const string& _cookie,
350 uint32_t _duration) : RGWSimpleCoroutine(_store->ctx()),
351 async_rados(_async_rados),
352 store(_store),
353 lock_name(_lock_name),
354 cookie(_cookie),
355 duration(_duration),
356 obj(_obj),
357 req(NULL)
358{
359 set_description() << "rados lock dest=" << obj << " lock=" << lock_name << " cookie=" << cookie << " duration=" << duration;
360}
361
362void RGWSimpleRadosLockCR::request_cleanup()
363{
364 if (req) {
365 req->finish();
366 req = NULL;
367 }
368}
369
370int RGWSimpleRadosLockCR::send_request()
371{
372 set_status() << "sending request";
373 req = new RGWAsyncLockSystemObj(this, stack->create_completion_notifier(),
374 store, NULL, obj, lock_name, cookie, duration);
375 async_rados->queue(req);
376 return 0;
377}
378
379int RGWSimpleRadosLockCR::request_complete()
380{
381 set_status() << "request complete; ret=" << req->get_ret_status();
382 return req->get_ret_status();
383}
384
385RGWSimpleRadosUnlockCR::RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
386 const rgw_raw_obj& _obj,
387 const string& _lock_name,
388 const string& _cookie) : RGWSimpleCoroutine(_store->ctx()),
389 async_rados(_async_rados),
390 store(_store),
391 lock_name(_lock_name),
392 cookie(_cookie),
393 obj(_obj),
394 req(NULL)
395{
396 set_description() << "rados unlock dest=" << obj << " lock=" << lock_name << " cookie=" << cookie;
397}
398
399void RGWSimpleRadosUnlockCR::request_cleanup()
400{
401 if (req) {
402 req->finish();
403 req = NULL;
404 }
405}
406
407int RGWSimpleRadosUnlockCR::send_request()
408{
409 set_status() << "sending request";
410
411 req = new RGWAsyncUnlockSystemObj(this, stack->create_completion_notifier(),
412 store, NULL, obj, lock_name, cookie);
413 async_rados->queue(req);
414 return 0;
415}
416
417int RGWSimpleRadosUnlockCR::request_complete()
418{
419 set_status() << "request complete; ret=" << req->get_ret_status();
420 return req->get_ret_status();
421}
422
7c673cae
FG
423int RGWOmapAppend::operate() {
424 reenter(this) {
425 for (;;) {
426 if (!has_product() && going_down) {
427 set_status() << "going down";
428 break;
429 }
430 set_status() << "waiting for product";
431 yield wait_for_product();
432 yield {
433 string entry;
434 while (consume(&entry)) {
435 set_status() << "adding entry: " << entry;
436 entries[entry] = bufferlist();
437 if (entries.size() >= window_size) {
438 break;
439 }
440 }
441 if (entries.size() >= window_size || going_down) {
442 set_status() << "flushing to omap";
443 call(new RGWRadosSetOmapKeysCR(store, obj, entries));
444 entries.clear();
445 }
446 }
447 if (get_ret_status() < 0) {
448 ldout(cct, 0) << "ERROR: failed to store entries in omap" << dendl;
449 return set_state(RGWCoroutine_Error);
450 }
451 }
452 /* done with coroutine */
453 return set_state(RGWCoroutine_Done);
454 }
455 return 0;
456}
457
458void RGWOmapAppend::flush_pending() {
459 receive(pending_entries);
460 num_pending_entries = 0;
461}
462
463bool RGWOmapAppend::append(const string& s) {
464 if (is_done()) {
465 return false;
466 }
467 ++total_entries;
468 pending_entries.push_back(s);
469 if (++num_pending_entries >= (int)window_size) {
470 flush_pending();
471 }
472 return true;
473}
474
475bool RGWOmapAppend::finish() {
476 going_down = true;
477 flush_pending();
478 set_sleeping(false);
479 return (!is_done());
480}
481
482int RGWAsyncGetBucketInstanceInfo::_send_request()
483{
484 RGWObjectCtx obj_ctx(store);
b32b8144 485 int r = store->get_bucket_instance_from_oid(obj_ctx, oid, *bucket_info, NULL, NULL);
7c673cae
FG
486 if (r < 0) {
487 ldout(store->ctx(), 0) << "ERROR: failed to get bucket instance info for "
b32b8144 488 << oid << dendl;
7c673cae
FG
489 return r;
490 }
491
492 return 0;
493}
494
b32b8144
FG
495RGWRadosBILogTrimCR::RGWRadosBILogTrimCR(RGWRados *store,
496 const RGWBucketInfo& bucket_info,
497 int shard_id,
498 const std::string& start_marker,
499 const std::string& end_marker)
500 : RGWSimpleCoroutine(store->ctx()), bs(store),
501 start_marker(BucketIndexShardsManager::get_shard_marker(start_marker)),
502 end_marker(BucketIndexShardsManager::get_shard_marker(end_marker))
503{
504 bs.init(bucket_info, shard_id);
505}
506
507int RGWRadosBILogTrimCR::send_request()
508{
509 bufferlist in;
510 cls_rgw_bi_log_trim_op call;
511 call.start_marker = std::move(start_marker);
512 call.end_marker = std::move(end_marker);
513 ::encode(call, in);
514
515 librados::ObjectWriteOperation op;
516 op.exec(RGW_CLASS, RGW_BI_LOG_TRIM, in);
517
518 cn = stack->create_completion_notifier();
519 return bs.index_ctx.aio_operate(bs.bucket_obj, cn->completion(), &op);
520}
521
522int RGWRadosBILogTrimCR::request_complete()
523{
524 int r = cn->completion()->get_return_value();
525 set_status() << "request complete; ret=" << r;
526 return r;
527}
528
7c673cae
FG
529int RGWAsyncFetchRemoteObj::_send_request()
530{
531 RGWObjectCtx obj_ctx(store);
532
533 string user_id;
534 char buf[16];
535 snprintf(buf, sizeof(buf), ".%lld", (long long)store->instance_id());
536 string client_id = store->zone_id() + buf;
537 string op_id = store->unique_id(store->get_new_req_id());
538 map<string, bufferlist> attrs;
539
540 rgw_obj src_obj(bucket_info.bucket, key);
541
542 rgw_obj dest_obj(src_obj);
543
544 int r = store->fetch_remote_obj(obj_ctx,
545 user_id,
546 client_id,
547 op_id,
548 false, /* don't record op state in ops log */
549 NULL, /* req_info */
550 source_zone,
551 dest_obj,
552 src_obj,
553 bucket_info, /* dest */
554 bucket_info, /* source */
555 NULL, /* real_time* src_mtime, */
556 NULL, /* real_time* mtime, */
557 NULL, /* const real_time* mod_ptr, */
558 NULL, /* const real_time* unmod_ptr, */
559 false, /* high precision time */
560 NULL, /* const char *if_match, */
561 NULL, /* const char *if_nomatch, */
562 RGWRados::ATTRSMOD_NONE,
563 copy_if_newer,
564 attrs,
565 RGW_OBJ_CATEGORY_MAIN,
566 versioned_epoch,
567 real_time(), /* delete_at */
568 &key.instance, /* string *version_id, */
569 NULL, /* string *ptag, */
570 NULL, /* string *petag, */
7c673cae 571 NULL, /* void (*progress_cb)(off_t, void *), */
31f18b77
FG
572 NULL, /* void *progress_data*); */
573 zones_trace);
7c673cae
FG
574
575 if (r < 0) {
576 ldout(store->ctx(), 0) << "store->fetch_remote_obj() returned r=" << r << dendl;
577 }
578 return r;
579}
580
581int RGWAsyncStatRemoteObj::_send_request()
582{
583 RGWObjectCtx obj_ctx(store);
584
585 string user_id;
586 char buf[16];
587 snprintf(buf, sizeof(buf), ".%lld", (long long)store->instance_id());
588 string client_id = store->zone_id() + buf;
589 string op_id = store->unique_id(store->get_new_req_id());
590
591 rgw_obj src_obj(bucket_info.bucket, key);
592
593 rgw_obj dest_obj(src_obj);
594
595 int r = store->stat_remote_obj(obj_ctx,
596 user_id,
597 client_id,
598 nullptr, /* req_info */
599 source_zone,
600 src_obj,
601 bucket_info, /* source */
602 pmtime, /* real_time* src_mtime, */
603 psize, /* uint64_t * */
604 nullptr, /* const real_time* mod_ptr, */
605 nullptr, /* const real_time* unmod_ptr, */
606 true, /* high precision time */
607 nullptr, /* const char *if_match, */
608 nullptr, /* const char *if_nomatch, */
609 pattrs,
610 nullptr,
611 nullptr, /* string *ptag, */
612 nullptr); /* string *petag, */
613
614 if (r < 0) {
615 ldout(store->ctx(), 0) << "store->fetch_remote_obj() returned r=" << r << dendl;
616 }
617 return r;
618}
619
620
621int RGWAsyncRemoveObj::_send_request()
622{
623 RGWObjectCtx obj_ctx(store);
624
625 rgw_obj obj(bucket_info.bucket, key);
626
627 ldout(store->ctx(), 0) << __func__ << "(): deleting obj=" << obj << dendl;
628
629 obj_ctx.obj.set_atomic(obj);
630
631 RGWObjState *state;
632
633 int ret = store->get_obj_state(&obj_ctx, bucket_info, obj, &state);
634 if (ret < 0) {
635 ldout(store->ctx(), 20) << __func__ << "(): get_obj_state() obj=" << obj << " returned ret=" << ret << dendl;
636 return ret;
637 }
638
639 /* has there been any racing object write? */
640 if (del_if_older && (state->mtime > timestamp)) {
641 ldout(store->ctx(), 20) << __func__ << "(): skipping object removal obj=" << obj << " (obj mtime=" << state->mtime << ", request timestamp=" << timestamp << ")" << dendl;
642 return 0;
643 }
644
645 RGWAccessControlPolicy policy;
646
647 /* decode policy */
648 map<string, bufferlist>::iterator iter = state->attrset.find(RGW_ATTR_ACL);
649 if (iter != state->attrset.end()) {
650 bufferlist::iterator bliter = iter->second.begin();
651 try {
652 policy.decode(bliter);
653 } catch (buffer::error& err) {
654 ldout(store->ctx(), 0) << "ERROR: could not decode policy, caught buffer::error" << dendl;
655 return -EIO;
656 }
657 }
658
659 RGWRados::Object del_target(store, bucket_info, obj_ctx, obj);
660 RGWRados::Object::Delete del_op(&del_target);
661
662 del_op.params.bucket_owner = bucket_info.owner;
663 del_op.params.obj_owner = policy.get_owner();
664 if (del_if_older) {
665 del_op.params.unmod_since = timestamp;
666 }
667 if (versioned) {
668 del_op.params.versioning_status = BUCKET_VERSIONED;
669 }
670 del_op.params.olh_epoch = versioned_epoch;
671 del_op.params.marker_version_id = marker_version_id;
672 del_op.params.obj_owner.set_id(owner);
673 del_op.params.obj_owner.set_name(owner_display_name);
674 del_op.params.mtime = timestamp;
675 del_op.params.high_precision_time = true;
31f18b77 676 del_op.params.zones_trace = zones_trace;
7c673cae
FG
677
678 ret = del_op.delete_obj();
679 if (ret < 0) {
680 ldout(store->ctx(), 20) << __func__ << "(): delete_obj() obj=" << obj << " returned ret=" << ret << dendl;
681 }
682 return ret;
683}
684
685int RGWContinuousLeaseCR::operate()
686{
687 if (aborted) {
688 caller->set_sleeping(false);
689 return set_cr_done();
690 }
691 reenter(this) {
692 while (!going_down) {
693 yield call(new RGWSimpleRadosLockCR(async_rados, store, obj, lock_name, cookie, interval));
694
695 caller->set_sleeping(false); /* will only be relevant when we return, that's why we can do it early */
696 if (retcode < 0) {
697 set_locked(false);
698 ldout(store->ctx(), 20) << *this << ": couldn't lock " << obj << ":" << lock_name << ": retcode=" << retcode << dendl;
699 return set_state(RGWCoroutine_Error, retcode);
700 }
701 set_locked(true);
702 yield wait(utime_t(interval / 2, 0));
703 }
704 set_locked(false); /* moot at this point anyway */
705 yield call(new RGWSimpleRadosUnlockCR(async_rados, store, obj, lock_name, cookie));
706 return set_state(RGWCoroutine_Done);
707 }
708 return 0;
709}
710
711RGWRadosTimelogAddCR::RGWRadosTimelogAddCR(RGWRados *_store, const string& _oid,
712 const cls_log_entry& entry) : RGWSimpleCoroutine(_store->ctx()),
713 store(_store),
714 oid(_oid), cn(NULL)
715{
716 stringstream& s = set_description();
717 s << "timelog add entry oid=" << oid << "entry={id=" << entry.id << ", section=" << entry.section << ", name=" << entry.name << "}";
718 entries.push_back(entry);
719}
720
7c673cae
FG
721int RGWRadosTimelogAddCR::send_request()
722{
723 set_status() << "sending request";
724
725 cn = stack->create_completion_notifier();
7c673cae
FG
726 return store->time_log_add(oid, entries, cn->completion(), true);
727}
728
729int RGWRadosTimelogAddCR::request_complete()
730{
731 int r = cn->completion()->get_return_value();
732
733 set_status() << "request complete; ret=" << r;
734
735 return r;
736}
737
738RGWRadosTimelogTrimCR::RGWRadosTimelogTrimCR(RGWRados *store,
739 const std::string& oid,
740 const real_time& start_time,
741 const real_time& end_time,
742 const std::string& from_marker,
743 const std::string& to_marker)
744 : RGWSimpleCoroutine(store->ctx()), store(store), oid(oid),
745 start_time(start_time), end_time(end_time),
746 from_marker(from_marker), to_marker(to_marker)
747{
748 set_description() << "timelog trim oid=" << oid
749 << " start_time=" << start_time << " end_time=" << end_time
750 << " from_marker=" << from_marker << " to_marker=" << to_marker;
751}
752
7c673cae
FG
753int RGWRadosTimelogTrimCR::send_request()
754{
755 set_status() << "sending request";
756
757 cn = stack->create_completion_notifier();
7c673cae
FG
758 return store->time_log_trim(oid, start_time, end_time, from_marker,
759 to_marker, cn->completion());
760}
761
762int RGWRadosTimelogTrimCR::request_complete()
763{
764 int r = cn->completion()->get_return_value();
765
766 set_status() << "request complete; ret=" << r;
767
768 return r;
769}
770
771
772RGWSyncLogTrimCR::RGWSyncLogTrimCR(RGWRados *store, const std::string& oid,
773 const std::string& to_marker,
774 std::string *last_trim_marker)
775 : RGWRadosTimelogTrimCR(store, oid, real_time{}, real_time{},
776 std::string{}, to_marker),
777 cct(store->ctx()), last_trim_marker(last_trim_marker)
778{
779}
780
781int RGWSyncLogTrimCR::request_complete()
782{
783 int r = RGWRadosTimelogTrimCR::request_complete();
784 if (r < 0 && r != -ENODATA) {
785 return r;
786 }
787 if (*last_trim_marker < to_marker) {
788 *last_trim_marker = to_marker;
789 }
790 return 0;
791}
792
793
794int RGWAsyncStatObj::_send_request()
795{
796 rgw_raw_obj raw_obj;
797 store->obj_to_raw(bucket_info.placement_rule, obj, &raw_obj);
798 return store->raw_obj_stat(raw_obj, psize, pmtime, pepoch,
799 nullptr, nullptr, objv_tracker);
800}
801
802RGWStatObjCR::RGWStatObjCR(RGWAsyncRadosProcessor *async_rados, RGWRados *store,
803 const RGWBucketInfo& _bucket_info, const rgw_obj& obj, uint64_t *psize,
804 real_time* pmtime, uint64_t *pepoch,
805 RGWObjVersionTracker *objv_tracker)
806 : RGWSimpleCoroutine(store->ctx()), store(store), async_rados(async_rados),
807 bucket_info(_bucket_info), obj(obj), psize(psize), pmtime(pmtime), pepoch(pepoch),
808 objv_tracker(objv_tracker)
809{
810}
811
812void RGWStatObjCR::request_cleanup()
813{
814 if (req) {
815 req->finish();
816 req = NULL;
817 }
818}
819
820int RGWStatObjCR::send_request()
821{
822 req = new RGWAsyncStatObj(this, stack->create_completion_notifier(),
823 store, bucket_info, obj, psize, pmtime, pepoch, objv_tracker);
824 async_rados->queue(req);
825 return 0;
826}
827
828int RGWStatObjCR::request_complete()
829{
830 return req->get_ret_status();
831}
b32b8144
FG
832
833RGWRadosNotifyCR::RGWRadosNotifyCR(RGWRados *store, const rgw_raw_obj& obj,
834 bufferlist& request, uint64_t timeout_ms,
835 bufferlist *response)
836 : RGWSimpleCoroutine(store->ctx()), store(store), obj(obj),
837 request(request), timeout_ms(timeout_ms), response(response)
838{
839 set_description() << "notify dest=" << obj;
840}
841
842int RGWRadosNotifyCR::send_request()
843{
844 int r = store->get_raw_obj_ref(obj, &ref);
845 if (r < 0) {
846 lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
847 return r;
848 }
849
850 set_status() << "sending request";
851
852 cn = stack->create_completion_notifier();
853 return ref.ioctx.aio_notify(ref.oid, cn->completion(), request,
854 timeout_ms, response);
855}
856
857int RGWRadosNotifyCR::request_complete()
858{
859 int r = cn->completion()->get_return_value();
860
861 set_status() << "request complete; ret=" << r;
862
863 return r;
864}