Skip to content

Commit 52d63b5

Browse files
authored
Merge pull request ceph#58448 from cbodley/wip-rgw-lc-async
cls/rgw: define lc ops in terms of ObjectOperation instead of IoCtx Reviewed-by: Matt Benjamin <[email protected]>
2 parents 1846ea4 + 8476a02 commit 52d63b5

File tree

14 files changed

+295
-212
lines changed

14 files changed

+295
-212
lines changed

src/cls/rgw/cls_rgw_client.cc

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -943,92 +943,90 @@ void cls_rgw_gc_remove(librados::ObjectWriteOperation& op, const vector<string>&
943943
op.exec(RGW_CLASS, RGW_GC_REMOVE, in);
944944
}
945945

946-
int cls_rgw_lc_get_head(IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& head)
946+
void cls_rgw_lc_get_head(ObjectReadOperation& op, bufferlist& out)
947947
{
948-
bufferlist in, out;
949-
int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_GET_HEAD, in, out);
950-
if (r < 0)
951-
return r;
948+
bufferlist in;
949+
op.exec(RGW_CLASS, RGW_LC_GET_HEAD, in, &out, nullptr);
950+
}
952951

952+
int cls_rgw_lc_get_head_decode(const bufferlist& out, cls_rgw_lc_obj_head& head)
953+
{
953954
cls_rgw_lc_get_head_ret ret;
954955
try {
955956
auto iter = out.cbegin();
956957
decode(ret, iter);
957958
} catch (ceph::buffer::error& err) {
958959
return -EIO;
959960
}
960-
head = ret.head;
961+
head = std::move(ret.head);
961962

962-
return r;
963+
return 0;
963964
}
964965

965-
int cls_rgw_lc_put_head(IoCtx& io_ctx, const string& oid, cls_rgw_lc_obj_head& head)
966+
void cls_rgw_lc_put_head(ObjectWriteOperation& op, const cls_rgw_lc_obj_head& head)
966967
{
967-
bufferlist in, out;
968+
bufferlist in;
968969
cls_rgw_lc_put_head_op call;
969970
call.head = head;
970971
encode(call, in);
971-
int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_PUT_HEAD, in, out);
972-
return r;
972+
op.exec(RGW_CLASS, RGW_LC_PUT_HEAD, in);
973973
}
974974

975-
int cls_rgw_lc_get_next_entry(IoCtx& io_ctx, const string& oid, const string& marker,
976-
cls_rgw_lc_entry& entry)
975+
void cls_rgw_lc_get_next_entry(ObjectReadOperation& op, const string& marker,
976+
bufferlist& out)
977977
{
978-
bufferlist in, out;
978+
bufferlist in;
979979
cls_rgw_lc_get_next_entry_op call;
980980
call.marker = marker;
981981
encode(call, in);
982-
int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_GET_NEXT_ENTRY, in, out);
983-
if (r < 0)
984-
return r;
982+
op.exec(RGW_CLASS, RGW_LC_GET_NEXT_ENTRY, in, &out, nullptr);
983+
}
985984

985+
int cls_rgw_lc_get_next_entry_decode(const bufferlist& out, cls_rgw_lc_entry& entry)
986+
{
986987
cls_rgw_lc_get_next_entry_ret ret;
987988
try {
988989
auto iter = out.cbegin();
989990
decode(ret, iter);
990991
} catch (ceph::buffer::error& err) {
991992
return -EIO;
992993
}
993-
entry = ret.entry;
994+
entry = std::move(ret.entry);
994995

995-
return r;
996+
return 0;
996997
}
997998

998-
int cls_rgw_lc_rm_entry(IoCtx& io_ctx, const string& oid,
999-
const cls_rgw_lc_entry& entry)
999+
void cls_rgw_lc_rm_entry(ObjectWriteOperation& op,
1000+
const cls_rgw_lc_entry& entry)
10001001
{
1001-
bufferlist in, out;
1002+
bufferlist in;
10021003
cls_rgw_lc_rm_entry_op call;
10031004
call.entry = entry;
10041005
encode(call, in);
1005-
int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_RM_ENTRY, in, out);
1006-
return r;
1006+
op.exec(RGW_CLASS, RGW_LC_RM_ENTRY, in);
10071007
}
10081008

1009-
int cls_rgw_lc_set_entry(IoCtx& io_ctx, const string& oid,
1010-
const cls_rgw_lc_entry& entry)
1009+
void cls_rgw_lc_set_entry(ObjectWriteOperation& op,
1010+
const cls_rgw_lc_entry& entry)
10111011
{
10121012
bufferlist in, out;
10131013
cls_rgw_lc_set_entry_op call;
10141014
call.entry = entry;
10151015
encode(call, in);
1016-
int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_SET_ENTRY, in, out);
1017-
return r;
1016+
op.exec(RGW_CLASS, RGW_LC_SET_ENTRY, in);
10181017
}
10191018

