cls_rgw: add client api calls for index suggest

This is needed for unitest creation.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
Yehuda Sadeh 2012-09-12 11:10:57 -07:00
parent d51d7b3416
commit b03adda4d9
3 changed files with 20 additions and 5 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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;
}