]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: change scope of bucket index entry flags
authorJ. Eric Ivancich <ivancich@redhat.com>
Fri, 13 Sep 2019 03:20:55 +0000 (23:20 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Fri, 24 Jan 2020 18:44:09 +0000 (13:44 -0500)
Redefine global constants that define flags in bucket index entries to
struct-scoped.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_types.h

index abf566322ffbc4d401945db9869cd90b21b4513d..d52650ed9a431dd556b9caaabb493890627cfda0 100644 (file)
@@ -810,9 +810,10 @@ static int read_key_entry(cls_method_context_t hctx, cls_rgw_obj_key& key,
   }
 
   if (key.instance.empty() &&
-      entry->flags & RGW_BUCKET_DIRENT_FLAG_VER_MARKER) {
-    /* we only do it where key.instance is empty. In this case the delete marker will have a
-     * separate entry in the index to avoid collisions with the actual object, as it's mutable
+      entry->flags & rgw_bucket_dir_entry::FLAG_VER_MARKER) {
+    /* we only do it where key.instance is empty. In this case the
+     * delete marker will have a separate entry in the index to avoid
+     * collisions with the actual object, as it's mutable
      */
     if (special_delete_marker_name) {
       encode_obj_versioned_data_key(key, idx, true);
@@ -871,7 +872,11 @@ int rgw_bucket_complete_op(cls_method_context_t hctx, bufferlist *in, bufferlist
   }
 
   entry.index_ver = header.ver;
-  entry.flags = (entry.key.instance.empty() ? 0 : RGW_BUCKET_DIRENT_FLAG_VER); /* resetting entry flags, entry might have been previously a delete marker */
+  /* resetting entry flags, entry might have been previously a delete
+   * marker */
+  entry.flags = (entry.key.instance.empty() ?
+                0 :
+                rgw_bucket_dir_entry::FLAG_VER);
 
   if (op.tag.size()) {
     map<string, rgw_bucket_pending_info>::iterator pinter = entry.pending_map.find(op.tag);
@@ -1105,7 +1110,7 @@ public:
   void init_as_delete_marker(rgw_bucket_dir_entry_meta& meta) {
     /* a deletion marker, need to initialize it, there's no instance entry for it yet */
     instance_entry.key = key;
-    instance_entry.flags = RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER;
+    instance_entry.flags = rgw_bucket_dir_entry::FLAG_DELETE_MARKER;
     instance_entry.meta = meta;
     instance_entry.tag = "delete-marker";
 
@@ -1172,9 +1177,9 @@ public:
       }
     }
 
-    uint64_t flags = RGW_BUCKET_DIRENT_FLAG_VER;
+    uint64_t flags = rgw_bucket_dir_entry::FLAG_VER;
     if (current) {
-      flags |= RGW_BUCKET_DIRENT_FLAG_CURRENT;
+      flags |= rgw_bucket_dir_entry::FLAG_CURRENT;
     }
 
     instance_entry.versioned_epoch = epoch;
@@ -1182,7 +1187,7 @@ public:
   }
 
   int demote_current() {
-    return write_entries(0, RGW_BUCKET_DIRENT_FLAG_CURRENT);
+    return write_entries(0, rgw_bucket_dir_entry::FLAG_CURRENT);
   }
 
   bool is_delete_marker() {
@@ -1324,7 +1329,7 @@ static int write_version_marker(cls_method_context_t hctx, cls_rgw_obj_key& key)
 {
   rgw_bucket_dir_entry entry;
   entry.key = key;
-  entry.flags = RGW_BUCKET_DIRENT_FLAG_VER_MARKER;
+  entry.flags = rgw_bucket_dir_entry::FLAG_VER_MARKER;
   int ret = write_entry(hctx, entry, key.name);
   if (ret < 0) {
     CLS_LOG(0, "ERROR: write_entry returned ret=%d", ret);
@@ -1355,10 +1360,10 @@ static int convert_plain_entry_to_versioned(cls_method_context_t hctx, cls_rgw_o
     }
 
     entry.versioned_epoch = 1; /* converted entries are always 1 */
-    entry.flags |= RGW_BUCKET_DIRENT_FLAG_VER;
+    entry.flags |= rgw_bucket_dir_entry::FLAG_VER;
 
     if (demote_current) {
-      entry.flags &= ~RGW_BUCKET_DIRENT_FLAG_CURRENT;
+      entry.flags &= ~rgw_bucket_dir_entry::FLAG_CURRENT;
     }
 
     string new_idx;
@@ -1901,7 +1906,7 @@ static int rgw_bucket_clear_olh(cls_method_context_t hctx, bufferlist *in, buffe
     return ret;
   }
 
-  if ((plain_entry.flags & RGW_BUCKET_DIRENT_FLAG_VER_MARKER) == 0) {
+  if ((plain_entry.flags & rgw_bucket_dir_entry::FLAG_VER_MARKER) == 0) {
     /* it's not a version marker, don't remove it */
     return 0;
   }
index d9212639fed92ede4eaefcda6c5e05a0e2ae1d1b..b77cd3b8bde161db0e6b5dab02dd7c2c96101e63 100644 (file)
@@ -339,12 +339,16 @@ struct cls_rgw_obj_key {
 WRITE_CLASS_ENCODER(cls_rgw_obj_key)
 
 
-#define RGW_BUCKET_DIRENT_FLAG_VER           0x1    /* a versioned object instance */
-#define RGW_BUCKET_DIRENT_FLAG_CURRENT       0x2    /* the last object instance of a versioned object */
-#define RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER 0x4    /* delete marker */
-#define RGW_BUCKET_DIRENT_FLAG_VER_MARKER    0x8    /* object is versioned, a placeholder for the plain entry */
-
 struct rgw_bucket_dir_entry {
+  /* a versioned object instance */
+  static constexpr uint16_t FLAG_VER =                0x1;
+  /* the last object instance of a versioned object */
+  static constexpr uint16_t FLAG_CURRENT =            0x2;
+  /* delete marker */
+  static constexpr uint16_t FLAG_DELETE_MARKER =      0x4;
+  /* object is versioned, a placeholder for the plain entry */
+  static constexpr uint16_t FLAG_VER_MARKER =         0x8;
+
   cls_rgw_obj_key key;
   rgw_bucket_entry_ver ver;
   std::string locator;
@@ -406,16 +410,21 @@ struct rgw_bucket_dir_entry {
     DECODE_FINISH(bl);
   }
 
-  bool is_current() {
-    int test_flags = RGW_BUCKET_DIRENT_FLAG_VER | RGW_BUCKET_DIRENT_FLAG_CURRENT;
-    return (flags & RGW_BUCKET_DIRENT_FLAG_VER) == 0 ||
+  bool is_current() const {
+    int test_flags =
+      rgw_bucket_dir_entry::FLAG_VER | rgw_bucket_dir_entry::FLAG_CURRENT;
+    return (flags & rgw_bucket_dir_entry::FLAG_VER) == 0 ||
            (flags & test_flags) == test_flags;
   }
-  bool is_delete_marker() { return (flags & RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER) != 0; }
-  bool is_visible() {
+  bool is_delete_marker() const {
+    return (flags & rgw_bucket_dir_entry::FLAG_DELETE_MARKER) != 0;
+  }
+  bool is_visible() const {
     return is_current() && !is_delete_marker();
   }
-  bool is_valid() { return (flags & RGW_BUCKET_DIRENT_FLAG_VER_MARKER) == 0; }
+  bool is_valid() const {
+    return (flags & rgw_bucket_dir_entry::FLAG_VER_MARKER) == 0;
+  }
 
   void dump(Formatter *f) const;
   void decode_json(JSONObj *obj);