]> 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 49709/head
authorYixin Jin <yjin77@yahoo.ca>
Thu, 12 Jan 2023 20:18:54 +0000 (20:18 +0000)
committerYixin Jin <yjin77@yahoo.ca>
Thu, 26 Jan 2023 19:42:41 +0000 (19:42 +0000)
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>
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/rgw/driver/rados/rgw_putobj_processor.cc

index cda3e35d861245f38b503c15b4f7a69a0f12b09c..4c3bcd53866ecf4ba6c1bb06e2859ee3c3fcad66 100644 (file)
@@ -4350,12 +4350,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);
@@ -4368,7 +4368,7 @@ static int rgw_mp_upload_part_info_update(cls_method_context_t hctx, bufferlist
             oi.soid.oid.name.c_str(),
             op.info.manifest.get_prefix().c_str(),
             op.part_key.c_str());
-    return -EINVAL;
+    return -EEXIST;
   }
 
   bufferlist bl;
index 08374b361391adca11fd5503199cf713fb78fa20..73a79490a2d52983787275c079fb1cf6ad9ce62e 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 674533ae3dd256a63938ac1d5311a9e979dcf428..139dbdb193955f4efbbbe1d82e277cb1a47e42f8 100644 (file)
@@ -619,7 +619,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 4116b14a4d3b55bbf81940ef5a01d3ab8ea6d4da..1f4460e928ba11897e19cb56ef41b65ac997ef77 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;
   }