From b03adda4d9bb369ffe8cb41288473c3d43f24f9d Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 12 Sep 2012 11:10:57 -0700 Subject: [PATCH] cls_rgw: add client api calls for index suggest This is needed for unitest creation. Signed-off-by: Yehuda Sadeh --- src/cls/rgw/cls_rgw_client.cc | 11 +++++++++++ src/cls/rgw/cls_rgw_client.h | 4 ++++ src/rgw/rgw_rados.cc | 10 +++++----- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index 29cf389431b09..1e7c7d01c39c3 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -66,6 +66,17 @@ int cls_rgw_list_op(IoCtx& io_ctx, string& oid, string& start_obj, return r; } +void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, bufferlist& updates) +{ + updates.append(op); + ::encode(dirent, updates); +} + +void cls_rgw_suggest_changes(ObjectWriteOperation& o, bufferlist& updates) +{ + o.exec("rgw", "dir_suggest_changes", updates); +} + int cls_rgw_get_dir_header(IoCtx& io_ctx, string& oid, rgw_bucket_dir_header *header) { bufferlist in, out; diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index 50b8125e8b13e..fec37da53ed4c 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -18,6 +18,10 @@ int cls_rgw_list_op(librados::IoCtx& io_ctx, string& oid, string& start_obj, int cls_rgw_get_dir_header(librados::IoCtx& io_ctx, string& oid, rgw_bucket_dir_header *header); +void cls_rgw_encode_suggestion(char op, rgw_bucket_dir_entry& dirent, bufferlist& updates); + +void cls_rgw_suggest_changes(librados::ObjectWriteOperation& o, bufferlist& updates); + /* usage logging */ int cls_rgw_usage_log_read(librados::IoCtx& io_ctx, string& oid, string& user, uint64_t start_epoch, uint64_t end_epoch, uint32_t max_entries, diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 2b6d471505204..3864bdd07f2d4 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2866,9 +2866,11 @@ int RGWRados::cls_bucket_list(rgw_bucket& bucket, string start, string prefix, } if (updates.length()) { + ObjectWriteOperation o; + cls_rgw_suggest_changes(o, updates); // we don't care if we lose suggested updates, send them off blindly AioCompletion *c = librados::Rados::aio_create_completion(NULL, NULL, NULL); - r = io_ctx.aio_exec(oid, c, "rgw", "dir_suggest_changes", updates, NULL); + r = io_ctx.aio_operate(oid, c, &o); c->release(); } return m.size(); @@ -2961,8 +2963,7 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx, } // encode a suggested removal of that key list_state.epoch = io_ctx.get_last_version(); - suggested_updates.append(CEPH_RGW_REMOVE); - ::encode(list_state, suggested_updates); + cls_rgw_encode_suggestion(CEPH_RGW_REMOVE, list_state, suggested_updates); } if (r < 0) return r; @@ -2971,8 +2972,7 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx, list_state.epoch = io_ctx.get_last_version(); list_state.meta.size = object.size; list_state.meta.mtime.set_from_double(double(object.mtime)); - suggested_updates.append(CEPH_RGW_UPDATE); - ::encode(list_state, suggested_updates); + cls_rgw_encode_suggestion(CEPH_RGW_UPDATE, list_state, suggested_updates); return 0; } -- 2.39.5