}
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);
}
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);
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";
}
}
- 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;
}
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() {
{
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);
}
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;
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;
}
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;
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);