]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix lifecycle transition of encrypted multipart objects 68826/head
authorMarcus Watts <mwatts@redhat.com>
Sat, 25 May 2024 03:45:14 +0000 (23:45 -0400)
committerMatthew N. Heler <matthew.heler@hotmail.com>
Fri, 8 May 2026 16:11:40 +0000 (11:11 -0500)
Lifecycle transtion can copy objects to a different storage tier.
When this happens, since the object is repacked, the original
manifest is invalidated.  It is necessary to store a special
"parts_len" attribute to fix this.  There was code in PutObj
to handle this, but that was only used for multisite replication,
it is not used by the lifecycle transisiton code.  This fix
adds similar logic to the lifecycle transition code path to make the
same thing happen.

Fixes: https://tracker.ceph.com/issues/23264
Signed-off-by: Marcus Watts <mwatts@redhat.com>
(cherry picked from commit 77b86722300f2df7c1bf418c2f730b888d77f86a)

src/rgw/driver/rados/rgw_rados.cc

index 78466e4d74b4d1c374c4940ebc10c1dc4cb666f2..3faffc80fd2c1345aabe0215649e6b115a430712 100644 (file)
@@ -5347,6 +5347,35 @@ int RGWRados::copy_obj_data(RGWObjectCtx& obj_ctx,
                             log_op ? rgw::sal::FLAG_LOG_OP : 0);
 }
 
+int fixup_manifest_to_parts_len(const DoutPrefixProvider *dpp, rgw::sal::Attrs &src_attrs) {
+  auto iter = src_attrs.find(RGW_ATTR_MANIFEST);
+  if (iter == src_attrs.end()) {
+    return 0;
+  }
+
+  bufferlist &manifest_bl { iter->second };
+
+  // if the source object was encrypted, preserve the part lengths from
+  // the original object's manifest in RGW_ATTR_CRYPT_PARTS. if the object
+  // already replicated and has the RGW_ATTR_CRYPT_PARTS attr, preserve it
+  if (src_attrs.count(RGW_ATTR_CRYPT_MODE) &&
+      !src_attrs.count(RGW_ATTR_CRYPT_PARTS)) {
+    std::vector<size_t> parts_len;
+    int r = RGWGetObj_BlockDecrypt::read_manifest_parts(dpp, manifest_bl,
+                                                       parts_len);
+    if (r < 0) {
+      ldpp_dout(dpp, 0) << "failed to read part lengths from the manifest r=" << r << dendl;
+      return r;
+    }
+    // store the encoded part lenghts in RGW_ATTR_CRYPT_PARTS
+    bufferlist parts_bl;
+    encode(parts_len, parts_bl);
+    src_attrs[RGW_ATTR_CRYPT_PARTS] = std::move(parts_bl);
+  }
+
+  return 0;
+}
+
 int RGWRados::transition_obj(RGWObjectCtx& obj_ctx,
                              RGWBucketInfo& bucket_info,
                              rgw_obj obj,
@@ -5374,6 +5403,11 @@ int RGWRados::transition_obj(RGWObjectCtx& obj_ctx,
     return ret;
   }
 
+  ret = fixup_manifest_to_parts_len(dpp, attrs);
+  if (ret < 0) {
+    return ret;
+  }
+
   if (read_mtime != mtime) {
     /* raced */
     ldpp_dout(dpp, 0) << __func__ << " ERROR: failed to transition obj(" << obj.key << ") read_mtime = " << read_mtime << " doesn't match mtime = " << mtime << dendl;