Skip to content

Commit 2a3f117

Browse files
committed
rgw/lc: pass optional_yield arguments to WorkQ functions
Signed-off-by: Casey Bodley <[email protected]>
1 parent 0fa436b commit 2a3f117

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

src/rgw/rgw_lc.cc

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,8 @@ struct lc_op_ctx {
537537
}; /* lc_op_ctx */
538538

539539

540-
static bool pass_size_limit_checks(const DoutPrefixProvider *dpp, lc_op_ctx& oc) {
540+
static bool pass_size_limit_checks(const DoutPrefixProvider *dpp,
541+
optional_yield y, lc_op_ctx& oc) {
541542

542543
const auto& op = oc.op;
543544
if (op.size_gt || op.size_lt) {
@@ -546,7 +547,7 @@ static bool pass_size_limit_checks(const DoutPrefixProvider *dpp, lc_op_ctx& oc)
546547
auto& o = oc.o;
547548
std::unique_ptr<rgw::sal::Object> obj = bucket->get_object(o.key);
548549

549-
ret = obj->load_obj_state(dpp, null_yield, true);
550+
ret = obj->load_obj_state(dpp, y, true);
550551
if (ret < 0) {
551552
return false;
552553
}
@@ -571,6 +572,7 @@ static std::string lc_id = "rgw lifecycle";
571572
static std::string lc_req_id = "0";
572573

573574
static void send_notification(const DoutPrefixProvider* dpp,
575+
optional_yield y,
574576
rgw::sal::Driver* driver,
575577
rgw::sal::Object* obj,
576578
rgw::sal::Bucket* bucket,
@@ -581,7 +583,7 @@ static void send_notification(const DoutPrefixProvider* dpp,
581583
// notification supported only for RADOS driver for now
582584
auto notify = driver->get_notification(
583585
dpp, obj, nullptr, event_types, bucket, lc_id,
584-
const_cast<std::string&>(bucket->get_tenant()), lc_req_id, null_yield);
586+
const_cast<std::string&>(bucket->get_tenant()), lc_req_id, y);
585587

586588
int ret = notify->publish_reserve(dpp, nullptr);
587589
if (ret < 0) {
@@ -622,7 +624,7 @@ static bool zonegroup_lc_check(const DoutPrefixProvider *dpp, rgw::sal::Zone* zo
622624
}
623625

624626
static int remove_expired_obj(const DoutPrefixProvider* dpp,
625-
lc_op_ctx& oc,
627+
optional_yield y, lc_op_ctx& oc,
626628
bool remove_indeed,
627629
const rgw::notify::EventTypeList& event_types) {
628630
int ret{0};
@@ -645,7 +647,7 @@ static int remove_expired_obj(const DoutPrefixProvider* dpp,
645647

646648
string etag;
647649
auto obj = oc.bucket->get_object(obj_key);
648-
ret = obj->load_obj_state(dpp, null_yield, true);
650+
ret = obj->load_obj_state(dpp, y, true);
649651
if (ret < 0) {
650652
/* for delete markers, we expect load_obj_state() to "fail"
651653
* with -ENOENT */
@@ -679,13 +681,13 @@ static int remove_expired_obj(const DoutPrefixProvider* dpp,
679681

680682
uint32_t flags = (!remove_indeed || !zonegroup_lc_check(dpp, oc.driver->get_zone()))
681683
? rgw::sal::FLAG_LOG_OP : 0;
682-
ret = del_op->delete_obj(dpp, null_yield, flags);
684+
ret = del_op->delete_obj(dpp, y, flags);
683685
if (ret < 0) {
684686
ldpp_dout(dpp, 1) <<
685687
fmt::format("ERROR: {} failed, with error: {}", __func__, ret) << dendl;
686688
} else {
687689
if (have_notify) {
688-
send_notification(dpp, driver, obj.get(), oc.bucket, etag, size,
690+
send_notification(dpp, y, driver, obj.get(), oc.bucket, etag, size,
689691
version_id, event_types);
690692
}
691693
}
@@ -955,7 +957,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
955957
params.ns = RGW_OBJ_NS_MULTIPART;
956958
params.access_list_filter = MultipartMetaFilter;
957959

958-
auto pf = [&](RGWLC::LCWorker *wk, WorkQ *wq, WorkItem &wi) {
960+
auto pf = [&](RGWLC::LCWorker *wk, WorkQ *wq, WorkItem &wi, optional_yield y) {
959961
int ret{0};
960962
auto wt = std::get<std::tuple<lc_op, rgw_bucket_dir_entry>>(wi);
961963
auto& [rule, obj] = wt;
@@ -966,7 +968,7 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
966968
auto sal_obj = target->get_object(key);
967969

968970
string etag;
969-
ret = sal_obj->load_obj_state(this, null_yield, true);
971+
ret = sal_obj->load_obj_state(this, y, true);
970972
if (ret < 0) {
971973
return ret;
972974
}
@@ -976,10 +978,10 @@ int RGWLC::handle_multipart_expiration(rgw::sal::Bucket* target,
976978
}
977979
auto size = sal_obj->get_size();
978980

979-
ret = mpu->abort(this, cct, null_yield);
981+
ret = mpu->abort(this, cct, y);
980982
if (ret == 0) {
981983
const auto event_type = rgw::notify::ObjectExpirationAbortMPU;
982-
send_notification(this, driver, sal_obj.get(), target, etag, size,
984+
send_notification(this, y, driver, sal_obj.get(), target, etag, size,
983985
obj.key.instance, {event_type});
984986
if (perfcounter) {
985987
perfcounter->inc(l_rgw_lc_abort_mpu, 1);
@@ -1211,7 +1213,7 @@ class LCOpAction_CurrentExpiration : public LCOpAction {
12111213
is_expired = obj_has_expired(dpp, oc.cct, mtime, op.expiration, exp_time);
12121214
}
12131215

1214-
auto size_check_p = pass_size_limit_checks(dpp, oc);
1216+
auto size_check_p = pass_size_limit_checks(dpp, y, oc);
12151217

12161218
ldpp_dout(dpp, 20) << __func__ << "(): key=" << o.key << ": is_expired="
12171219
<< (int)is_expired << " size_check_p: "
@@ -1221,12 +1223,12 @@ class LCOpAction_CurrentExpiration : public LCOpAction {
12211223
return is_expired && size_check_p;
12221224
}
12231225

1224-
int process(lc_op_ctx& oc) override {
1226+
int process(lc_op_ctx& oc, optional_yield y) override {
12251227
auto& o = oc.o;
12261228
int r;
12271229
if (o.is_delete_marker()) {
12281230
r = remove_expired_obj(
1229-
oc.dpp, oc, true,
1231+
oc.dpp, y, oc, true,
12301232
{rgw::notify::ObjectExpirationDeleteMarker,
12311233
rgw::notify::LifecycleExpirationDeleteMarkerCreated});
12321234
if (r < 0) {
@@ -1241,7 +1243,7 @@ class LCOpAction_CurrentExpiration : public LCOpAction {
12411243
<< " " << oc.wq->thr_name() << dendl;
12421244
} else {
12431245
/* ! o.is_delete_marker() */
1244-
r = remove_expired_obj(oc.dpp, oc, !oc.bucket->versioning_enabled(),
1246+
r = remove_expired_obj(oc.dpp, y, oc, !oc.bucket->versioning_enabled(),
12451247
{rgw::notify::ObjectExpirationCurrent,
12461248
rgw::notify::LifecycleExpirationDelete});
12471249
if (r < 0) {
@@ -1279,7 +1281,7 @@ class LCOpAction_NonCurrentExpiration : public LCOpAction {
12791281
int expiration = oc.op.noncur_expiration;
12801282
bool is_expired = obj_has_expired(dpp, oc.cct, oc.effective_mtime, expiration,
12811283
exp_time);
1282-
auto size_check_p = pass_size_limit_checks(dpp, oc);
1284+
auto size_check_p = pass_size_limit_checks(dpp, y, oc);
12831285
auto newer_noncurrent_p = (oc.num_noncurrent > oc.op.newer_noncurrent);
12841286

12851287
ldpp_dout(dpp, 20) << __func__ << "(): key=" << o.key << ": is_expired="
@@ -1291,12 +1293,12 @@ class LCOpAction_NonCurrentExpiration : public LCOpAction {
12911293

12921294
return is_expired &&
12931295
(oc.num_noncurrent > oc.op.newer_noncurrent) && size_check_p &&
1294-
pass_object_lock_check(oc.driver, oc.obj.get(), dpp);
1296+
pass_object_lock_check(oc.driver, oc.obj.get(), dpp, y);
12951297
}
12961298

1297-
int process(lc_op_ctx& oc) override {
1299+
int process(lc_op_ctx& oc, optional_yield y) override {
12981300
auto& o = oc.o;
1299-
int r = remove_expired_obj(oc.dpp, oc, true,
1301+
int r = remove_expired_obj(oc.dpp, y, oc, true,
13001302
{rgw::notify::LifecycleExpirationDelete,
13011303
rgw::notify::ObjectExpirationNoncurrent});
13021304
if (r < 0) {
@@ -1341,9 +1343,9 @@ class LCOpAction_DMExpiration : public LCOpAction {
13411343
return true;
13421344
}
13431345

1344-
int process(lc_op_ctx& oc) override {
1346+
int process(lc_op_ctx& oc, optional_yield y) override {
13451347
auto& o = oc.o;
1346-
int r = remove_expired_obj(oc.dpp, oc, true,
1348+
int r = remove_expired_obj(oc.dpp, y, oc, true,
13471349
{rgw::notify::ObjectExpirationDeleteMarker,
13481350
rgw::notify::LifecycleExpirationDeleteMarkerCreated});
13491351
if (r < 0) {
@@ -1402,7 +1404,7 @@ class LCOpAction_Transition : public LCOpAction {
14021404
is_expired = obj_has_expired(dpp, oc.cct, mtime, transition.days, exp_time);
14031405
}
14041406

1405-
auto size_check_p = pass_size_limit_checks(dpp, oc);
1407+
auto size_check_p = pass_size_limit_checks(dpp, y, oc);
14061408

14071409
ldpp_dout(oc.dpp, 20) << __func__ << "(): key=" << o.key << ": is_expired="
14081410
<< is_expired << " " << " size_check_p: "
@@ -1427,19 +1429,19 @@ class LCOpAction_Transition : public LCOpAction {
14271429
*/
14281430
if (! oc.bucket->versioning_enabled()) {
14291431
ret =
1430-
remove_expired_obj(oc.dpp, oc, true, {/* no delete notify expected */});
1432+
remove_expired_obj(oc.dpp, y, oc, true, {/* no delete notify expected */});
14311433
ldpp_dout(oc.dpp, 20) << "delete_tier_obj Object(key:" << oc.o.key
14321434
<< ") not versioned flags: " << oc.o.flags << dendl;
14331435
} else {
14341436
/* versioned */
14351437
if (oc.o.is_current() && !oc.o.is_delete_marker()) {
1436-
ret = remove_expired_obj(oc.dpp, oc, false, {/* no delete notify expected */});
1438+
ret = remove_expired_obj(oc.dpp, y, oc, false, {/* no delete notify expected */});
14371439
ldpp_dout(oc.dpp, 20) << "delete_tier_obj Object(key:" << oc.o.key
14381440
<< ") current & not delete_marker"
14391441
<< " versioned_epoch: " << oc.o.versioned_epoch
14401442
<< "flags: " << oc.o.flags << dendl;
14411443
} else {
1442-
ret = remove_expired_obj(oc.dpp, oc, true,
1444+
ret = remove_expired_obj(oc.dpp, y, oc, true,
14431445
{/* no delete notify expected */});
14441446
ldpp_dout(oc.dpp, 20)
14451447
<< "delete_tier_obj Object(key:" << oc.o.key << ") not current "
@@ -1451,7 +1453,7 @@ class LCOpAction_Transition : public LCOpAction {
14511453
return ret;
14521454
}
14531455

1454-
int transition_obj_to_cloud(lc_op_ctx& oc) {
1456+
int transition_obj_to_cloud(lc_op_ctx& oc, optional_yield y) {
14551457
int ret{0};
14561458
/* If CurrentVersion object & bucket has versioning enabled, remove it &
14571459
* create delete marker */
@@ -1463,7 +1465,7 @@ class LCOpAction_Transition : public LCOpAction {
14631465
auto& obj = oc.obj;
14641466

14651467
string etag;
1466-
ret = obj->load_obj_state(oc.dpp, null_yield, true);
1468+
ret = obj->load_obj_state(oc.dpp, y, true);
14671469
if (ret < 0) {
14681470
return ret;
14691471
}
@@ -1475,8 +1477,7 @@ class LCOpAction_Transition : public LCOpAction {
14751477

14761478
ret = oc.obj->transition_to_cloud(oc.bucket, oc.tier.get(), oc.o,
14771479
oc.env.worker->get_cloud_targets(),
1478-
oc.cct, !delete_object, oc.dpp,
1479-
null_yield);
1480+
oc.cct, !delete_object, oc.dpp, y);
14801481
if (ret < 0) {
14811482
return ret;
14821483
} else {
@@ -1489,7 +1490,7 @@ class LCOpAction_Transition : public LCOpAction {
14891490
} else {
14901491
event_types.push_back(rgw::notify::ObjectTransitionNonCurrent);
14911492
}
1492-
send_notification(oc.dpp, oc.driver, obj.get(), oc.bucket, etag, size,
1493+
send_notification(oc.dpp, y, oc.driver, obj.get(), oc.bucket, etag, size,
14931494
oc.o.key.instance, event_types);
14941495
}
14951496

@@ -1504,7 +1505,7 @@ class LCOpAction_Transition : public LCOpAction {
15041505
return 0;
15051506
}
15061507

1507-
int process(lc_op_ctx& oc) override {
1508+
int process(lc_op_ctx& oc, optional_yield y) override {
15081509
auto& o = oc.o;
15091510
int r;
15101511

@@ -1519,7 +1520,7 @@ class LCOpAction_Transition : public LCOpAction {
15191520
auto& obj = oc.obj;
15201521

15211522
string etag;
1522-
r = obj->load_obj_state(oc.dpp, null_yield, true);
1523+
r = obj->load_obj_state(oc.dpp, y, true);
15231524
if (r < 0) {
15241525
ldpp_dout(oc.dpp, 0) <<
15251526
fmt::format("ERROR: get_obj_state() failed on transition of object k={} error r={}",
@@ -1546,7 +1547,7 @@ class LCOpAction_Transition : public LCOpAction {
15461547
oc.driver->get_notification(
15471548
oc.dpp, obj.get(), nullptr, event_types, bucket, lc_id,
15481549
const_cast<std::string&>(oc.bucket->get_tenant()), lc_req_id,
1549-
null_yield);
1550+
y);
15501551
auto version_id = oc.o.key.instance;
15511552

15521553
r = notify->publish_reserve(oc.dpp, nullptr);
@@ -1594,7 +1595,7 @@ class LCOpAction_Transition : public LCOpAction {
15941595
uint32_t flags = !zonegroup_lc_check(oc.dpp, oc.driver->get_zone())
15951596
? rgw::sal::FLAG_LOG_OP : 0;
15961597
int r = oc.obj->transition(oc.bucket, target_placement, o.meta.mtime,
1597-
o.versioned_epoch, oc.dpp, null_yield, flags);
1598+
o.versioned_epoch, oc.dpp, y, flags);
15981599
if (r < 0) {
15991600
ldpp_dout(oc.dpp, 0) << "ERROR: failed to transition obj "
16001601
<< oc.bucket << ":" << o.key
@@ -1634,8 +1635,8 @@ class LCOpAction_CurrentTransition : public LCOpAction_Transition {
16341635
public:
16351636
LCOpAction_CurrentTransition(const transition_action& _transition)
16361637
: LCOpAction_Transition(_transition) {}
1637-
int process(lc_op_ctx& oc) override {
1638-
int r = LCOpAction_Transition::process(oc);
1638+
int process(lc_op_ctx& oc, optional_yield y) override {
1639+
int r = LCOpAction_Transition::process(oc, y);
16391640
if (r == 0) {
16401641
if (perfcounter) {
16411642
perfcounter->inc(l_rgw_lc_transition_current, 1);
@@ -1659,8 +1660,8 @@ class LCOpAction_NonCurrentTransition : public LCOpAction_Transition {
16591660
const transition_action& _transition)
16601661
: LCOpAction_Transition(_transition)
16611662
{}
1662-
int process(lc_op_ctx& oc) override {
1663-
int r = LCOpAction_Transition::process(oc);
1663+
int process(lc_op_ctx& oc, optional_yield y) override {
1664+
int r = LCOpAction_Transition::process(oc, y);
16641665
if (r == 0) {
16651666
if (perfcounter) {
16661667
perfcounter->inc(l_rgw_lc_transition_noncurrent, 1);
@@ -1829,7 +1830,7 @@ int RGWLC::bucket_lc_process(string& shard_id, LCWorker* worker,
18291830
/* fetch information for zone checks */
18301831
rgw::sal::Zone* zone = driver->get_zone();
18311832

1832-
auto pf = [&bucket_name](RGWLC::LCWorker* wk, WorkQ* wq, WorkItem& wi) {
1833+
auto pf = [&bucket_name](RGWLC::LCWorker* wk, WorkQ* wq, WorkItem& wi, optional_yield y) {
18331834
auto wt =
18341835
std::get<std::tuple<LCOpRule, rgw_bucket_dir_entry>>(wi);
18351836
auto& [op_rule, o] = wt;

0 commit comments

Comments
 (0)