]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: simple manifest compaction
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 13 Oct 2016 22:57:46 +0000 (15:57 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 9 Mar 2017 17:18:52 +0000 (09:18 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_common.h
src/rgw/rgw_rados.h

index a7dc3b32988ad8736f5da9c618be201e4ccc8444..0660e4dc39dc62061351d57101898d9dcc9cfed0 100644 (file)
@@ -992,6 +992,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)
 
index cd13a8882c6172f179ac00ce838715e6dea3bd5b..0f30218d248cfc5754419e6c3a30c33ea91ff8c2 100644 (file)
@@ -346,7 +346,7 @@ protected:
   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;
@@ -421,7 +421,7 @@ public:
   }
 
   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);
@@ -430,9 +430,16 @@ public:
     ::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);
   }
 
@@ -471,20 +478,36 @@ public:
     }
 
     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);