]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: minor clean-up -- convert enum BIIndexType to enum class 28249/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Fri, 30 Nov 2018 02:46:04 +0000 (21:46 -0500)
committerPrashant D <pdhange@redhat.com>
Sun, 26 May 2019 23:56:12 +0000 (19:56 -0400)
Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
(cherry picked from commit 06fcac3ba04b69cc5788938642f8a17bfb520aa2)

src/cls/rgw/cls_rgw.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_admin.cc
src/rgw/rgw_rados.cc

index fbad562b65898d60462f91547de1f0675ca29fec..a88064cdaef3715da82abee464758fd801b40e1b 100644 (file)
@@ -2229,13 +2229,13 @@ static int rgw_bi_get_op(cls_method_context_t hctx, bufferlist *in, bufferlist *
   string idx;
 
   switch (op.type) {
-    case PlainIdx:
+    case BIIndexType::Plain:
       idx = op.key.name;
       break;
-    case InstanceIdx:
+    case BIIndexType::Instance:
       encode_obj_index_key(op.key, &idx);
       break;
-    case OLHIdx:
+    case BIIndexType::OLH:
       encode_olh_data_key(op.key, &idx);
       break;
     default:
@@ -2310,7 +2310,7 @@ static int list_plain_entries(cls_method_context_t hctx, const string& name, con
     }
 
     rgw_cls_bi_entry entry;
-    entry.type = PlainIdx;
+    entry.type = BIIndexType::Plain;
     entry.idx = iter->first;
     entry.data = iter->second;
 
@@ -2388,7 +2388,7 @@ static int list_instance_entries(cls_method_context_t hctx, const string& name,
   map<string, bufferlist>::iterator iter;
   for (iter = keys.begin(); iter != keys.end(); ++iter) {
     rgw_cls_bi_entry entry;
-    entry.type = InstanceIdx;
+    entry.type = BIIndexType::Instance;
     entry.idx = iter->first;
     entry.data = iter->second;
 
@@ -2473,7 +2473,7 @@ static int list_olh_entries(cls_method_context_t hctx, const string& name, const
   map<string, bufferlist>::iterator iter;
   for (iter = keys.begin(); iter != keys.end(); ++iter) {
     rgw_cls_bi_entry entry;
-    entry.type = OLHIdx;
+    entry.type = BIIndexType::OLH;
     entry.idx = iter->first;
     entry.data = iter->second;
 
index 37db81e53639488c9f5cdb6dd816d967dbaf0583..30735b1518f06b9e6b70bcabecf7cb3482a964af 100644 (file)
@@ -597,7 +597,7 @@ struct rgw_cls_bi_get_op {
   cls_rgw_obj_key key;
   BIIndexType type; /* namespace: plain, instance, olh */
 
-  rgw_cls_bi_get_op() : type(PlainIdx) {}
+  rgw_cls_bi_get_op() : type(BIIndexType::Plain) {}
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
index c48a2b353cf5e80b437d12c16a449b3ea24fa72e..c948632bc31ef96e10e6c87c9d7844076c9d118e 100644 (file)
@@ -1,3 +1,5 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
 
 #include "cls/rgw/cls_rgw_types.h"
 #include "common/ceph_json.h"
@@ -156,15 +158,15 @@ static void dump_bi_entry(bufferlist bl, BIIndexType index_type, Formatter *form
 {
   bufferlist::iterator iter = bl.begin();
   switch (index_type) {
-    case PlainIdx:
-    case InstanceIdx:
+    case BIIndexType::Plain:
+    case BIIndexType::Instance:
       {
         rgw_bucket_dir_entry entry;
         decode(entry, iter);
         encode_json("entry", entry, formatter);
       }
       break;
-    case OLHIdx:
+    case BIIndexType::OLH:
       {
         rgw_bucket_olh_entry entry;
         decode(entry, iter);
@@ -181,18 +183,18 @@ void rgw_cls_bi_entry::decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key)
   string s;
   JSONDecoder::decode_json("type", s, obj);
   if (s == "plain") {
-    type = PlainIdx;
+    type = BIIndexType::Plain;
   } else if (s == "instance") {
-    type = InstanceIdx;
+    type = BIIndexType::Instance;
   } else if (s == "olh") {
-    type = OLHIdx;
+    type = BIIndexType::OLH;
   } else {
-    type = InvalidIdx;
+    type = BIIndexType::Invalid;
   }
   using ceph::encode;
   switch (type) {
-    case PlainIdx:
-    case InstanceIdx:
+    case BIIndexType::Plain:
+    case BIIndexType::Instance:
       {
         rgw_bucket_dir_entry entry;
         JSONDecoder::decode_json("entry", entry, obj);
@@ -203,7 +205,7 @@ void rgw_cls_bi_entry::decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key)
         }
       }
       break;
-    case OLHIdx:
+    case BIIndexType::OLH:
       {
         rgw_bucket_olh_entry entry;
         JSONDecoder::decode_json("entry", entry, obj);
@@ -223,17 +225,17 @@ void rgw_cls_bi_entry::dump(Formatter *f) const
 {
   string type_str;
   switch (type) {
-    case PlainIdx:
-      type_str = "plain";
-      break;
-    case InstanceIdx:
-      type_str = "instance";
-      break;
-    case OLHIdx:
-      type_str = "olh";
-      break;
-    default:
-      type_str = "invalid";
+  case BIIndexType::Plain:
+    type_str = "plain";
+    break;
+  case BIIndexType::Instance:
+    type_str = "instance";
+    break;
+  case BIIndexType::OLH:
+    type_str = "olh";
+    break;
+  default:
+    type_str = "invalid";
   }
   encode_json("type", type_str, f);
   encode_json("idx", idx, f);
@@ -246,10 +248,10 @@ bool rgw_cls_bi_entry::get_info(cls_rgw_obj_key *key, uint8_t *category, rgw_buc
   bufferlist::iterator iter = data.begin();
   using ceph::decode;
   switch (type) {
-    case PlainIdx:
+    case BIIndexType::Plain:
         account = true;
         // NO BREAK; falls through to case InstanceIdx:
-    case InstanceIdx:
+    case BIIndexType::Instance:
       {
         rgw_bucket_dir_entry entry;
         decode(entry, iter);
@@ -261,7 +263,7 @@ bool rgw_cls_bi_entry::get_info(cls_rgw_obj_key *key, uint8_t *category, rgw_buc
         accounted_stats->actual_size += entry.meta.size;
       }
       break;
-    case OLHIdx:
+    case BIIndexType::OLH:
       {
         rgw_bucket_olh_entry entry;
         decode(entry, iter);
index 06c0f8b649523e1d1a2e9ece833b491d3f61be68..c50df73b7d0a1705930a09c659e00108aa9e398c 100644 (file)
@@ -382,11 +382,11 @@ struct rgw_bucket_dir_entry {
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry)
 
-enum BIIndexType {
-  InvalidIdx    = 0,
-  PlainIdx      = 1,
-  InstanceIdx   = 2,
-  OLHIdx        = 3,
+enum class BIIndexType : uint8_t {
+  Invalid    = 0,
+  Plain      = 1,
+  Instance   = 2,
+  OLH        = 3,
 };
 
 struct rgw_bucket_category_stats;
@@ -396,11 +396,11 @@ struct rgw_cls_bi_entry {
   string idx;
   bufferlist data;
 
-  rgw_cls_bi_entry() : type(InvalidIdx) {}
+  rgw_cls_bi_entry() : type(BIIndexType::Invalid) {}
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
-    encode((uint8_t)type, bl);
+    encode(type, bl);
     encode(idx, bl);
     encode(data, bl);
     ENCODE_FINISH(bl);
index 551311831c2b54073a0c2f549c68c6a93710af78..dec7c3a785c3e109852a76d9fd79645e2c5c97eb 100644 (file)
@@ -1025,28 +1025,28 @@ ReplicaLogType get_replicalog_type(const string& name) {
 
 BIIndexType get_bi_index_type(const string& type_str) {
   if (type_str == "plain")
-    return PlainIdx;
+    return BIIndexType::Plain;
   if (type_str == "instance")
-    return InstanceIdx;
+    return BIIndexType::Instance;
   if (type_str == "olh")
-    return OLHIdx;
+    return BIIndexType::OLH;
 
-  return InvalidIdx;
+  return BIIndexType::Invalid;
 }
 
 void dump_bi_entry(bufferlist& bl, BIIndexType index_type, Formatter *formatter)
 {
   bufferlist::iterator iter = bl.begin();
   switch (index_type) {
-    case PlainIdx:
-    case InstanceIdx:
+    case BIIndexType::Plain:
+    case BIIndexType::Instance:
       {
         rgw_bucket_dir_entry entry;
         decode(entry, iter);
         encode_json("entry", entry, formatter);
       }
       break;
-    case OLHIdx:
+    case BIIndexType::OLH:
       {
         rgw_bucket_olh_entry entry;
         decode(entry, iter);
@@ -2798,7 +2798,7 @@ int main(int argc, const char **argv)
   uint64_t max_rewrite_size = ULLONG_MAX;
   uint64_t min_rewrite_stripe_size = 0;
 
-  BIIndexType bi_index_type = PlainIdx;
+  BIIndexType bi_index_type = BIIndexType::Plain;
 
   string job_id;
   int num_shards = 0;
@@ -3063,7 +3063,7 @@ int main(int argc, const char **argv)
     } else if (ceph_argparse_witharg(args, i, &val, "--index-type", (char*)NULL)) {
       string index_type_str = val;
       bi_index_type = get_bi_index_type(index_type_str);
-      if (bi_index_type == InvalidIdx) {
+      if (bi_index_type == BIIndexType::Invalid) {
         cerr << "ERROR: invalid bucket index entry type" << std::endl;
         return EINVAL;
       }
index 88e870054031f0fefe59080e6500f78982a65790..b5f653d33d7ea4183efa17cdf312e1fec8d8a457 100644 (file)
@@ -12955,7 +12955,7 @@ int RGWRados::bi_get_instance(const RGWBucketInfo& bucket_info, rgw_obj& obj, rg
   }
 
   rgw_cls_bi_entry bi_entry;
-  r = bi_get(obj.bucket, obj, InstanceIdx, &bi_entry);
+  r = bi_get(obj.bucket, obj, BIIndexType::Instance, &bi_entry);
   if (r < 0 && r != -ENOENT) {
     ldout(cct, 0) << "ERROR: bi_get() returned r=" << r << dendl;
   }