Skip to content

Commit

Permalink
rgw: Turn sync part_info_update CLS call to an async one
Browse files Browse the repository at this point in the history
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 9996b02)
  • Loading branch information
yima77 authored and trociny committed Jun 13, 2023
1 parent f17d379 commit d82fa08
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/cls/rgw/cls_rgw.cc
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
28 changes: 11 additions & 17 deletions src/cls/rgw/cls_rgw_client.cc
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/cls/rgw/cls_rgw_client.h
Expand Up @@ -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);
Expand Down
12 changes: 10 additions & 2 deletions src/rgw/rgw_putobj_processor.cc
Expand Up @@ -13,6 +13,7 @@
*
*/

#include "include/rados/librados.hpp"
#include "rgw_aio.h"
#include "rgw_putobj_processor.h"
#include "rgw_multi.h"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d82fa08

Please sign in to comment.