Skip to content

Commit

Permalink
rgw: simple manifest compaction
Browse files Browse the repository at this point in the history
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
  • Loading branch information
yehudasa committed Oct 13, 2016
1 parent e414516 commit d459032
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/rgw/rgw_common.h
Expand Up @@ -982,6 +982,9 @@ struct rgw_bucket {
bool operator<(const rgw_bucket& b) const {
return name.compare(b.name) < 0;
}
bool operator==(const rgw_bucket& b) const {
return (name == b.name) && (bucket_id == b.bucket_id);
}
};
WRITE_CLASS_ENCODER(rgw_bucket)

Expand Down
47 changes: 35 additions & 12 deletions src/rgw/rgw_rados.h
Expand Up @@ -279,7 +279,7 @@ class RGWObjManifest {
uint64_t obj_size;

rgw_obj obj;
rgw_raw_obj head_obj;
rgw_raw_obj head_obj; /* in-memory only, calculated from obj */
uint64_t head_size;

uint64_t max_head_size;
Expand Down Expand Up @@ -354,7 +354,7 @@ class RGWObjManifest {
}

void encode(bufferlist& bl) const {
ENCODE_START(6, 3, bl);
ENCODE_START(6, 6, bl);
::encode(obj_size, bl);
::encode(objs, bl);
::encode(explicit_objs, bl);
Expand All @@ -363,9 +363,16 @@ class RGWObjManifest {
::encode(max_head_size, bl);
::encode(prefix, bl);
::encode(rules, bl);
::encode(tail_bucket, bl);
::encode(tail_instance, bl);
::encode(head_obj, bl);
bool encode_tail_bucket = !(tail_bucket == obj.bucket);
::encode(encode_tail_bucket, bl);
if (encode_tail_bucket) {
::encode(tail_bucket, bl);
}
bool encode_tail_instance = (tail_instance != obj.get_instance());
::encode(encode_tail_instance, bl);
if (encode_tail_instance) {
::encode(tail_instance, bl);
}
ENCODE_FINISH(bl);
}

Expand Down Expand Up @@ -404,20 +411,36 @@ class RGWObjManifest {
}

if (struct_v >= 4) {
::decode(tail_bucket, bl);
if (struct_v < 6) {
::decode(tail_bucket, bl);
} else {
bool need_to_decode;
::decode(need_to_decode, bl);
if (need_to_decode) {
::decode(tail_bucket, bl);
} else {
tail_bucket = obj.bucket;
}
}
}

if (struct_v >= 5) {
::decode(tail_instance, bl);
if (struct_v < 6) {
::decode(tail_instance, bl);
} else {
bool need_to_decode;
::decode(need_to_decode, bl);
if (need_to_decode) {
::decode(tail_instance, bl);
} else {
tail_instance = obj.get_instance();
}
}
} else { // old object created before 'tail_instance' field added to manifest
tail_instance = obj.get_instance();
}

if (struct_v >= 6) {
::decode(head_obj, bl);
} else {
rgw_obj_to_raw(obj, &head_obj);
}
rgw_obj_to_raw(obj, &head_obj);

update_iterators();
DECODE_FINISH(bl);
Expand Down

0 comments on commit d459032

Please sign in to comment.