From 381594d0838bc4fa6f61762a954099f3396e1672 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 2 Aug 2022 15:44:54 -0400 Subject: [PATCH] rgw: PutObj initializes source bucket for copy-source cherry-picks one more thing from 72d1a363263cf707d022ee756122236ba175cda2 to resolve a crash in CopyObj Fixes: https://tracker.ceph.com/issues/56646 Signed-off-by: Casey Bodley --- src/rgw/rgw_op.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 6ebc8dc89036..04f94f60f3f8 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3898,11 +3898,17 @@ void RGWPutObj::execute(optional_yield y) } if ((! copy_source.empty()) && !copy_source_range) { - rgw::sal::RGWRadosObject obj(store, rgw_obj_key(copy_source_object_name, copy_source_version_id)); - rgw::sal::RGWRadosBucket bucket(store, copy_source_bucket_info); + std::unique_ptr bucket; + op_ret = store->get_bucket(nullptr, copy_source_bucket_info, &bucket); + if (op_ret < 0) { + ldpp_dout(this, 0) << "ERROR: failed to get bucket with error" << op_ret << dendl; + return; + } + std::unique_ptr obj = + bucket->get_object(rgw_obj_key(copy_source_object_name, copy_source_version_id)); RGWObjState *astate; - op_ret = obj.get_obj_state(this, &obj_ctx, bucket, &astate, s->yield); + op_ret = obj->get_obj_state(this, &obj_ctx, *bucket, &astate, s->yield); if (op_ret < 0) { ldpp_dout(this, 0) << "ERROR: get copy source obj state returned with error" << op_ret << dendl; return; -- 2.47.3