1020-
int cls_rgw_lc_get_entry(IoCtx& io_ctx, const string& oid,
1021-
const std::string& marker, cls_rgw_lc_entry& entry)
1019+
void cls_rgw_lc_get_entry(ObjectReadOperation& op, const std::string& marker,
1020+
bufferlist& out)
10221021
{
1023-
bufferlist in, out;
1024-
cls_rgw_lc_get_entry_op call{marker};;
1022+
bufferlist in;
1023+
cls_rgw_lc_get_entry_op call{marker};
10251024
encode(call, in);
1026-
int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_GET_ENTRY, in, out);
1027-
1028-
if (r < 0) {
1029-
return r;
1030-
}
1025+
op.exec(RGW_CLASS, RGW_LC_GET_ENTRY, in, &out, nullptr);
1026+
}
10311027

1028+
int cls_rgw_lc_get_entry_decode(const bufferlist& out, cls_rgw_lc_entry& entry)
1029+
{
10321030
cls_rgw_lc_get_entry_ret ret;
10331031
try {
10341032
auto iter = out.cbegin();
@@ -1038,28 +1036,24 @@ int cls_rgw_lc_get_entry(IoCtx& io_ctx, const string& oid,
10381036
}
10391037

10401038
entry = std::move(ret.entry);
1041-
return r;
1039+
return 0;
10421040
}
10431041

1044-
int cls_rgw_lc_list(IoCtx& io_ctx, const string& oid,
1045-
const string& marker,
1046-
uint32_t max_entries,
1047-
vector<cls_rgw_lc_entry>& entries)
1042+
void cls_rgw_lc_list(ObjectReadOperation& op, const string& marker,
1043+
uint32_t max_entries, bufferlist& out)
10481044
{
1049-
bufferlist in, out;
1050-
cls_rgw_lc_list_entries_op op;
1051-
1052-
entries.clear();
1053-
1054-
op.marker = marker;
1055-
op.max_entries = max_entries;
1045+
bufferlist in;
1046+
cls_rgw_lc_list_entries_op call;
1047+
call.marker = marker;
1048+
call.max_entries = max_entries;
10561049

1057-
encode(op, in);
1050+
encode(call, in);
10581051

1059-
int r = io_ctx.exec(oid, RGW_CLASS, RGW_LC_LIST_ENTRIES, in, out);
1060-
if (r < 0)
1061-
return r;
1052+
op.exec(RGW_CLASS, RGW_LC_LIST_ENTRIES, in, &out, nullptr);
1053+
}
10621054

1055+
int cls_rgw_lc_list_decode(const bufferlist& out, std::vector<cls_rgw_lc_entry>& entries)
1056+
{
10631057
cls_rgw_lc_list_entries_ret ret;
10641058
try {
10651059
auto iter = out.cbegin();
@@ -1072,7 +1066,7 @@ int cls_rgw_lc_list(IoCtx& io_ctx, const string& oid,
10721066
[](const cls_rgw_lc_entry& a, const cls_rgw_lc_entry& b)
10731067
{ return a.bucket < b.bucket; });
10741068
entries = std::move(ret.entries);
1075-
return r;
1069+
return 0;
10761070
}
10771071

10781072
void cls_rgw_mp_upload_part_info_update(librados::ObjectWriteOperation& op,

src/cls/rgw/cls_rgw_client.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -607,19 +607,19 @@ int cls_rgw_gc_list_decode(const bufferlist& bl,
607607
bool *truncated, std::string& next_marker);
608608

609609
/* lifecycle */
610-
// these overloads which call io_ctx.operate() should not be called in the rgw.
611-
// rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()
612-
#ifndef CLS_CLIENT_HIDE_IOCTX
613-
int cls_rgw_lc_get_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head);
614-
int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head);
615-
int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, cls_rgw_lc_entry& entry);
616-
int cls_rgw_lc_rm_entry(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_lc_entry& entry);
617-
int cls_rgw_lc_set_entry(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_lc_entry& entry);
618-
int cls_rgw_lc_get_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, cls_rgw_lc_entry& entry);
619-
int cls_rgw_lc_list(librados::IoCtx& io_ctx, const std::string& oid,
620-
const std::string& marker, uint32_t max_entries,
621-
std::vector<cls_rgw_lc_entry>& entries);
622-
#endif
610+
void cls_rgw_lc_get_head(librados::ObjectReadOperation& op, bufferlist& bl);
611+
int cls_rgw_lc_get_head_decode(const bufferlist& bl, cls_rgw_lc_obj_head& head);
612+
void cls_rgw_lc_put_head(librados::ObjectWriteOperation& op, const cls_rgw_lc_obj_head& head);
613+
void cls_rgw_lc_get_next_entry(librados::ObjectReadOperation& op, const std::string& marker, bufferlist& bl);
614+
int cls_rgw_lc_get_next_entry_decode(const bufferlist& bl, cls_rgw_lc_entry& entry);
615+
void cls_rgw_lc_rm_entry(librados::ObjectWriteOperation& op, const cls_rgw_lc_entry& entry);
616+
void cls_rgw_lc_set_entry(librados::ObjectWriteOperation& op, const cls_rgw_lc_entry& entry);
617+
void cls_rgw_lc_get_entry(librados::ObjectReadOperation& op, const std::string& marker, bufferlist& bl);
618+
int cls_rgw_lc_get_entry_decode(const bufferlist& bl, cls_rgw_lc_entry& entry);
619+
void cls_rgw_lc_list(librados::ObjectReadOperation& op,
620+
const std::string& marker, uint32_t max_entries,
621+
bufferlist& bl);
622+
int cls_rgw_lc_list_decode(const bufferlist& bl, std::vector<cls_rgw_lc_entry>& entries);
623623

