]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: switch to new encoders/decoders
authorYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 8 Mar 2012 00:29:11 +0000 (16:29 -0800)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Thu, 8 Mar 2012 00:29:11 +0000 (16:29 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
src/rgw/rgw_access.h
src/rgw/rgw_acl.h
src/rgw/rgw_cache.h
src/rgw/rgw_cls_api.h
src/rgw/rgw_common.h
src/rgw/rgw_log.h

index fe133d5f542de22909c4fcaa656567dfd6bcf3b0..4bbf1c831727f745124453c7bfcd133e812b2138 100644 (file)
@@ -32,19 +32,19 @@ struct RGWObjManifestPart {
   RGWObjManifestPart() : loc_ofs(0), size(0) {}
 
   void encode(bufferlist& bl) const {
-     __u32 ver = 1;
-    ::encode(ver, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(loc, bl);
     ::encode(loc_ofs, bl);
     ::encode(size, bl);
+    ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-     __u32 ver;
-     ::decode(ver, bl);
+     DECODE_START_LEGACY_COMPAT_LEN_32(2, 2, 2, bl);
      ::decode(loc, bl);
      ::decode(loc_ofs, bl);
      ::decode(size, bl);
+     DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(RGWObjManifestPart);
@@ -56,17 +56,17 @@ struct RGWObjManifest {
   RGWObjManifest() : obj_size(0) {}
 
   void encode(bufferlist& bl) const {
-     __u32 ver = 1;
-    ::encode(ver, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(obj_size, bl);
     ::encode(objs, bl);
+    ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-     __u32 ver;
-     ::decode(ver, bl);
+     DECODE_START_LEGACY_COMPAT_LEN_32(2, 2, 2, bl);
      ::decode(obj_size, bl);
      ::decode(objs, bl);
+     DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(RGWObjManifest);
index abbd94ef6672f18ae9c365f33e8b4e177a74dd80..6a7a0ee939445b2bed4b5cfccbb2a97468924a96 100644 (file)
@@ -47,14 +47,14 @@ public:
   void set_permissions(int perm) { flags = perm; }
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(flags, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(flags, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(ACLPermission)
@@ -71,14 +71,14 @@ public:
   void set(ACLGranteeTypeEnum t) { type = t; }
 //  virtual void set(const char *s) = 0;
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(type, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(type, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(ACLGranteeType)
@@ -124,8 +124,7 @@ public:
   ACLGroupTypeEnum get_group() { return group; }
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 2;
-    ::encode(struct_v, bl);
+    ENCODE_START(3, 3, bl);
     ::encode(type, bl);
     ::encode(id, bl);
     string uri;
@@ -135,10 +134,10 @@ public:
     ::encode(name, bl);
     __u32 g = (__u32)group;
     ::encode(g, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     ::decode(type, bl);
     ::decode(id, bl);
     string uri;
@@ -153,6 +152,7 @@ public:
     } else {
       group = uri_to_group(uri);
     }
+    DECODE_FINISH(bl);
   }
 
   ACLGroupTypeEnum uri_to_group(string& uri);
@@ -186,17 +186,16 @@ public:
   int get_perm(string& id, int perm_mask);
   int get_group_perm(ACLGroupTypeEnum group, int perm_mask);
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 2;
-    ::encode(struct_v, bl);
+    ENCODE_START(3, 3, bl);
     bool maps_initialized = true;
     ::encode(maps_initialized, bl);
     ::encode(acl_user_map, bl);
     ::encode(grant_map, bl);
     ::encode(acl_group_map, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     bool maps_initialized;
     ::decode(maps_initialized, bl);
     ::decode(acl_user_map, bl);
@@ -210,6 +209,7 @@ public:
         _add_grant(&grant);
       }
     }
+    DECODE_FINISH(bl);
   }
   void add_grant(ACLGrant *grant);
 
@@ -236,16 +236,16 @@ public:
   ~ACLOwner() {}
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(id, bl);
     ::encode(display_name, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(id, bl);
     ::decode(display_name, bl);
+    DECODE_FINISH(bl);
   }
   void set_id(string& _id) { id = _id; }
   void set_name(string& name) { display_name = name; }
@@ -270,21 +270,21 @@ public:
   bool verify_permission(string& uid, int user_perm_mask, int perm);
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(owner, bl);
     ::encode(acl, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(owner, bl);
     ::decode(acl, bl);
+    DECODE_FINISH(bl);
    }
   void decode_owner(bufferlist::iterator& bl) { // sometimes we only need that, should be faster
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(owner, bl);
+    DECODE_FINISH(bl);
   }
 
   void set_owner(ACLOwner& o) { owner = o; }
index d4f943b472b737d4a3d3ba1cf9b379a4853ee39a..e3998493d2488a89f250c9357ba4c37741a53795 100644 (file)
@@ -24,19 +24,20 @@ struct ObjectMetaInfo {
   ObjectMetaInfo() : size(0), mtime(0) {}
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(size, bl);
     utime_t t(mtime, 0);
     ::encode(t, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(struct_v, bl);
     ::decode(size, bl);
     utime_t t;
     ::decode(t, bl);
     mtime = t.sec();
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(ObjectMetaInfo)
@@ -52,18 +53,17 @@ struct ObjectCacheInfo {
   ObjectCacheInfo() : status(0), flags(0) {}
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 2;
-    ::encode(struct_v, bl);
+    ENCODE_START(3, 3, bl);
     ::encode(status, bl);
     ::encode(flags, bl);
     ::encode(data, bl);
     ::encode(xattrs, bl);
     ::encode(meta, bl);
     ::encode(rm_xattrs, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     ::decode(status, bl);
     ::decode(flags, bl);
     ::decode(data, bl);
@@ -71,6 +71,7 @@ struct ObjectCacheInfo {
     ::decode(meta, bl);
     if (struct_v >= 2)
       ::decode(rm_xattrs, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(ObjectCacheInfo)
@@ -85,22 +86,22 @@ struct RGWCacheNotifyInfo {
   RGWCacheNotifyInfo() : op(0), ofs(0) {}
 
   void encode(bufferlist& obl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, obl);
+    ENCODE_START(2, 2, obl);
     ::encode(op, obl);
     ::encode(obj, obl);
     ::encode(obj_info, obl);
     ::encode(ofs, obl);
     ::encode(ns, obl);
+    ENCODE_FINISH(obl);
   }
   void decode(bufferlist::iterator& ibl) {
-    __u8 struct_v;
-    ::decode(struct_v, ibl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, ibl);
     ::decode(op, ibl);
     ::decode(obj, ibl);
     ::decode(obj_info, ibl);
     ::decode(ofs, ibl);
     ::decode(ns, ibl);
+    DECODE_FINISH(ibl);
   }
 };
 WRITE_CLASS_ENCODER(RGWCacheNotifyInfo)
index f19fd9634866f558f9b49933a9ffdd5130ec5896..471a52b3b5aefb85bdeeef3c21a4fc07d8ff9da0 100644 (file)
@@ -27,21 +27,21 @@ struct rgw_bucket_pending_info {
   uint8_t op;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     uint8_t s = (uint8_t)state;
     ::encode(s, bl);
     ::encode(timestamp, bl);
     ::encode(op, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     uint8_t s;
     ::decode(s, bl);
     state = (RGWPendingState)s;
     ::decode(timestamp, bl);
     ::decode(op, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_pending_info)
@@ -60,8 +60,7 @@ struct rgw_bucket_dir_entry_meta {
   category(0), size(0) { mtime.set_from_double(0); }
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 2;
-    ::encode(struct_v, bl);
+    ENCODE_START(3, 3, bl);
     ::encode(category, bl);
     ::encode(size, bl);
     ::encode(mtime, bl);
@@ -69,10 +68,10 @@ struct rgw_bucket_dir_entry_meta {
     ::encode(owner, bl);
     ::encode(owner_display_name, bl);
     ::encode(content_type, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     ::decode(category, bl);
     ::decode(size, bl);
     ::decode(mtime, bl);
@@ -81,6 +80,7 @@ struct rgw_bucket_dir_entry_meta {
     ::decode(owner_display_name, bl);
     if (struct_v >= 2)
       ::decode(content_type, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry_meta)
@@ -97,23 +97,18 @@ struct rgw_bucket_dir_entry {
     epoch(0), exists(false) {}
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 2;
-    if (!locator.size()) {
-      struct_v = 1; // don't waste space encoding it
-    }
+    ENCODE_START(3, 3, bl);
     ::encode(struct_v, bl);
     ::encode(name, bl);
     ::encode(epoch, bl);
     ::encode(exists, bl);
     ::encode(meta, bl);
     ::encode(pending_map, bl);
-    if (locator.size()) {
-      ::encode(locator, bl);
-    }
+    ::encode(locator, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     ::decode(name, bl);
     ::decode(epoch, bl);
     ::decode(exists, bl);
@@ -122,6 +117,7 @@ struct rgw_bucket_dir_entry {
     if (struct_v >= 2) {
       ::decode(locator, bl);
     }
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry)
@@ -132,18 +128,18 @@ struct rgw_bucket_category_stats {
   uint64_t num_entries;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(total_size, bl);
     ::encode(total_size_rounded, bl);
     ::encode(num_entries, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(total_size, bl);
     ::decode(total_size_rounded, bl);
     ::decode(num_entries, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_category_stats)
@@ -152,14 +148,14 @@ struct rgw_bucket_dir_header {
   map<uint8_t, rgw_bucket_category_stats> stats;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(stats, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(stats, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_header)
@@ -169,16 +165,16 @@ struct rgw_bucket_dir {
   std::map<string, struct rgw_bucket_dir_entry> m;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(header, bl);
     ::encode(m, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(header, bl);
     ::decode(m, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir)
@@ -191,27 +187,22 @@ struct rgw_cls_obj_prepare_op
   string locator;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 2;
-    if (!locator.size()) {
-      struct_v = 1; // don't waste the encoding space
-    }
-    ::encode(struct_v, bl);
+    ENCODE_START(3, 3, bl);
     ::encode(op, bl);
     ::encode(name, bl);
     ::encode(tag, bl);
-    if (locator.size()) {
-      ::encode(locator, bl);
-    }
+    ::encode(locator, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     ::decode(op, bl);
     ::decode(name, bl);
     ::decode(tag, bl);
     if (struct_v >= 2) {
       ::decode(locator, bl);
     }
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_cls_obj_prepare_op)
@@ -226,23 +217,17 @@ struct rgw_cls_obj_complete_op
   string tag;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 2;
-    if (!locator.size()) {
-      struct_v = 1; // don't waste the encoding space
-    }
-    ::encode(struct_v, bl);
+    ENCODE_START(3, 3, bl);
     ::encode(op, bl);
     ::encode(name, bl);
     ::encode(epoch, bl);
     ::encode(meta, bl);
     ::encode(tag, bl);
-    if (locator.size()) {
-      ::encode(locator, bl);
-    }
+    ::encode(locator, bl);
+    ENCODE_FINISH(bl);
  }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     ::decode(op, bl);
     ::decode(name, bl);
     ::decode(epoch, bl);
@@ -251,6 +236,7 @@ struct rgw_cls_obj_complete_op
     if (struct_v >= 2) {
       ::decode(locator, bl);
     }
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_cls_obj_complete_op)
@@ -261,16 +247,16 @@ struct rgw_cls_list_op
   uint32_t num_entries;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(start_obj, bl);
     ::encode(num_entries, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(start_obj, bl);
     ::decode(num_entries, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_cls_list_op)
@@ -281,16 +267,16 @@ struct rgw_cls_list_ret
   bool is_truncated;
 
   void encode(bufferlist &bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(dir, bl);
     ::encode(is_truncated, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(dir, bl);
     ::decode(is_truncated, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_cls_list_ret)
index 328685dcd4d9c04a79a974aab5613bf47766f938..f6d5cb18d2efbae7cf38b4e63525aea0f5be6811 100644 (file)
@@ -59,8 +59,6 @@ using ceph::crypto::MD5;
 
 #define RGW_BUCKETS_OBJ_PREFIX ".buckets"
 
-#define USER_INFO_VER 8
-
 #define RGW_MAX_CHUNK_SIZE     (512*1024)
 #define RGW_MAX_PENDING_CHUNKS  16
 #define RGW_MAX_PUT_SIZE        (5ULL*1024*1024*1024)
@@ -281,19 +279,19 @@ struct RGWAccessKey {
 
   RGWAccessKey() {}
   void encode(bufferlist& bl) const {
-     __u32 ver = 1;
-    ::encode(ver, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(id, bl);
     ::encode(key, bl);
     ::encode(subuser, bl);
+    ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-     __u32 ver;
-     ::decode(ver, bl);
+     DECODE_START_LEGACY_COMPAT_LEN_32(2, 2, 2, bl);
      ::decode(id, bl);
      ::decode(key, bl);
      ::decode(subuser, bl);
+     DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(RGWAccessKey);
@@ -304,17 +302,17 @@ struct RGWSubUser {
 
   RGWSubUser() : perm_mask(0) {}
   void encode(bufferlist& bl) const {
-     __u32 ver = 1;
-    ::encode(ver, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(name, bl);
     ::encode(perm_mask, bl);
+    ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-     __u32 ver;
-     ::decode(ver, bl);
+     DECODE_START_LEGACY_COMPAT_LEN_32(2, 2, 2, bl);
      ::decode(name, bl);
      ::decode(perm_mask, bl);
+     DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(RGWSubUser);
@@ -334,8 +332,7 @@ struct RGWUserInfo
   RGWUserInfo() : auid(0), suspended(0) {}
 
   void encode(bufferlist& bl) const {
-     __u32 ver = USER_INFO_VER;
-     ::encode(ver, bl);
+     ENCODE_START(9, 9, bl);
      ::encode(auid, bl);
      string access_key;
      string secret_key;
@@ -364,17 +361,17 @@ struct RGWUserInfo
      ::encode(subusers, bl);
      ::encode(suspended, bl);
      ::encode(swift_keys, bl);
+     ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-     __u32 ver;
-    ::decode(ver, bl);
-     if (ver >= 2) ::decode(auid, bl);
+     DECODE_START_LEGACY_COMPAT_LEN_32(9, 9, 9, bl);
+     if (struct_v >= 2) ::decode(auid, bl);
      else auid = CEPH_AUTH_UID_DEFAULT;
      string access_key;
      string secret_key;
     ::decode(access_key, bl);
     ::decode(secret_key, bl);
-    if (ver < 6) {
+    if (struct_v < 6) {
       RGWAccessKey k;
       k.id = access_key;
       k.key = secret_key;
@@ -384,23 +381,24 @@ struct RGWUserInfo
     ::decode(user_email, bl);
     string swift_name;
     string swift_key;
-    if (ver >= 3) ::decode(swift_name, bl);
-    if (ver >= 4) ::decode(swift_key, bl);
-    if (ver >= 5)
+    if (struct_v >= 3) ::decode(swift_name, bl);
+    if (struct_v >= 4) ::decode(swift_key, bl);
+    if (struct_v >= 5)
       ::decode(user_id, bl);
     else
       user_id = access_key;
-    if (ver >= 6) {
+    if (struct_v >= 6) {
       ::decode(access_keys, bl);
       ::decode(subusers, bl);
     }
     suspended = 0;
-    if (ver >= 7) {
+    if (struct_v >= 7) {
       ::decode(suspended, bl);
     }
-    if (ver >= 8) {
+    if (struct_v >= 8) {
       ::decode(swift_keys, bl);
     }
+    DECODE_FINISH(bl);
   }
 
   void clear() {
@@ -438,22 +436,22 @@ struct rgw_bucket {
   }
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 2;
-    ::encode(struct_v, bl);
+     ENCODE_START(3, 3, bl);
     ::encode(name, bl);
     ::encode(pool, bl);
     ::encode(marker, bl);
     ::encode(bucket_id, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     ::decode(name, bl);
     ::decode(pool, bl);
     if (struct_v >= 2) {
       ::decode(marker, bl);
       ::decode(bucket_id, bl);
     }
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket)
@@ -478,20 +476,20 @@ struct RGWBucketInfo
   uint32_t flags;
 
   void encode(bufferlist& bl) const {
-     __u32 ver = 3;
-     ::encode(ver, bl);
+     ENCODE_START(4, 4, bl);
      ::encode(bucket, bl);
      ::encode(owner, bl);
      ::encode(flags, bl);
+     ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-     __u32 ver;
-     ::decode(ver, bl);
+    DECODE_START_LEGACY_COMPAT_LEN_32(4, 4, 4, bl);
      ::decode(bucket, bl);
-     if (ver >= 2)
+     if (struct_v >= 2)
        ::decode(owner, bl);
-     if (ver >= 3)
+     if (struct_v >= 3)
        ::decode(flags, bl);
+     DECODE_FINISH(bl);
   }
 
   RGWBucketInfo() : flags(0) {}
@@ -608,8 +606,7 @@ struct RGWBucketEnt {
   RGWBucketEnt() : size(0), size_rounded(0), mtime(0), count(0) {}
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 4;
-    ::encode(struct_v, bl);
+    ENCODE_START(5, 5, bl);
     uint64_t s = size;
     __u32 mt = mtime;
     string empty_str;  // originally had the bucket name here, but we encode bucket later
@@ -620,10 +617,10 @@ struct RGWBucketEnt {
     ::encode(bucket, bl);
     s = size_rounded;
     ::encode(s, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(5, 5, 5, bl);
     __u32 mt;
     uint64_t s;
     string empty_str;  // backward compatibility
@@ -639,6 +636,7 @@ struct RGWBucketEnt {
     if (struct_v >= 4)
       ::decode(s, bl);
     size_rounded = s;
+    DECODE_FINISH(bl);
   }
   void clear() {
     bucket.clear();
@@ -657,20 +655,20 @@ struct RGWUploadPartInfo {
   utime_t modified;
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 1;
-    ::encode(struct_v, bl);
+    ENCODE_START(2, 2, bl);
     ::encode(num, bl);
     ::encode(size, bl);
     ::encode(etag, bl);
     ::encode(modified, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     ::decode(num, bl);
     ::decode(size, bl);
     ::decode(etag, bl);
     ::decode(modified, bl);
+    DECODE_FINISH(bl);
   }
 };
 WRITE_CLASS_ENCODER(RGWUploadPartInfo)
@@ -836,23 +834,23 @@ public:
   }
 
   void encode(bufferlist& bl) const {
-    __u8 struct_v = 2;
-    ::encode(struct_v, bl);
+    ENCODE_START(3, 3, bl);
     ::encode(bucket.name, bl);
     ::encode(key, bl);
     ::encode(ns, bl);
     ::encode(object, bl);
     ::encode(bucket, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    __u8 struct_v;
-    ::decode(struct_v, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
     ::decode(bucket.name, bl);
     ::decode(key, bl);
     ::decode(ns, bl);
     ::decode(object, bl);
     if (struct_v >= 2)
       ::decode(bucket, bl);
+    DECODE_FINISH(bl);
   }
 
   bool operator==(const rgw_obj& o) const {
index dd8d08854ba0e62a9e9ddcd6a01c8694897da68c..e0e8defaa4a856768cd14333a8e492baf93beabe 100644 (file)
@@ -4,9 +4,6 @@
 #include "rgw_common.h"
 #include "include/utime.h"
 
-#define LOG_ENTRY_VER 4
-#define INTENT_LOG_ENTRY_VER 1
-
 #define RGW_SHOULD_LOG_DEFAULT 1
 
 #define RGW_LOG_POOL_NAME ".log"
@@ -33,9 +30,7 @@ struct rgw_log_entry {
   uint64_t bucket_id;
 
   void encode(bufferlist &bl) const {
-    uint8_t ver;
-    ver = LOG_ENTRY_VER;
-    ::encode(ver, bl);
+    ENCODE_START(5, 5, bl);
     ::encode(object_owner, bl);
     ::encode(bucket_owner, bl);
     ::encode(bucket, bl);
@@ -54,12 +49,12 @@ struct rgw_log_entry {
     ::encode(referrer, bl);
     ::encode(bytes_received, bl);
     ::encode(bucket_id, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &p) {
-    uint8_t ver;
-    ::decode(ver, p);
+    DECODE_START_LEGACY_COMPAT_LEN(5, 5, 5, p);
     ::decode(object_owner, p);
-    if (ver > 3)
+    if (struct_v > 3)
       ::decode(bucket_owner, p);
     ::decode(bucket, p);
     ::decode(time, p);
@@ -75,15 +70,16 @@ struct rgw_log_entry {
     ::decode(total_time, p);
     ::decode(user_agent, p);
     ::decode(referrer, p);
-    if (ver >= 2)
+    if (struct_v >= 2)
       ::decode(bytes_received, p);
     else
       bytes_received = 0;
 
-    if (ver >= 3)
+    if (struct_v >= 3)
       ::decode(bucket_id, p);
     else
       bucket_id = -1;
+    DECODE_FINISH(p);
   }
 };
 WRITE_CLASS_ENCODER(rgw_log_entry)
@@ -94,19 +90,19 @@ struct rgw_intent_log_entry {
   uint32_t intent;
 
   void encode(bufferlist &bl) const {
-    uint8_t ver;
-    ver = INTENT_LOG_ENTRY_VER;
-    ::encode(ver, bl);
+    ENCODE_START(2, 2, bl);
+    ::encode(struct_v, bl);
     ::encode(obj, bl);
     ::encode(op_time, bl);
     ::encode(intent, bl);
+    ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &p) {
-    uint8_t ver;
-    ::decode(ver, p);
+    DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, p);
     ::decode(obj, p);
     ::decode(op_time, p);
     ::decode(intent, p);
+    DECODE_FINISH(p);
   }
 };
 WRITE_CLASS_ENCODER(rgw_intent_log_entry)