Skip to content

Commit 76302ac

Browse files
committed
rgw: pass optional_yield to all index ops
prepare for coroutine support by making the yield context available to all index ops Signed-off-by: Casey Bodley <[email protected]>
1 parent f980890 commit 76302ac

27 files changed

+191
-127
lines changed

src/rgw/driver/posix/rgw_sal_posix.cc

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,7 @@ int POSIXBucket::set_acl(const DoutPrefixProvider* dpp,
24682468
return write_attrs(dpp, y);
24692469
}
24702470

2471-
int POSIXBucket::read_stats(const DoutPrefixProvider *dpp,
2471+
int POSIXBucket::read_stats(const DoutPrefixProvider *dpp, optional_yield y,
24722472
const bucket_index_layout_generation& idx_layout,
24732473
int shard_id, std::string* bucket_ver, std::string* master_ver,
24742474
std::map<RGWObjCategory, RGWStorageStats>& stats,
@@ -2477,14 +2477,14 @@ int POSIXBucket::read_stats(const DoutPrefixProvider *dpp,
24772477
auto& main = stats[RGWObjCategory::Main];
24782478

24792479
// TODO: bucket stats shouldn't have to list all objects
2480-
return dir->for_each(dpp, [this, dpp, &main] (const char* name) {
2480+
return dir->for_each(dpp, [this, dpp, y, &main] (const char* name) {
24812481
if (name[0] == '.') {
24822482
/* Skip dotfiles */
24832483
return 0;
24842484
}
24852485

24862486
std::unique_ptr<FSEnt> dent;
2487-
int ret = dir->get_ent(dpp, null_yield, name, std::string(), dent);
2487+
int ret = dir->get_ent(dpp, y, name, std::string(), dent);
24882488
if (ret < 0) {
24892489
ret = errno;
24902490
ldpp_dout(dpp, 0) << "ERROR: could not get ent for object " << name << ": "
@@ -2617,17 +2617,19 @@ int POSIXBucket::remove_objs_from_index(const DoutPrefixProvider *dpp, std::list
26172617
return 0;
26182618
}
26192619

2620-
int POSIXBucket::check_index(const DoutPrefixProvider *dpp, std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats)
2620+
int POSIXBucket::check_index(const DoutPrefixProvider *dpp, optional_yield y,
2621+
std::map<RGWObjCategory, RGWStorageStats>& existing_stats,
2622+
std::map<RGWObjCategory, RGWStorageStats>& calculated_stats)
26212623
{
26222624
return 0;
26232625
}
26242626

2625-
int POSIXBucket::rebuild_index(const DoutPrefixProvider *dpp)
2627+
int POSIXBucket::rebuild_index(const DoutPrefixProvider *dpp, optional_yield y)
26262628
{
26272629
return 0;
26282630
}
26292631

2630-
int POSIXBucket::set_tag_timeout(const DoutPrefixProvider *dpp, uint64_t timeout)
2632+
int POSIXBucket::set_tag_timeout(const DoutPrefixProvider *dpp, optional_yield y, uint64_t timeout)
26312633
{
26322634
return 0;
26332635
}
@@ -2907,6 +2909,12 @@ int POSIXObject::list_parts(const DoutPrefixProvider* dpp, CephContext* cct,
29072909
return -EOPNOTSUPP;
29082910
}
29092911

2912+
bool POSIXObject::is_sync_completed(const DoutPrefixProvider* dpp, optional_yield y,
2913+
const ceph::real_time& obj_mtime)
2914+
{
2915+
return false;
2916+
}
2917+
29102918
int POSIXObject::load_obj_state(const DoutPrefixProvider* dpp, optional_yield y, bool follow_olh)
29112919
{
29122920
int ret = stat(dpp);

src/rgw/driver/posix/rgw_sal_posix.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ class POSIXBucket : public StoreBucket {
514514
virtual RGWAccessControlPolicy& get_acl(void) override { return acls; }
515515
virtual int set_acl(const DoutPrefixProvider* dpp, RGWAccessControlPolicy& acl,
516516
optional_yield y) override;
517-
virtual int read_stats(const DoutPrefixProvider *dpp,
517+
virtual int read_stats(const DoutPrefixProvider *dpp, optional_yield y,
518518
const bucket_index_layout_generation& idx_layout,
519519
int shard_id, std::string* bucket_ver, std::string* master_ver,
520520
std::map<RGWObjCategory, RGWStorageStats>& stats,
@@ -538,9 +538,11 @@ class POSIXBucket : public StoreBucket {
538538
RGWUsageIter& usage_iter, std::map<rgw_user_bucket, rgw_usage_log_entry>& usage) override;
539539
virtual int trim_usage(const DoutPrefixProvider *dpp, uint64_t start_epoch, uint64_t end_epoch, optional_yield y) override;
540540
virtual int remove_objs_from_index(const DoutPrefixProvider *dpp, std::list<rgw_obj_index_key>& objs_to_unlink) override;
541-
virtual int check_index(const DoutPrefixProvider *dpp, std::map<RGWObjCategory, RGWStorageStats>& existing_stats, std::map<RGWObjCategory, RGWStorageStats>& calculated_stats) override;
542-
virtual int rebuild_index(const DoutPrefixProvider *dpp) override;
543-
virtual int set_tag_timeout(const DoutPrefixProvider *dpp, uint64_t timeout) override;
541+
virtual int check_index(const DoutPrefixProvider *dpp, optional_yield y,
542+
std::map<RGWObjCategory, RGWStorageStats>& existing_stats,
543+
std::map<RGWObjCategory, RGWStorageStats>& calculated_stats) override;
544+
virtual int rebuild_index(const DoutPrefixProvider *dpp, optional_yield y) override;
545+
virtual int set_tag_timeout(const DoutPrefixProvider *dpp, optional_yield y, uint64_t timeout) override;
544546
virtual int purge_instance(const DoutPrefixProvider* dpp, optional_yield y) override;
545547

546548
virtual std::unique_ptr<Bucket> clone() override {
@@ -662,6 +664,8 @@ class POSIXObject : public StoreObject {
662664
bool* truncated, list_parts_each_t each_func,
663665
optional_yield y) override;
664666

667+
bool is_sync_completed(const DoutPrefixProvider* dpp, optional_yield y,
668+
const ceph::real_time& obj_mtime) override;
665669
virtual int load_obj_state(const DoutPrefixProvider* dpp, optional_yield y, bool follow_olh = true) override;
666670
virtual int set_obj_attrs(const DoutPrefixProvider* dpp, Attrs* setattrs,
667671
Attrs* delattrs, optional_yield y, uint32_t flags) override;

src/rgw/driver/rados/rgw_bucket.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ int RGWBucket::check_object_index(const DoutPrefixProvider *dpp,
563563
}
564564

565565
// use a quicker/shorter tag timeout during this process
566-
bucket->set_tag_timeout(dpp, BUCKET_TAG_QUICK_TIMEOUT);
566+
bucket->set_tag_timeout(dpp, y, BUCKET_TAG_QUICK_TIMEOUT);
567567

568568
rgw::sal::Bucket::ListResults results;
569569
results.is_truncated = true;
@@ -591,7 +591,7 @@ int RGWBucket::check_object_index(const DoutPrefixProvider *dpp,
591591
formatter->close_section();
592592

593593
// restore normal tag timeout for bucket
594-
bucket->set_tag_timeout(dpp, 0);
594+
bucket->set_tag_timeout(dpp, y, 0);
595595

596596
return 0;
597597
}
@@ -988,22 +988,22 @@ int RGWBucket::check_index_unlinked(rgw::sal::RadosStore* const rados_store,
988988
return 0;
989989
}
990990

991-
int RGWBucket::check_index(const DoutPrefixProvider *dpp,
991+
int RGWBucket::check_index(const DoutPrefixProvider *dpp, optional_yield y,
992992
RGWBucketAdminOpState& op_state,
993993
map<RGWObjCategory, RGWStorageStats>& existing_stats,
994994
map<RGWObjCategory, RGWStorageStats>& calculated_stats,
995995
std::string *err_msg)
996996
{
997997
bool fix_index = op_state.will_fix_index();
998998

999-
int r = bucket->check_index(dpp, existing_stats, calculated_stats);
999+
int r = bucket->check_index(dpp, y, existing_stats, calculated_stats);
10001000
if (r < 0) {
10011001
set_err_msg(err_msg, "failed to check index error=" + cpp_strerror(-r));
10021002
return r;
10031003
}
10041004

10051005
if (fix_index) {
1006-
r = bucket->rebuild_index(dpp);
1006+
r = bucket->rebuild_index(dpp, y);
10071007
if (r < 0) {
10081008
set_err_msg(err_msg, "failed to rebuild index err=" + cpp_strerror(-r));
10091009
return r;
@@ -1420,7 +1420,7 @@ int RGWBucketAdminOp::check_index(rgw::sal::Driver* driver,
14201420
}
14211421
}
14221422

1423-
ret = bucket.check_index(dpp, op_state, existing_stats, calculated_stats);
1423+
ret = bucket.check_index(dpp, y, op_state, existing_stats, calculated_stats);
14241424
if (ret < 0) {
14251425
return ret;
14261426
}
@@ -1499,7 +1499,7 @@ static int bucket_stats(rgw::sal::Driver* driver,
14991499

15001500
std::string bucket_ver, master_ver;
15011501
std::string max_marker;
1502-
ret = bucket->read_stats(dpp, index, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, &max_marker);
1502+
ret = bucket->read_stats(dpp, y, index, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, &max_marker);
15031503
if (ret < 0) {
15041504
cerr << "error getting bucket stats bucket=" << bucket->get_name() << " ret=" << ret << std::endl;
15051505
return ret;
@@ -1613,7 +1613,7 @@ int RGWBucketAdminOp::limit_check(rgw::sal::Driver* driver,
16131613
/* need stats for num_entries */
16141614
string bucket_ver, master_ver;
16151615
std::map<RGWObjCategory, RGWStorageStats> stats;
1616-
ret = bucket->read_stats(dpp, index, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, nullptr);
1616+
ret = bucket->read_stats(dpp, y, index, RGW_NO_SHARD, &bucket_ver, &master_ver, stats, nullptr);
16171617

16181618
if (ret < 0)
16191619
continue;
@@ -2915,7 +2915,7 @@ int RGWBucketInstanceMetadataHandler::put_post(
29152915
const std::optional<RGWBucketCompleteInfo>& old_bci,
29162916
RGWObjVersionTracker& objv_tracker)
29172917
{
2918-
int ret = svc_bi->init_index(dpp, bci.info, bci.info.layout.current_index);
2918+
int ret = svc_bi->init_index(dpp, y, bci.info, bci.info.layout.current_index);
29192919
if (ret < 0) {
29202920
return ret;
29212921
}

src/rgw/driver/rados/rgw_bucket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ class RGWBucket {
347347
int check_index_unlinked(rgw::sal::RadosStore* rados_store, const DoutPrefixProvider *dpp, RGWBucketAdminOpState& op_state,
348348
RGWFormatterFlusher& flusher);
349349

350-
int check_index(const DoutPrefixProvider *dpp,
350+
int check_index(const DoutPrefixProvider *dpp, optional_yield y,
351351
RGWBucketAdminOpState& op_state,
352352
std::map<RGWObjCategory, RGWStorageStats>& existing_stats,
353353
std::map<RGWObjCategory, RGWStorageStats>& calculated_stats,

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2449,7 +2449,7 @@ int RGWRados::create_bucket(const DoutPrefixProvider* dpp,
24492449
}
24502450

24512451
if (zone_placement) {
2452-
ret = svc.bi->init_index(dpp, info, info.layout.current_index);
2452+
ret = svc.bi->init_index(dpp, y, info, info.layout.current_index);
24532453
if (ret < 0) {
24542454
return ret;
24552455
}
@@ -2475,7 +2475,7 @@ int RGWRados::create_bucket(const DoutPrefixProvider* dpp,
24752475
/* only remove it if it's a different bucket instance */
24762476
if (orig_info.bucket.bucket_id != bucket.bucket_id) {
24772477
if (zone_placement) {
2478-
r = svc.bi->clean_index(dpp, info, info.layout.current_index);
2478+
r = svc.bi->clean_index(dpp, y, info, info.layout.current_index);
24792479
if (r < 0) {
24802480
ldpp_dout(dpp, 0) << "WARNING: could not remove bucket index (r=" << r << ")" << dendl;
24812481
}
@@ -5988,7 +5988,8 @@ static void accumulate_raw_stats(const rgw_bucket_dir_header& header,
59885988
}
59895989
}
59905990

5991-
int RGWRados::bucket_check_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info,
5991+
int RGWRados::bucket_check_index(const DoutPrefixProvider *dpp, optional_yield y,
5992+
const RGWBucketInfo& bucket_info,
59925993
map<RGWObjCategory, RGWStorageStats> *existing_stats,
59935994
map<RGWObjCategory, RGWStorageStats> *calculated_stats)
59945995
{
@@ -6024,7 +6025,8 @@ int RGWRados::bucket_check_index(const DoutPrefixProvider *dpp, RGWBucketInfo& b
60246025
return 0;
60256026
}
60266027

6027-
int RGWRados::bucket_rebuild_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info)
6028+
int RGWRados::bucket_rebuild_index(const DoutPrefixProvider *dpp, optional_yield y,
6029+
const RGWBucketInfo& bucket_info)
60286030
{
60296031
librados::IoCtx index_pool;
60306032
map<int, string> bucket_objs;
@@ -9401,7 +9403,7 @@ int RGWRados::raw_obj_stat(const DoutPrefixProvider *dpp,
94019403
return 0;
94029404
}
94039405

9404-
int RGWRados::get_bucket_stats(const DoutPrefixProvider *dpp,
9406+
int RGWRados::get_bucket_stats(const DoutPrefixProvider *dpp, optional_yield y,
94059407
RGWBucketInfo& bucket_info,
94069408
const rgw::bucket_index_layout_generation& idx_layout,
94079409
int shard_id, string *bucket_ver, string *master_ver,

src/rgw/driver/rados/rgw_rados.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,8 @@ int restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx,
14551455
rctx->set_compressed(obj);
14561456
}
14571457
int decode_policy(const DoutPrefixProvider *dpp, bufferlist& bl, ACLOwner *owner);
1458-
int get_bucket_stats(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout, int shard_id, std::string *bucket_ver, std::string *master_ver,
1458+
int get_bucket_stats(const DoutPrefixProvider *dpp, optional_yield y,
1459+
RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout, int shard_id, std::string *bucket_ver, std::string *master_ver,
14591460
std::map<RGWObjCategory, RGWStorageStats>& stats, std::string *max_marker, bool* syncstopped = NULL);
14601461
int get_bucket_stats_async(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout, int shard_id, boost::intrusive_ptr<rgw::sal::ReadStatsCB> cb);
14611462

@@ -1589,10 +1590,12 @@ int restore_obj_from_cloud(RGWLCCloudTierCtx& tier_ctx,
15891590

15901591
int process_lc(const std::unique_ptr<rgw::sal::Bucket>& optional_bucket);
15911592

1592-
int bucket_check_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info,
1593+
int bucket_check_index(const DoutPrefixProvider *dpp, optional_yield y,
1594+
const RGWBucketInfo& bucket_info,
15931595
std::map<RGWObjCategory, RGWStorageStats> *existing_stats,
15941596
std::map<RGWObjCategory, RGWStorageStats> *calculated_stats);
1595-
int bucket_rebuild_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info);
1597+
int bucket_rebuild_index(const DoutPrefixProvider *dpp, optional_yield y,
1598+
const RGWBucketInfo& bucket_info);
15961599

15971600
// Search the bucket for encrypted multipart uploads, and increase their mtime
15981601
// slightly to generate a bilog entry to trigger a resync to repair any

0 commit comments

Comments
 (0)