624624
/* multipart */
625625
void cls_rgw_mp_upload_part_info_update(librados::ObjectWriteOperation& op, const std::string& part_key, const RGWUploadPartInfo& info);

src/rgw/driver/rados/rgw_bucket.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,6 +2781,7 @@ class RGWBucketInstanceMetadataHandler : public RGWBucketInstanceMetadataHandler
27812781
class RGWMetadataHandlerPut_BucketInstance : public RGWMetadataHandlerPut_SObj
27822782
{
27832783
CephContext *cct;
2784+
optional_yield y;
27842785
RGWBucketInstanceMetadataHandler *bihandler;
27852786
RGWBucketInstanceMetadataObject *obj;
27862787
public:
@@ -2790,7 +2791,7 @@ class RGWMetadataHandlerPut_BucketInstance : public RGWMetadataHandlerPut_SObj
27902791
RGWMetadataObject *_obj, RGWObjVersionTracker& objv_tracker,
27912792
optional_yield y,
27922793
RGWMDLogSyncType type, bool from_remote_zone) : RGWMetadataHandlerPut_SObj(_handler, _op, entry, _obj, objv_tracker, y, type, from_remote_zone),
2793-
cct(_cct), bihandler(_handler) {
2794+
cct(_cct), y(y), bihandler(_handler) {
27942795
obj = static_cast<RGWBucketInstanceMetadataObject *>(_obj);
27952796

27962797
auto& bci = obj->get_bci();
@@ -2947,7 +2948,7 @@ int RGWMetadataHandlerPut_BucketInstance::put_post(const DoutPrefixProvider *dpp
29472948
auto lc_it = bci.attrs.find(RGW_ATTR_LC);
29482949
if (lc_it != bci.attrs.end()) {
29492950
ldpp_dout(dpp, 20) << "set lc config for " << bci.info.bucket.name << dendl;
2950-
ret = lc->set_bucket_config(bucket.get(), bci.attrs, nullptr);
2951+
ret = lc->set_bucket_config(dpp, y, bucket.get(), bci.attrs, nullptr);
29512952
if (ret < 0) {
29522953
ldpp_dout(dpp, 0) << __func__ << " failed to set lc config for "
29532954
<< bci.info.bucket.name
@@ -2957,7 +2958,7 @@ int RGWMetadataHandlerPut_BucketInstance::put_post(const DoutPrefixProvider *dpp
29572958

29582959
} else {
29592960
ldpp_dout(dpp, 20) << "remove lc config for " << bci.info.bucket.name << dendl;
2960-
ret = lc->remove_bucket_config(bucket.get(), bci.attrs, false /* cannot merge attrs */);
2961+
ret = lc->remove_bucket_config(dpp, y, bucket.get(), bci.attrs, false /* cannot merge attrs */);
29612962
if (ret < 0) {
29622963
ldpp_dout(dpp, 0) << __func__ << " failed to remove lc config for "
29632964
<< bci.info.bucket.name

src/rgw/driver/rados/rgw_cr_tools.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int RGWBucketLifecycleConfigCR::Request::_send_request(const DoutPrefixProvider
115115
return -EIO;
116116
}
117117

118-
int ret = lc->set_bucket_config(params.bucket,
118+
int ret = lc->set_bucket_config(dpp, null_yield, params.bucket,
119119
params.bucket_attrs,
120120
&params.config);
121121
if (ret < 0) {

0 commit comments

Comments
 (0)