]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: clean-up use enum class for stats category
authorJ. Eric Ivancich <ivancich@redhat.com>
Wed, 5 Dec 2018 15:18:22 +0000 (10:18 -0500)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 2 Jan 2019 20:45:19 +0000 (15:45 -0500)
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 <ivancich@redhat.com>
14 files changed:
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/cls/rgw/cls_rgw_ops.cc
src/cls/rgw/cls_rgw_ops.h
src/cls/rgw/cls_rgw_types.cc
src/cls/rgw/cls_rgw_types.h
src/rgw/rgw_common.h
src/rgw/rgw_cr_rados.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_reshard.cc
src/test/cls_rgw/test_cls_rgw.cc

index 3bb5d0fff4843e283d0a47f4dbc9b28dbee4bd9f..cbccae3319889d75f749eafb08678e914e35f6db 100644 (file)
@@ -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;
   }
 
index b074fa409716cce0fb3b38346b22f5c3ce658911..da9c43508d9dff156ff65915a2ba56b151d1e4a0 100644 (file)
@@ -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<uint8_t, rgw_bucket_category_stats>& stats)
+void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o,
+                                bool absolute,
+                                 const map<RGWObjCategory, rgw_bucket_category_stats>& stats)
 {
   struct rgw_cls_bucket_update_stats_op call;
   call.absolute = absolute;
index f731a15ea21886ead91dd9cd1c69a67044321d89..07e7211b83d8c0a51f4334ec264f9d59763c2193 100644 (file)
@@ -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<uint8_t, rgw_bucket_category_stats>& stats);
+void cls_rgw_bucket_update_stats(librados::ObjectWriteOperation& o,
+                                 bool absolute,
+                                 const map<RGWObjCategory, rgw_bucket_category_stats>& 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,
index 53eb55e32d849ae0fce3d02ebac82aaf5dbd3091..713cee413f8e7bc4307695b1aae5fe5be3b9a025 100644 (file)
@@ -354,7 +354,7 @@ void rgw_cls_bucket_update_stats_op::generate_test_instances(list<rgw_cls_bucket
 {
   rgw_cls_bucket_update_stats_op *r = new rgw_cls_bucket_update_stats_op;
   r->absolute = 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;
index 04c3ce366b0d53828a13dee81213a531b91729f7..7e449b36dc6158a24ea9095c395292a6534c7980 100644 (file)
@@ -463,7 +463,7 @@ WRITE_CLASS_ENCODER(rgw_cls_check_index_ret)
 struct rgw_cls_bucket_update_stats_op
 {
   bool absolute{false};
-  map<uint8_t, rgw_bucket_category_stats> stats;
+  map<RGWObjCategory, rgw_bucket_category_stats> stats;
 
   rgw_cls_bucket_update_stats_op() {}
 
index 891c663ffa94200528620a82e52e40f8ea9ac9ec..5b400d35718f811ed6e233fda5e0aa19a7f39366 100644 (file)
@@ -41,7 +41,7 @@ void cls_rgw_obj_key::decode_json(JSONObj *obj) {
 void rgw_bucket_dir_entry_meta::generate_test_instances(list<rgw_bucket_dir_entry_meta*>& 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<RGWObjCategory>(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<rgw_bucket_dir_header*>
 
   uint8_t i;
   for (i = 0, iter = l.begin(); iter != l.end(); ++iter, ++i) {
+    RGWObjCategory c = static_cast<RGWObjCategory>(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<uint8_t, struct rgw_bucket_category_stats>::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();
index 0d666f8a0ca1d5fb7f8620ba9a56097d9d3eac86..a0f71f18f3ab037defc36ceb4d5e63888eef64a3 100644 (file)
@@ -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<uint8_t, rgw_bucket_category_stats> stats;
+  map<RGWObjCategory, rgw_bucket_category_stats> stats;
   uint64_t tag_timeout;
   uint64_t ver;
   uint64_t master_ver;
index fd530ad5e672ea88f81243381cbbf626f74bff0f..204a9c96c4cfa6bfee989b61db414edac038e435 100644 (file)
@@ -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";
   }
 
index 0fc0d8a20202750e9b5be3e69b45024fe188bc28..e2e343832b7b7f9a8f952cb8af48adf680165dd9 100644 (file)
@@ -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, */
index 2f8044981fbae97ef76f307851a47e5296215873..2082ac14778fb5d01e43955f78fafec03cbf2728 100644 (file)
@@ -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);
index d9368a45c4c01a2deb0855b34c29e98c06ba7e4a..4402f5489f9d7af6b149235f8e026db9135de7a4 100644 (file)
@@ -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<string, RGWBucketEnt>& m)
     auto hiter = headers.begin();
     for (; hiter != headers.end(); ++hiter) {
       RGWObjCategory category = main_category;
-      map<uint8_t, struct rgw_bucket_category_stats>::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;
index 9f09fa56892fcae4e8ce00c9b0ca25239f1e9325..0e183cbfcb96af6548872f5b79a96b9f1fb78fe5 100644 (file)
@@ -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;
index 71829c1e5c9f5d3e952963e2d3c5d97d523e53f6..fb154249a87487a042811b933ece01d6a2103013 100644 (file)
@@ -32,7 +32,7 @@ class BucketReshardShard {
   int num_shard;
   RGWRados::BucketShard bs;
   vector<rgw_cls_bi_entry> entries;
-  map<uint8_t, rgw_bucket_category_stats> stats;
+  map<RGWObjCategory, rgw_bucket_category_stats> stats;
   deque<librados::AioCompletion *>& 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);
index d72a394ccb68f0ae7aa8b325d7d8da257e0ab750..3ef6cbeefd57a0aed01d3dc9d81a0b5eef86ccab 100644 (file)
@@ -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<int, struct rgw_cls_list_ret> results;
   map<int, string> 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<int, string> oids = { {0, bucket_oid} };
   map<int, struct rgw_cls_list_ret> 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);
   }