]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: PutObj initializes source bucket for copy-source 47266/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 2 Aug 2022 19:44:54 +0000 (15:44 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 4 Aug 2022 14:38:38 +0000 (10:38 -0400)
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 <cbodley@redhat.com>
src/rgw/rgw_op.cc

index 6ebc8dc89036bfb1b70e9b6f47a63c2a83d969ab..04f94f60f3f8d10f0888f95a4bf96beb857fbf14 100644 (file)
@@ -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<rgw::sal::RGWBucket> 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<rgw::sal::RGWObject> 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;