From 5a98f505fc4176f02b26673a0ab863b60c1ed92e Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 14 Feb 2024 09:43:14 -0500 Subject: [PATCH] rgw/putobj: RadosWriter uses part head object for multipart parts the cleanup logic in the RadosWrite destructor was using the wrong `head_obj` to avoid races between cleanup and part re-uploads. it pointed at the final location of the multipart upload, rather than the head object of the current part Fixes: https://tracker.ceph.com/issues/63642 Signed-off-by: Casey Bodley (cherry picked from commit bbbf5c54bdce3061ae9831c49fe065311a2e156d) Conflicts: rgw_putobj_processor.* uses sal::RGWObject instead of rgw_obj --- src/rgw/rgw_putobj_processor.cc | 8 ++++++++ src/rgw/rgw_putobj_processor.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index a4baa2308a370..e26f2949b6371 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -74,6 +74,11 @@ static int process_completed(const AioResultList& completed, RawObjSet *written) return error.value_or(0); } +void RadosWriter::set_head_obj(std::unique_ptr head) +{ + head_obj = std::move(head); +} + int RadosWriter::set_stripe_obj(const rgw_raw_obj& raw_obj) { stripe_obj = store->svc()->rados->obj(raw_obj); @@ -389,6 +394,9 @@ int MultipartObjectProcessor::prepare_head() head_obj->raw_obj_to_obj(stripe_obj); head_obj->set_hash_source(target_obj->get_name()); + // point part uploads at the part head instead of the final multipart head + writer.set_head_obj(head_obj->clone()); + r = writer.set_stripe_obj(stripe_obj); if (r < 0) { return r; diff --git a/src/rgw/rgw_putobj_processor.h b/src/rgw/rgw_putobj_processor.h index f6308ddb7fb2a..73fc0264b914c 100644 --- a/src/rgw/rgw_putobj_processor.h +++ b/src/rgw/rgw_putobj_processor.h @@ -104,6 +104,9 @@ class RadosWriter : public DataProcessor { ~RadosWriter(); + // change the head object + void set_head_obj(std::unique_ptr head); + // change the current stripe object int set_stripe_obj(const rgw_raw_obj& obj);