From: J. Eric Ivancich Date: Wed, 5 Dec 2018 15:18:22 +0000 (-0500) Subject: rgw: clean-up use enum class for stats category X-Git-Tag: v14.1.0~522^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c52636c84fd3eaf3db02cfe73cb3570b81803403;p=ceph.git rgw: clean-up use enum class for stats category The stats entries for rgw buckets has a category, which used a combination of uint8_t and enum RGWObjClass. Clean this up by converting RGWObjClass to an enum class and using that throughout. This provides type safety and better code clarity. Also, add some source code documentation. Signed-off-by: J. Eric Ivancich --- diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 3bb5d0fff484..cbccae331988 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -484,7 +484,9 @@ int rgw_bucket_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out) return 0; } -static int check_index(cls_method_context_t hctx, struct rgw_bucket_dir_header *existing_header, struct rgw_bucket_dir_header *calc_header) +static int check_index(cls_method_context_t hctx, + rgw_bucket_dir_header *existing_header, + rgw_bucket_dir_header *calc_header) { int rc = read_bucket_header(hctx, existing_header); if (rc < 0) { @@ -515,7 +517,7 @@ static int check_index(cls_method_context_t hctx, struct rgw_bucket_dir_header * break; } - struct rgw_bucket_dir_entry entry; + rgw_bucket_dir_entry entry; auto eiter = kiter->second.cbegin(); try { decode(entry, eiter); @@ -523,7 +525,7 @@ static int check_index(cls_method_context_t hctx, struct rgw_bucket_dir_header * CLS_LOG(1, "ERROR: rgw_bucket_list(): failed to decode entry, key=%s\n", kiter->first.c_str()); return -EIO; } - struct rgw_bucket_category_stats& stats = calc_header->stats[entry.meta.category]; + rgw_bucket_category_stats& stats = calc_header->stats[entry.meta.category]; stats.num_entries++; stats.total_size += entry.meta.accounted_size; stats.total_size_rounded += cls_rgw_get_rounded_size(entry.meta.accounted_size); @@ -955,8 +957,11 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist remove_key.name.c_str(), remove_key.instance.c_str(), ret); continue; } - CLS_LOG(0, "rgw_bucket_complete_op(): entry.name=%s entry.instance=%s entry.meta.category=%d\n", - remove_entry.key.name.c_str(), remove_entry.key.instance.c_str(), remove_entry.meta.category); + CLS_LOG(0, + "rgw_bucket_complete_op(): entry.name=%s entry.instance=%s entry.meta.category=%d\n", + remove_entry.key.name.c_str(), + remove_entry.key.instance.c_str(), + int(remove_entry.meta.category)); unaccount_entry(header, remove_entry); if (op.log_op && !header.syncstopped) { @@ -2237,7 +2242,8 @@ static int rgw_bi_get_op(cls_method_context_t hctx, bufferlist *in, bufferlist * encode_olh_data_key(op.key, &idx); break; default: - CLS_LOG(10, "%s(): invalid key type encoding: %d", __func__, op.type); + CLS_LOG(10, "%s(): invalid key type encoding: %d", + __func__, int(op.type)); return -EINVAL; } diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index b074fa409716..da9c43508d9d 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -153,8 +153,9 @@ int CLSRGWIssueSetTagTimeout::issue_op(int shard_id, const string& oid) return issue_bucket_set_tag_timeout_op(io_ctx, oid, tag_timeout, &manager); } -void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o, bool absolute, - const map& stats) +void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o, + bool absolute, + const map& stats) { struct rgw_cls_bucket_update_stats_op call; call.absolute = absolute; diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index f731a15ea218..07e7211b83d8 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -343,8 +343,9 @@ public: CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio), tag_timeout(_tag_timeout) {} }; -void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o, bool absolute, - const map& stats); +void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o, + bool absolute, + const map& stats); void cls_rgw_bucket_prepare_op(librados::ObjectWriteOperation& o, RGWModifyOp op, string& tag, const cls_rgw_obj_key& key, const string& locator, bool log_op, diff --git a/src/cls/rgw/cls_rgw_ops.cc b/src/cls/rgw/cls_rgw_ops.cc index 53eb55e32d84..713cee413f8e 100644 --- a/src/cls/rgw/cls_rgw_ops.cc +++ b/src/cls/rgw/cls_rgw_ops.cc @@ -354,7 +354,7 @@ void rgw_cls_bucket_update_stats_op::generate_test_instances(listabsolute = true; - rgw_bucket_category_stats& s = r->stats[0]; + rgw_bucket_category_stats& s = r->stats[RGWObjCategory::None]; s.total_size = 1; s.total_size_rounded = 4096; s.num_entries = 1; diff --git a/src/cls/rgw/cls_rgw_ops.h b/src/cls/rgw/cls_rgw_ops.h index 04c3ce366b0d..7e449b36dc61 100644 --- a/src/cls/rgw/cls_rgw_ops.h +++ b/src/cls/rgw/cls_rgw_ops.h @@ -463,7 +463,7 @@ WRITE_CLASS_ENCODER(rgw_cls_check_index_ret) struct rgw_cls_bucket_update_stats_op { bool absolute{false}; - map stats; + map stats; rgw_cls_bucket_update_stats_op() {} diff --git a/src/cls/rgw/cls_rgw_types.cc b/src/cls/rgw/cls_rgw_types.cc index 891c663ffa94..5b400d35718f 100644 --- a/src/cls/rgw/cls_rgw_types.cc +++ b/src/cls/rgw/cls_rgw_types.cc @@ -41,7 +41,7 @@ void cls_rgw_obj_key::decode_json(JSONObj *obj) { void rgw_bucket_dir_entry_meta::generate_test_instances(list& o) { rgw_bucket_dir_entry_meta *m = new rgw_bucket_dir_entry_meta; - m->category = 1; + m->category = RGWObjCategory::Main; m->size = 100; m->etag = "etag"; m->owner = "owner"; @@ -68,7 +68,7 @@ void rgw_bucket_dir_entry_meta::dump(Formatter *f) const void rgw_bucket_dir_entry_meta::decode_json(JSONObj *obj) { int val; JSONDecoder::decode_json("category", val, obj); - category = (uint8_t)val; + category = static_cast(val); JSONDecoder::decode_json("size", size, obj); utime_t ut; JSONDecoder::decode_json("mtime", ut, obj); @@ -242,7 +242,9 @@ void rgw_cls_bi_entry::dump(Formatter *f) const dump_bi_entry(data, type, f); } -bool rgw_cls_bi_entry::get_info(cls_rgw_obj_key *key, uint8_t *category, rgw_bucket_category_stats *accounted_stats) +bool rgw_cls_bi_entry::get_info(cls_rgw_obj_key *key, + RGWObjCategory *category, + rgw_bucket_category_stats *accounted_stats) { bool account = false; auto iter = data.cbegin(); @@ -509,9 +511,10 @@ void rgw_bucket_dir_header::generate_test_instances(list uint8_t i; for (i = 0, iter = l.begin(); iter != l.end(); ++iter, ++i) { + RGWObjCategory c = static_cast(i); rgw_bucket_dir_header *h = new rgw_bucket_dir_header; rgw_bucket_category_stats *s = *iter; - h->stats[i] = *s; + h->stats[c] = *s; o.push_back(h); @@ -525,10 +528,9 @@ void rgw_bucket_dir_header::dump(Formatter *f) const { f->dump_int("ver", ver); f->dump_int("master_ver", master_ver); - map::const_iterator iter = stats.begin(); f->open_array_section("stats"); - for (; iter != stats.end(); ++iter) { - f->dump_int("category", (int)iter->first); + for (auto iter = stats.begin(); iter != stats.end(); ++iter) { + f->dump_int("category", int(iter->first)); f->open_object_section("category_stats"); iter->second.dump(f); f->close_section(); diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 0d666f8a0ca1..a0f71f18f3ab 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -91,8 +91,26 @@ struct rgw_bucket_pending_info { }; WRITE_CLASS_ENCODER(rgw_bucket_pending_info) + +// categories of objects stored in a bucket index (b-i) and used to +// differentiate their associated statistics (bucket stats, and in +// some cases user stats) +enum class RGWObjCategory : uint8_t { + None = 0, // b-i entries for delete markers; also used in + // testing and for default values in default + // constructors + + Main = 1, // b-i entries for standard objs + + Shadow = 2, // presumfably intended for multipart shadow + // uploads; not currently used in the codebase + + MultiMeta = 3, // b-i entries for multipart upload metadata objs +}; + + struct rgw_bucket_dir_entry_meta { - uint8_t category; + RGWObjCategory category; uint64_t size; ceph::real_time mtime; string etag; @@ -103,7 +121,7 @@ struct rgw_bucket_dir_entry_meta { string user_data; rgw_bucket_dir_entry_meta() : - category(0), size(0), accounted_size(0) { } + category(RGWObjCategory::None), size(0), accounted_size(0) { } void encode(bufferlist &bl) const { ENCODE_START(5, 3, bl); @@ -419,7 +437,8 @@ struct rgw_cls_bi_entry { void dump(Formatter *f) const; void decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key = NULL); - bool get_info(cls_rgw_obj_key *key, uint8_t *category, rgw_bucket_category_stats *accounted_stats); + bool get_info(cls_rgw_obj_key *key, RGWObjCategory *category, + rgw_bucket_category_stats *accounted_stats); }; WRITE_CLASS_ENCODER(rgw_cls_bi_entry) @@ -680,7 +699,7 @@ struct cls_rgw_bucket_instance_entry { WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry) struct rgw_bucket_dir_header { - map stats; + map stats; uint64_t tag_timeout; uint64_t ver; uint64_t master_ver; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index fd530ad5e672..204a9c96c4cf 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -286,13 +286,6 @@ enum RGWIntentEvent { DEL_DIR = 1, }; -enum RGWObjCategory { - RGW_OBJ_CATEGORY_NONE = 0, - RGW_OBJ_CATEGORY_MAIN = 1, - RGW_OBJ_CATEGORY_SHADOW = 2, - RGW_OBJ_CATEGORY_MULTIMETA = 3, -}; - enum HostStyle { PathStyle = 0, VirtualStyle = 1, @@ -1472,7 +1465,7 @@ struct RGWStorageStats uint64_t num_objects; RGWStorageStats() - : category(RGW_OBJ_CATEGORY_NONE), + : category(RGWObjCategory::None), size(0), size_rounded(0), num_objects(0) {} @@ -2257,13 +2250,13 @@ static inline void append_rand_alpha(CephContext *cct, const string& src, string static inline const char *rgw_obj_category_name(RGWObjCategory category) { switch (category) { - case RGW_OBJ_CATEGORY_NONE: + case RGWObjCategory::None: return "rgw.none"; - case RGW_OBJ_CATEGORY_MAIN: + case RGWObjCategory::Main: return "rgw.main"; - case RGW_OBJ_CATEGORY_SHADOW: + case RGWObjCategory::Shadow: return "rgw.shadow"; - case RGW_OBJ_CATEGORY_MULTIMETA: + case RGWObjCategory::MultiMeta: return "rgw.multimeta"; } diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 0fc0d8a20202..e2e343832b7b 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -602,7 +602,7 @@ int RGWAsyncFetchRemoteObj::_send_request() RGWRados::ATTRSMOD_NONE, copy_if_newer, attrs, - RGW_OBJ_CATEGORY_MAIN, + RGWObjCategory::Main, versioned_epoch, real_time(), /* delete_at */ NULL, /* string *ptag, */ diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 2f8044981fba..2082ac14778f 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -4673,7 +4673,7 @@ void RGWCopyObj::execute() if_nomatch, attrs_mod, copy_if_newer, - attrs, RGW_OBJ_CATEGORY_MAIN, + attrs, RGWObjCategory::Main, olh_epoch, (delete_at ? *delete_at : real_time()), (version_id.empty() ? NULL : &version_id), @@ -5358,7 +5358,7 @@ void RGWInitMultipart::execute() RGWRados::Object::Write obj_op(&op_target); obj_op.meta.owner = s->owner.get_id(); - obj_op.meta.category = RGW_OBJ_CATEGORY_MULTIMETA; + obj_op.meta.category = RGWObjCategory::MultiMeta; obj_op.meta.flags = PUT_OBJ_CREATE_EXCL; op_ret = obj_op.write_meta(0, 0, attrs); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d9368a45c4c0..4402f5489f9d 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -100,7 +100,7 @@ static string default_bucket_index_pool_suffix = "rgw.buckets.index"; static string default_storage_extra_pool_suffix = "rgw.buckets.non-ec"; static string log_lock_name = "rgw_log_lock"; -static RGWObjCategory main_category = RGW_OBJ_CATEGORY_MAIN; +static RGWObjCategory main_category = RGWObjCategory::Main; #define RGW_USAGE_OBJ_PREFIX "usage." @@ -3381,7 +3381,7 @@ int RGWRados::swift_versioning_copy(RGWObjectCtx& obj_ctx, RGWRados::ATTRSMOD_NONE, true, /* bool copy_if_newer */ state->attrset, - RGW_OBJ_CATEGORY_MAIN, + RGWObjCategory::Main, 0, /* uint64_t olh_epoch */ real_time(), /* time_t delete_at */ NULL, /* string *version_id */ @@ -3467,7 +3467,7 @@ int RGWRados::swift_versioning_restore(RGWSysObjectCtx& sysobj_ctx, RGWRados::ATTRSMOD_NONE, true, /* bool copy_if_newer */ no_attrs, - RGW_OBJ_CATEGORY_MAIN, + RGWObjCategory::Main, 0, /* uint64_t olh_epoch */ real_time(), /* time_t delete_at */ nullptr, /* string *version_id */ @@ -6079,7 +6079,7 @@ int RGWRados::set_attrs(void *ctx, const RGWBucketInfo& bucket_info, rgw_obj& ob int64_t poolid = ref.ioctx.get_id(); r = index_op.complete(poolid, epoch, state->size, state->accounted_size, mtime, etag, content_type, &acl_bl, - RGW_OBJ_CATEGORY_MAIN, NULL); + RGWObjCategory::Main, NULL); } else { int ret = index_op.cancel(); if (ret < 0) { @@ -8075,7 +8075,7 @@ int RGWRados::update_containers_stats(map& m) auto hiter = headers.begin(); for (; hiter != headers.end(); ++hiter) { RGWObjCategory category = main_category; - map::iterator iter = (hiter->stats).find((uint8_t)category); + auto iter = (hiter->stats).find(category); if (iter != hiter->stats.end()) { struct rgw_bucket_category_stats& stats = iter->second; ent.count += stats.num_entries; @@ -8649,14 +8649,19 @@ int RGWRados::cls_obj_complete_del(BucketShard& bs, string& tag, rgw_bucket_dir_entry ent; ent.meta.mtime = removed_mtime; obj.key.get_index_key(&ent.key); - return cls_obj_complete_op(bs, obj, CLS_RGW_OP_DEL, tag, pool, epoch, ent, RGW_OBJ_CATEGORY_NONE, remove_objs, bilog_flags, zones_trace); + return cls_obj_complete_op(bs, obj, CLS_RGW_OP_DEL, tag, pool, epoch, + ent, RGWObjCategory::None, remove_objs, + bilog_flags, zones_trace); } int RGWRados::cls_obj_complete_cancel(BucketShard& bs, string& tag, rgw_obj& obj, uint16_t bilog_flags, rgw_zone_set *zones_trace) { rgw_bucket_dir_entry ent; obj.key.get_index_key(&ent.key); - return cls_obj_complete_op(bs, obj, CLS_RGW_OP_CANCEL, tag, -1 /* pool id */, 0, ent, RGW_OBJ_CATEGORY_NONE, NULL, bilog_flags, zones_trace); + return cls_obj_complete_op(bs, obj, CLS_RGW_OP_CANCEL, tag, + -1 /* pool id */, 0, ent, + RGWObjCategory::None, NULL, bilog_flags, + zones_trace); } int RGWRados::cls_obj_set_bucket_tag_timeout(RGWBucketInfo& bucket_info, uint64_t timeout) @@ -9244,8 +9249,8 @@ int RGWRados::cls_user_sync_bucket_stats(rgw_raw_obj& user_obj, for (const auto& hiter : headers) { for (const auto& iter : hiter.stats) { - if (uint8_t(RGW_OBJ_CATEGORY_MAIN) == iter.first || - uint8_t(RGW_OBJ_CATEGORY_MULTIMETA) == iter.first) { + if (RGWObjCategory::Main == iter.first || + RGWObjCategory::MultiMeta == iter.first) { const struct rgw_bucket_category_stats& header_stats = iter.second; entry.size += header_stats.total_size; entry.size_rounded += header_stats.total_size_rounded; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 9f09fa56892f..0e183cbfcb96 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1599,7 +1599,7 @@ public: bool completeMultipart; MetaParams() : mtime(NULL), rmattrs(NULL), data(NULL), manifest(NULL), ptag(NULL), - remove_objs(NULL), category(RGW_OBJ_CATEGORY_MAIN), flags(0), + remove_objs(NULL), category(RGWObjCategory::Main), flags(0), if_match(NULL), if_nomatch(NULL), canceled(false), user_data(nullptr), zones_trace(nullptr), modify_tail(false), completeMultipart(false) {} } meta; diff --git a/src/rgw/rgw_reshard.cc b/src/rgw/rgw_reshard.cc index 71829c1e5c9f..fb154249a874 100644 --- a/src/rgw/rgw_reshard.cc +++ b/src/rgw/rgw_reshard.cc @@ -32,7 +32,7 @@ class BucketReshardShard { int num_shard; RGWRados::BucketShard bs; vector entries; - map stats; + map stats; deque& aio_completions; uint64_t max_aio_completions; uint64_t reshard_shard_batch_size; @@ -88,7 +88,7 @@ public: return num_shard; } - int add_entry(rgw_cls_bi_entry& entry, bool account, uint8_t category, + int add_entry(rgw_cls_bi_entry& entry, bool account, RGWObjCategory category, const rgw_bucket_category_stats& entry_stats) { entries.push_back(entry); if (account) { @@ -178,7 +178,7 @@ public: } int add_entry(int shard_index, - rgw_cls_bi_entry& entry, bool account, uint8_t category, + rgw_cls_bi_entry& entry, bool account, RGWObjCategory category, const rgw_bucket_category_stats& entry_stats) { int ret = target_shards[shard_index]->add_entry(entry, account, category, entry_stats); @@ -568,7 +568,7 @@ int RGWBucketReshard::do_reshard(int num_shards, int target_shard_id; cls_rgw_obj_key cls_key; - uint8_t category; + RGWObjCategory category; rgw_bucket_category_stats stats; bool account = entry.get_info(&cls_key, &category, &stats); rgw_obj_key key(cls_key); diff --git a/src/test/cls_rgw/test_cls_rgw.cc b/src/test/cls_rgw/test_cls_rgw.cc index d72a394ccb68..3ef6cbeefd57 100644 --- a/src/test/cls_rgw/test_cls_rgw.cc +++ b/src/test/cls_rgw/test_cls_rgw.cc @@ -68,7 +68,7 @@ public: } }; -void test_stats(librados::IoCtx& ioctx, string& oid, int category, uint64_t num_entries, uint64_t total_size) +void test_stats(librados::IoCtx& ioctx, string& oid, RGWObjCategory category, uint64_t num_entries, uint64_t total_size) { map results; map oids; @@ -131,16 +131,17 @@ TEST(cls_rgw, index_basic) index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, obj, loc); - test_stats(ioctx, bucket_oid, 0, i, obj_size * i); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, i, obj_size * i); op = mgr.write_op(); rgw_bucket_dir_entry_meta meta; - meta.category = 0; + meta.category = RGWObjCategory::None; meta.size = obj_size; index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, epoch, obj, meta); } - test_stats(ioctx, bucket_oid, 0, NUM_OBJS, obj_size * NUM_OBJS); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, NUM_OBJS, + obj_size * NUM_OBJS); } TEST(cls_rgw, index_multiple_obj_writers) @@ -163,20 +164,21 @@ TEST(cls_rgw, index_multiple_obj_writers) index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, obj, loc); - test_stats(ioctx, bucket_oid, 0, 0, 0); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, 0, 0); } for (int i = NUM_OBJS; i > 0; i--) { string tag = str_int("tag", i - 1); rgw_bucket_dir_entry_meta meta; - meta.category = 0; + meta.category = RGWObjCategory::None; meta.size = obj_size * i; index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, i, obj, meta); /* verify that object size doesn't change, as we went back with epoch */ - test_stats(ioctx, bucket_oid, 0, 1, obj_size * NUM_OBJS); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, 1, + obj_size * NUM_OBJS); } } @@ -203,16 +205,16 @@ TEST(cls_rgw, index_remove_object) index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, obj, loc); - test_stats(ioctx, bucket_oid, 0, i, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, i, total_size); rgw_bucket_dir_entry_meta meta; - meta.category = 0; + meta.category = RGWObjCategory::None; meta.size = i * obj_size; total_size += i * obj_size; index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, ++epoch, obj, meta); - test_stats(ioctx, bucket_oid, 0, i + 1, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, i + 1, total_size); } int i = NUM_OBJS / 2; @@ -225,7 +227,7 @@ TEST(cls_rgw, index_remove_object) index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_DEL, tag_remove, obj, loc); index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag_modify, obj, loc); - test_stats(ioctx, bucket_oid, 0, NUM_OBJS, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, NUM_OBJS, total_size); rgw_bucket_dir_entry_meta meta; @@ -234,17 +236,17 @@ TEST(cls_rgw, index_remove_object) /* verify stats correct */ total_size -= i * obj_size; - test_stats(ioctx, bucket_oid, 0, NUM_OBJS - 1, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, NUM_OBJS - 1, total_size); meta.size = 512; - meta.category = 0; + meta.category = RGWObjCategory::None; /* complete object modification */ index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag_modify, ++epoch, obj, meta); /* verify stats correct */ total_size += meta.size; - test_stats(ioctx, bucket_oid, 0, NUM_OBJS, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, NUM_OBJS, total_size); /* prepare both removal and modification on the same object, this time we'll @@ -255,21 +257,22 @@ TEST(cls_rgw, index_remove_object) /* complete modification */ total_size -= meta.size; meta.size = i * obj_size * 2; - meta.category = 0; + meta.category = RGWObjCategory::None; /* complete object modification */ index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag_modify, ++epoch, obj, meta); /* verify stats correct */ total_size += meta.size; - test_stats(ioctx, bucket_oid, 0, NUM_OBJS, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, NUM_OBJS, total_size); /* complete object removal */ index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_DEL, tag_remove, ++epoch, obj, meta); /* verify stats correct */ total_size -= meta.size; - test_stats(ioctx, bucket_oid, 0, NUM_OBJS - 1, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, NUM_OBJS - 1, + total_size); } TEST(cls_rgw, index_suggest) @@ -298,16 +301,16 @@ TEST(cls_rgw, index_suggest) index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, obj, loc); - test_stats(ioctx, bucket_oid, 0, i, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, i, total_size); rgw_bucket_dir_entry_meta meta; - meta.category = 0; + meta.category = RGWObjCategory::None; meta.size = obj_size; total_size += meta.size; index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, ++epoch, obj, meta); - test_stats(ioctx, bucket_oid, 0, i + 1, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, i + 1, total_size); } /* prepare (without completion) some of the objects */ @@ -318,7 +321,7 @@ TEST(cls_rgw, index_suggest) index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, obj, loc); - test_stats(ioctx, bucket_oid, 0, num_objs, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, num_objs, total_size); } int actual_num_objs = num_objs; @@ -330,14 +333,14 @@ TEST(cls_rgw, index_suggest) index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, obj, loc); - test_stats(ioctx, bucket_oid, 0, actual_num_objs, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, actual_num_objs, total_size); rgw_bucket_dir_entry_meta meta; index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_DEL, tag, ++epoch, obj, meta); total_size -= obj_size; actual_num_objs--; - test_stats(ioctx, bucket_oid, 0, actual_num_objs, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, actual_num_objs, total_size); } bufferlist updates; @@ -375,7 +378,7 @@ TEST(cls_rgw, index_suggest) cls_rgw_suggest_changes(*op, updates); ASSERT_EQ(0, ioctx.operate(bucket_oid, op)); - test_stats(ioctx, bucket_oid, 0, num_objs / 2, total_size); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, num_objs / 2, total_size); } /* @@ -418,12 +421,12 @@ TEST(cls_rgw, index_list) op = mgr.write_op(); rgw_bucket_dir_entry_meta meta; - meta.category = 0; + meta.category = RGWObjCategory::None; meta.size = obj_size; index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, epoch, obj, meta); } - test_stats(ioctx, bucket_oid, 0, num_objs, obj_size * num_objs); + test_stats(ioctx, bucket_oid, RGWObjCategory::None, num_objs, obj_size * num_objs); map oids = { {0, bucket_oid} }; map list_results; @@ -478,7 +481,7 @@ TEST(cls_rgw, bi_list) index_prepare(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, obj, loc, RGW_BILOG_FLAG_VERSIONED_OP); op = mgr.write_op(); rgw_bucket_dir_entry_meta meta; - meta.category = 0; + meta.category = RGWObjCategory::None; meta.size = obj_size; index_complete(mgr, ioctx, bucket_oid, CLS_RGW_OP_ADD, tag, epoch, obj, meta, RGW_BILOG_FLAG_VERSIONED_OP); }