Skip to content

Commit 111c54a

Browse files
dangbenhanokh
authored andcommitted
RGW - Fix copy_obj handling of obj_ctx
Fixes: https://tracker.ceph.com/issues/66286 (Line added by Gabriel) In RadosStore, the source and dest objects in the copy_object() call used to share an obj_ctx. When obj_ctx was removed from the SAL API, they each got their own, but RGWRados::copy_obj() still assumed they shared one. Pass in each one separately, and use the correct one for further calls. Signed-off-by: Daniel Gryniewicz <[email protected]> Signed-off-by: Gabriel BenHanokh <[email protected]>
1 parent d496d20 commit 111c54a

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2915,6 +2915,7 @@ int RGWRados::swift_versioning_copy(RGWObjectCtx& obj_ctx,
29152915
jspan_context no_trace{false, false};
29162916

29172917
r = copy_obj(obj_ctx,
2918+
obj_ctx, /* src and dest share an obj_ctx */
29182919
owner,
29192920
remote_user,
29202921
NULL, /* req_info *info */
@@ -3014,6 +3015,7 @@ int RGWRados::swift_versioning_restore(RGWObjectCtx& obj_ctx,
30143015
jspan_context no_trace{false, false};
30153016

30163017
int ret = copy_obj(obj_ctx,
3018+
obj_ctx, /* src and dest share an obj_ctx */
30173019
owner,
30183020
remote_user,
30193021
nullptr, /* req_info *info */
@@ -4154,7 +4156,7 @@ int RGWFetchObjFilter_Default::filter(CephContext *cct,
41544156
return 0;
41554157
}
41564158

4157-
int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
4159+
int RGWRados::fetch_remote_obj(RGWObjectCtx& dest_obj_ctx,
41584160
const rgw_user& user_id,
41594161
req_info *info,
41604162
const rgw_zone_id& source_zone,
@@ -4206,7 +4208,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
42064208
using namespace rgw::putobj;
42074209
jspan_context no_trace{false, false};
42084210
AtomicObjectProcessor processor(&aio, this, dest_bucket_info, nullptr,
4209-
owner, obj_ctx, dest_obj, olh_epoch,
4211+
owner, dest_obj_ctx, dest_obj, olh_epoch,
42104212
tag, rctx.dpp, rctx.y, no_trace);
42114213
RGWRESTConn *conn;
42124214
auto& zone_conn_map = svc.zone->get_zone_conn_map();
@@ -4290,7 +4292,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
42904292

42914293
if (copy_if_newer) {
42924294
/* need to get mtime for destination */
4293-
ret = get_obj_state(rctx.dpp, &obj_ctx, dest_bucket_info, stat_dest_obj, &dest_state, &manifest, stat_follow_olh, rctx.y);
4295+
ret = get_obj_state(rctx.dpp, &dest_obj_ctx, dest_bucket_info, stat_dest_obj, &dest_state, &manifest, stat_follow_olh, rctx.y);
42944296
if (ret < 0)
42954297
goto set_err_state;
42964298

@@ -4499,8 +4501,8 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
44994501

45004502
if (copy_if_newer && canceled) {
45014503
ldpp_dout(rctx.dpp, 20) << "raced with another write of obj: " << dest_obj << dendl;
4502-
obj_ctx.invalidate(dest_obj); /* object was overwritten */
4503-
ret = get_obj_state(rctx.dpp, &obj_ctx, dest_bucket_info, stat_dest_obj, &dest_state, &manifest, stat_follow_olh, rctx.y);
4504+
dest_obj_ctx.invalidate(dest_obj); /* object was overwritten */
4505+
ret = get_obj_state(rctx.dpp, &dest_obj_ctx, dest_bucket_info, stat_dest_obj, &dest_state, &manifest, stat_follow_olh, rctx.y);
45044506
if (ret < 0) {
45054507
ldpp_dout(rctx.dpp, 0) << "ERROR: " << __func__ << ": get_err_state() returned ret=" << ret << dendl;
45064508
goto set_err_state;
@@ -4534,7 +4536,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
45344536
// for OP_LINK_OLH to call set_olh() with a real olh_epoch
45354537
if (olh_epoch && *olh_epoch > 0) {
45364538
constexpr bool log_data_change = true;
4537-
ret = set_olh(rctx.dpp, obj_ctx, dest_bucket_info, dest_obj, false, nullptr,
4539+
ret = set_olh(rctx.dpp, dest_obj_ctx, dest_bucket_info, dest_obj, false, nullptr,
45384540
*olh_epoch, real_time(), false, rctx.y, zones_trace, log_data_change);
45394541
} else {
45404542
// we already have the latest copy
@@ -4609,7 +4611,8 @@ int RGWRados::copy_obj_to_remote_dest(const DoutPrefixProvider *dpp,
46094611
* err: stores any errors resulting from the get of the original object
46104612
* Returns: 0 on success, -ERR# otherwise.
46114613
*/
4612-
int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
4614+
int RGWRados::copy_obj(RGWObjectCtx& src_obj_ctx,
4615+
RGWObjectCtx& dest_obj_ctx,
46134616
const ACLOwner& owner,
46144617
const rgw_user& remote_user,
46154618
req_info *info,
@@ -4670,7 +4673,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
46704673
if (remote_src || !source_zone.empty()) {
46714674
rgw_zone_set_entry source_trace_entry{source_zone.id, std::nullopt};
46724675
const req_context rctx{dpp, y, nullptr};
4673-
return fetch_remote_obj(obj_ctx, remote_user, info, source_zone,
4676+
return fetch_remote_obj(dest_obj_ctx, remote_user, info, source_zone,
46744677
dest_obj, src_obj, dest_bucket_info, &src_bucket_info,
46754678
dest_placement, src_mtime, mtime, mod_ptr,
46764679
unmod_ptr, high_precision_time,
@@ -4680,7 +4683,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
46804683
}
46814684

46824685
map<string, bufferlist> src_attrs;
4683-
RGWRados::Object src_op_target(this, src_bucket_info, obj_ctx, src_obj);
4686+
RGWRados::Object src_op_target(this, src_bucket_info, src_obj_ctx, src_obj);
46844687
RGWRados::Object::Read read_op(&src_op_target);
46854688

46864689
read_op.conds.mod_ptr = mod_ptr;
@@ -4737,7 +4740,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
47374740
RGWObjManifest *amanifest = nullptr;
47384741

47394742
constexpr bool follow_olh = true;
4740-
ret = get_obj_state(dpp, &obj_ctx, src_bucket_info, src_obj,
4743+
ret = get_obj_state(dpp, &src_obj_ctx, src_bucket_info, src_obj,
47414744
&astate, &amanifest, follow_olh, y);
47424745
if (ret < 0) {
47434746
return ret;
@@ -4814,7 +4817,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
48144817

48154818
if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */
48164819
attrs.erase(RGW_ATTR_TAIL_TAG);
4817-
return copy_obj_data(obj_ctx, owner, dest_bucket_info, dest_placement, read_op, obj_size - 1, dest_obj,
4820+
return copy_obj_data(dest_obj_ctx, owner, dest_bucket_info, dest_placement, read_op, obj_size - 1, dest_obj,
48184821
mtime, real_time(), attrs, olh_epoch, delete_at, petag, dpp, y);
48194822
}
48204823

@@ -4831,7 +4834,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx,
48314834
RGWObjManifest *pmanifest;
48324835
ldpp_dout(dpp, 20) << "dest_obj=" << dest_obj << " src_obj=" << src_obj << " copy_itself=" << (int)copy_itself << dendl;
48334836

4834-
RGWRados::Object dest_op_target(this, dest_bucket_info, obj_ctx, dest_obj);
4837+
RGWRados::Object dest_op_target(this, dest_bucket_info, dest_obj_ctx, dest_obj);
48354838
RGWRados::Object::Write write_op(&dest_op_target);
48364839

48374840
string tag;

src/rgw/driver/rados/rgw_rados.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ class RGWRados
11331133
std::string *ptag,
11341134
std::string *petag, optional_yield y);
11351135

1136-
int fetch_remote_obj(RGWObjectCtx& obj_ctx,
1136+
int fetch_remote_obj(RGWObjectCtx& dest_obj_ctx,
11371137
const rgw_user& user_id,
11381138
req_info *info,
11391139
const rgw_zone_id& source_zone,
@@ -1180,7 +1180,8 @@ class RGWRados
11801180
* are overwritten by values contained in attrs parameter.
11811181
* Returns: 0 on success, -ERR# otherwise.
11821182
*/
1183-
int copy_obj(RGWObjectCtx& obj_ctx,
1183+
int copy_obj(RGWObjectCtx& src_obj_ctx,
1184+
RGWObjectCtx& dest_obj_ctx,
11841185
const ACLOwner& owner, // owner of destination object
11851186
const rgw_user& remote_user, // uid for fetch_remote_obj() auth
11861187
req_info *info,

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,6 +2903,7 @@ int RadosObject::copy_object(const ACLOwner& owner,
29032903
optional_yield y)
29042904
{
29052905
return store->getRados()->copy_obj(*rados_ctx,
2906+
*static_cast<RadosObject*>(dest_object)->rados_ctx,
29062907
owner,
29072908
remote_user,
29082909
info,

0 commit comments

Comments
 (0)