From: Yixin Jin Date: Thu, 12 Jan 2023 20:18:54 +0000 (+0000) Subject: rgw: Turn sync part_info_update CLS call to an async one X-Git-Tag: v18.1.0~360^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9996b02ffb62cb8adf0882cf064d82c493d2f498;p=ceph.git rgw: Turn sync part_info_update CLS call to an async one 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 --- diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index cda3e35d8612..4c3bcd53866e 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -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; diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index 08374b361391..73a79490a2d5 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -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) diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index 674533ae3dd2..139dbdb19395 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -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); diff --git a/src/rgw/driver/rados/rgw_putobj_processor.cc b/src/rgw/driver/rados/rgw_putobj_processor.cc index 4116b14a4d3b..1f4460e928ba 100644 --- a/src/rgw/driver/rados/rgw_putobj_processor.cc +++ b/src/rgw/driver/rados/rgw_putobj_processor.cc @@ -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; }