From: Daniel Gryniewicz Date: Thu, 27 Jun 2024 16:40:38 +0000 (-0400) Subject: RGW - Fix copy_obj handling of obj_ctx X-Git-Tag: v18.2.5~111^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fc11e2a574b17ebb6e94182aae6daabf6564e101;p=ceph.git 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 Signed-off-by: Gabriel BenHanokh (cherry picked from commit 111c54a19dc12b84cda785feddb0a0ba483b1f77) Conflicts: from rgw_owner changes to RGWRados::copy_obj() src/rgw/driver/rados/rgw_rados.cc src/rgw/driver/rados/rgw_rados.h src/rgw/driver/rados/rgw_sal_rados.cc --- diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 0f29820f85a9..5c303469f48a 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -2865,6 +2865,7 @@ int RGWRados::swift_versioning_copy(RGWObjectCtx& obj_ctx, rgw_zone_id no_zone; r = copy_obj(obj_ctx, + obj_ctx, /* src and dest share an obj_ctx */ user, NULL, /* req_info *info */ no_zone, @@ -2959,6 +2960,7 @@ int RGWRados::swift_versioning_restore(RGWObjectCtx& obj_ctx, obj_ctx.set_atomic(obj); int ret = copy_obj(obj_ctx, + obj_ctx, /* src and dest share an obj_ctx */ user, nullptr, /* req_info *info */ no_zone, @@ -3875,7 +3877,7 @@ int RGWFetchObjFilter_Default::filter(CephContext *cct, return 0; } -int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, +int RGWRados::fetch_remote_obj(RGWObjectCtx& dest_obj_ctx, const rgw_user& user_id, req_info *info, const rgw_zone_id& source_zone, @@ -3922,7 +3924,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, rgw::BlockingAioThrottle aio(cct->_conf->rgw_put_obj_min_window_size); using namespace rgw::putobj; AtomicObjectProcessor processor(&aio, this, dest_bucket_info, nullptr, - user_id, obj_ctx, dest_obj, olh_epoch, + user_id, dest_obj_ctx, dest_obj, olh_epoch, tag, dpp, null_yield); RGWRESTConn *conn; auto& zone_conn_map = svc.zone->get_zone_conn_map(); @@ -4006,7 +4008,7 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, if (copy_if_newer) { /* need to get mtime for destination */ - ret = get_obj_state(dpp, &obj_ctx, dest_bucket_info, stat_dest_obj, &dest_state, &manifest, stat_follow_olh, null_yield); + ret = get_obj_state(dpp, &dest_obj_ctx, dest_bucket_info, stat_dest_obj, &dest_state, &manifest, stat_follow_olh, null_yield); if (ret < 0) goto set_err_state; @@ -4209,8 +4211,8 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx, if (copy_if_newer && canceled) { ldpp_dout(dpp, 20) << "raced with another write of obj: " << dest_obj << dendl; - obj_ctx.invalidate(dest_obj); /* object was overwritten */ - ret = get_obj_state(dpp, &obj_ctx, dest_bucket_info, stat_dest_obj, &dest_state, &manifest, stat_follow_olh, null_yield); + dest_obj_ctx.invalidate(dest_obj); /* object was overwritten */ + ret = get_obj_state(dpp, &dest_obj_ctx, dest_bucket_info, stat_dest_obj, &dest_state, &manifest, stat_follow_olh, null_yield); if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR: " << __func__ << ": get_err_state() returned ret=" << ret << dendl; goto set_err_state; @@ -4244,7 +4246,7 @@ set_err_state: // for OP_LINK_OLH to call set_olh() with a real olh_epoch if (olh_epoch && *olh_epoch > 0) { constexpr bool log_data_change = true; - ret = set_olh(dpp, obj_ctx, dest_bucket_info, dest_obj, false, nullptr, + ret = set_olh(dpp, dest_obj_ctx, dest_bucket_info, dest_obj, false, nullptr, *olh_epoch, real_time(), false, null_yield, zones_trace, log_data_change); } else { // we already have the latest copy @@ -4310,7 +4312,8 @@ int RGWRados::copy_obj_to_remote_dest(const DoutPrefixProvider *dpp, * err: stores any errors resulting from the get of the original object * Returns: 0 on success, -ERR# otherwise. */ -int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, +int RGWRados::copy_obj(RGWObjectCtx& src_obj_ctx, + RGWObjectCtx& dest_obj_ctx, const rgw_user& user_id, req_info *info, const rgw_zone_id& source_zone, @@ -4368,7 +4371,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, if (remote_src || !source_zone.empty()) { rgw_zone_set_entry source_trace_entry{source_zone.id, std::nullopt}; - return fetch_remote_obj(obj_ctx, user_id, info, source_zone, + return fetch_remote_obj(dest_obj_ctx, user_id, info, source_zone, dest_obj, src_obj, dest_bucket_info, &src_bucket_info, dest_placement, src_mtime, mtime, mod_ptr, unmod_ptr, high_precision_time, @@ -4378,7 +4381,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, } map src_attrs; - RGWRados::Object src_op_target(this, src_bucket_info, obj_ctx, src_obj); + RGWRados::Object src_op_target(this, src_bucket_info, src_obj_ctx, src_obj); RGWRados::Object::Read read_op(&src_op_target); read_op.conds.mod_ptr = mod_ptr; @@ -4437,7 +4440,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, RGWObjState *astate = NULL; RGWObjManifest *amanifest = nullptr; - ret = get_obj_state(dpp, &obj_ctx, src_bucket_info, src_obj, &astate, &amanifest, y); + ret = get_obj_state(dpp, &src_obj_ctx, src_bucket_info, src_obj, &astate, &amanifest, y); if (ret < 0) { return ret; } @@ -4513,7 +4516,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */ attrs.erase(RGW_ATTR_TAIL_TAG); - return copy_obj_data(obj_ctx, dest_bucket_info, dest_placement, read_op, obj_size - 1, dest_obj, + return copy_obj_data(dest_obj_ctx, dest_bucket_info, dest_placement, read_op, obj_size - 1, dest_obj, mtime, real_time(), attrs, olh_epoch, delete_at, petag, dpp, y); } @@ -4530,7 +4533,7 @@ int RGWRados::copy_obj(RGWObjectCtx& obj_ctx, RGWObjManifest *pmanifest; ldpp_dout(dpp, 20) << "dest_obj=" << dest_obj << " src_obj=" << src_obj << " copy_itself=" << (int)copy_itself << dendl; - RGWRados::Object dest_op_target(this, dest_bucket_info, obj_ctx, dest_obj); + RGWRados::Object dest_op_target(this, dest_bucket_info, dest_obj_ctx, dest_obj); RGWRados::Object::Write write_op(&dest_op_target); string tag; diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index c3dc5a4f45b8..146eac2de588 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -1112,7 +1112,7 @@ public: std::string *ptag, std::string *petag); - int fetch_remote_obj(RGWObjectCtx& obj_ctx, + int fetch_remote_obj(RGWObjectCtx& dest_obj_ctx, const rgw_user& user_id, req_info *info, const rgw_zone_id& source_zone, @@ -1159,7 +1159,8 @@ public: * are overwritten by values contained in attrs parameter. * Returns: 0 on success, -ERR# otherwise. */ - int copy_obj(RGWObjectCtx& obj_ctx, + int copy_obj(RGWObjectCtx& src_obj_ctx, + RGWObjectCtx& dest_obj_ctx, const rgw_user& user_id, req_info *info, const rgw_zone_id& source_zone, diff --git a/src/rgw/driver/rados/rgw_sal_rados.cc b/src/rgw/driver/rados/rgw_sal_rados.cc index 4b727b31b120..0dcf2c022f8b 100644 --- a/src/rgw/driver/rados/rgw_sal_rados.cc +++ b/src/rgw/driver/rados/rgw_sal_rados.cc @@ -2335,6 +2335,7 @@ int RadosObject::copy_object(User* user, optional_yield y) { return store->getRados()->copy_obj(*rados_ctx, + *static_cast(dest_object)->rados_ctx, user->get_id(), info, source_zone,