]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Turn sync part_info_update CLS call to an async one
authorYixin Jin <yjin77@yahoo.ca>
Thu, 12 Jan 2023 20:18:54 +0000 (20:18 +0000)
committerMykola Golub <mgolub@suse.com>
Tue, 13 Jun 2023 06:18:52 +0000 (07:18 +0100)
1. Use librados::ObjectWriteOperation to implement
the async CLS call.
2. Change the call to use the async CLS call.
3. Style update to be compliant

Signed-off-by: Yixin Jin <yjin77@yahoo.ca>
(cherry picked from commit 9996b02ffb62cb8adf0882cf064d82c493d2f498)

src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/rgw/rgw_putobj_processor.cc

index 6ef4d92d7645f79ee86dda0632930ae8163d035b..7d2b94903afec268765908473d1aab2a11dffd47 100644 (file)
@@ -4164,12 +4164,12 @@ static int rgw_mp_upload_part_info_update(cls_method_context_t hctx, bufferlist
   RGWUploadPartInfo stored_info;
 
   int ret = read_omap_entry(hctx, op.part_key, &stored_info);
-  if (ret < 0 and ret != -ENOENT) {
+  if (ret < 0 && ret != -ENOENT) {
     return ret;
   }
 
   /* merge all the prior (stored) manifest prefixes to carry forward */
-  if (not stored_info.manifest.empty()) {
+  if (!stored_info.manifest.empty()) {
     op.info.past_prefixes.insert(stored_info.manifest.get_prefix());
   }
   op.info.past_prefixes.merge(stored_info.past_prefixes);
@@ -4180,7 +4180,7 @@ static int rgw_mp_upload_part_info_update(cls_method_context_t hctx, bufferlist
     CLS_LOG(1, "ERROR: Current prefix %s is also a past prefix for part %s",
             op.info.manifest.get_prefix().c_str(),
             op.part_key.c_str());
-    return -EINVAL;
+    return -EEXIST;
   }
 
   bufferlist bl;
index d74a5d693c01d73a863ea7ec483e8fe982ab114e..4e16b4970ab8002796c4ee8bb356c51ba5cc19d3 100644 (file)
@@ -1068,24 +1068,18 @@ int cls_rgw_lc_list(IoCtx& io_ctx, const string& oid,
   return r;
 }
 
-int cls_rgw_mp_upload_part_info_update(librados::IoCtx& io_ctx,
-                                       const std::string& oid,
-                                       const std::string& part_key,
-                                       const RGWUploadPartInfo& info)
-{
-  buffer::list in, out;
-  cls_rgw_mp_upload_part_info_update_op op;
-
-  // For now, there doesn't appear to be a need for an encoded
-  // result -- we might in future want to return a copy of the final
-  // RGWUploadPartInfo
-  op.part_key = part_key;
-  op.info = info;
-  encode(op, in);
+void cls_rgw_mp_upload_part_info_update(librados::ObjectWriteOperation& op,
+                                        const std::string& part_key,
+                                        const RGWUploadPartInfo& info)
+{
+  cls_rgw_mp_upload_part_info_update_op call;
+  call.part_key = part_key;
+  call.info     = info;
 
-  int r = io_ctx.exec(oid, RGW_CLASS, RGW_MP_UPLOAD_PART_INFO_UPDATE, in, out);
-  return r;
+  buffer::list in;
+  encode(call, in);
+
+  op.exec(RGW_CLASS, RGW_MP_UPLOAD_PART_INFO_UPDATE, in);
 }
 
 void cls_rgw_reshard_add(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry)
index a82a12a2d0b8b6d62ffa30506d01ddc2f0422dc6..03ecb752a4473a250114e21bb96a80dc332cb737 100644 (file)
@@ -609,7 +609,7 @@ int cls_rgw_lc_list(librados::IoCtx& io_ctx, const std::string& oid,
 #endif
 
 /* multipart */
-int cls_rgw_mp_upload_part_info_update(librados::IoCtx& io_ctx, const std::string& oid, const std::string& part_key, const RGWUploadPartInfo& info);
+void cls_rgw_mp_upload_part_info_update(librados::ObjectWriteOperation& op, const std::string& part_key, const RGWUploadPartInfo& info);
 
 /* resharding */
 void cls_rgw_reshard_add(librados::ObjectWriteOperation& op, const cls_rgw_reshard_entry& entry);
index a6cb0f85c5d0152eced8b183e95ebc51a5102b07..8292df5bf5b62e0cb85abbaa1013990e76013d04 100644 (file)
@@ -13,6 +13,7 @@
  *
  */
 
+#include "include/rados/librados.hpp"
 #include "rgw_aio.h"
 #include "rgw_putobj_processor.h"
 #include "rgw_multi.h"
@@ -471,7 +472,6 @@ int MultipartObjectProcessor::complete(size_t accounted_size,
   if (r < 0)
     return r;
 
-  bufferlist bl;
   RGWUploadPartInfo info;
   string p = "part.";
   bool sorted_omap = is_v2_upload_id(upload_id);
@@ -512,9 +512,17 @@ int MultipartObjectProcessor::complete(size_t accounted_size,
     return r;
   }
 
-  r = cls_rgw_mp_upload_part_info_update(meta_obj_ref.pool.ioctx(), meta_obj_ref.obj.oid, p, info);
+  librados::ObjectWriteOperation op;
+  cls_rgw_mp_upload_part_info_update(op, p, info);
+  r = rgw_rados_operate(dpp, meta_obj_ref.pool.ioctx(), meta_obj_ref.obj.oid, &op, y);
   ldpp_dout(dpp, 20) << "Update meta: " << meta_obj_ref.obj.oid << " part " << p << " prefix " << info.manifest.get_prefix() << " return " << r << dendl;
 
+  if (r == -EOPNOTSUPP) {
+    // New CLS call to update part info is not yet supported. Fall back to the old handling.
+    bufferlist bl;
+    encode(info, bl);
+    r = meta_obj->omap_set_val_by_key(dpp, p, bl, true, null_yield);
+  }
   if (r < 0) {
     return r == -ENOENT ? -ERR_NO_SUCH_UPLOAD : r;
   }