From b2490b54479f72d9a6eb9a48f77ccf1a90754010 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 9 Sep 2014 11:18:43 -0700 Subject: [PATCH] rgw: bucket index link olh interface Signed-off-by: Yehuda Sadeh --- src/cls/rgw/cls_rgw_client.cc | 16 ++++++++++++++++ src/cls/rgw/cls_rgw_client.h | 3 +++ src/rgw/rgw_rados.cc | 26 ++++++++++++++++++++++++++ src/rgw/rgw_rados.h | 1 + 4 files changed, 46 insertions(+) diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index ccb30ebde7476..9c231f21149e6 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -93,6 +93,22 @@ int cls_rgw_list_op(IoCtx& io_ctx, const string& oid, return r; } +int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, + bool delete_marker, const string& op_tag) +{ + bufferlist in, out; + struct cls_rgw_link_olh_op call; + call.key = key; + call.op_tag = op_tag; + call.delete_marker = delete_marker; + ::encode(call, in); + int r = io_ctx.exec(oid, "rgw", "bucket_link_olh", in, out); + if (r < 0) + return r; + + return 0; +} + int cls_rgw_bucket_check_index_op(IoCtx& io_ctx, string& oid, rgw_bucket_dir_header *existing_header, rgw_bucket_dir_header *calculated_header) diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index c7f31d8eb411c..3953c26f9c249 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -31,6 +31,9 @@ int cls_rgw_list_op(librados::IoCtx& io_ctx, const string& oid, const string& filter_prefix, uint32_t num_entries, rgw_bucket_dir *dir, bool *is_truncated); +int cls_rgw_bucket_link_olh(librados::IoCtx& io_ctx, const string& oid, const cls_rgw_obj_key& key, + bool delete_marker, const string& op_tag); + int cls_rgw_bucket_check_index_op(librados::IoCtx& io_ctx, string& oid, rgw_bucket_dir_header *existing_header, rgw_bucket_dir_header *calculated_header); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 351bd903a0f6f..802b6b877d7f0 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5259,6 +5259,32 @@ int RGWRados::olh_init_modification(rgw_obj& obj, string *tag) return 0; } +int RGWRados::bucket_index_link_olh(rgw_obj& obj_instance, bool delete_marker, const string& op_tag) +{ + rgw_rados_ref ref; + rgw_bucket bucket; + int r = get_obj_ref(obj_instance, &ref, &bucket); + if (r < 0) { + return r; + } + + librados::IoCtx index_ctx; + string oid; + + int ret = open_bucket_index(bucket, index_ctx, oid); + if (ret < 0) { + return ret; + } + + cls_rgw_obj_key key(obj_instance.get_index_key_name(), obj_instance.get_instance()); + ret = cls_rgw_bucket_link_olh(index_ctx, oid, key, delete_marker, op_tag); + if (ret < 0) { + return ret; + } + + return 0; +} + static void filter_attrset(map& unfiltered_attrset, const string& check_prefix, map *attrset) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 902a911df3dd8..c60a9bed56727 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1750,6 +1750,7 @@ public: int obj_operate(rgw_obj& obj, librados::ObjectReadOperation *op); int olh_init_modification(rgw_obj& obj, string *tag); + int bucket_index_link_olh(rgw_obj& obj_instance, bool delete_marker, const string& op_tag); int follow_olh(map& attrset, rgw_obj& target); int get_olh(rgw_obj& obj, RGWOLHInfo *olh); -- 2.39.5