]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: decode rgw_raw_obj as rgw_obj when it's old object
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 11 Oct 2016 22:44:17 +0000 (15:44 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 9 Mar 2017 17:18:51 +0000 (09:18 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_rados.h

index 19c55b31131dbfbe21cfa2ff909543761ea403e0..a91c89e0a9a9e3c0d7806bda57b69dd77b8bbc37 100644 (file)
@@ -14,6 +14,7 @@
 #include "rgw_common.h"
 #include "rgw_acl.h"
 #include "rgw_string.h"
+#include "rgw_rados.h"
 
 #include "common/ceph_crypto.h"
 #include "common/armor.h"
@@ -1434,6 +1435,14 @@ bool RGWUserCaps::is_valid_cap_type(const string& tp)
   return false;
 }
 
+void rgw_raw_obj::decode_from_rgw_obj(bufferlist::iterator& bl)
+{
+  rgw_obj old_obj;
+  ::decode(old_obj, bl);
+
+  RGWRados::obj_to_raw(old_obj, this);
+}
+
 std::string rgw_bucket::get_key(char tenant_delim, char id_delim) const
 {
   static constexpr size_t shard_len{12}; // ":4294967295\0"
index 5cd07b5ab3abc06feef45f2b34113dbe4372b2c2..53b01dc61979fbb97583e9e1fa5284984752c019 100644 (file)
@@ -861,9 +861,21 @@ struct rgw_raw_obj {
     ::encode(loc, bl);
     ENCODE_FINISH(bl);
   }
+
+  void decode_from_rgw_obj(bufferlist::iterator& bl);
+
   void decode(bufferlist::iterator& bl) {
-     DECODE_START(6, bl);
-#warning decode old rgw_obj
+    unsigned ofs = bl.get_off();
+    DECODE_START(6, bl);
+    if (struct_v < 6) {
+      /*
+       * this object was encoded as rgw_obj, prior to rgw_raw_obj been split out of it,
+       * let's decode it as rgw_obj and convert it
+       */
+      bl.seek(ofs);
+      decode_from_rgw_obj(bl);
+      return;
+    }
     ::decode(pool, bl);
     ::decode(oid, bl);
     ::decode(loc, bl);
index 5a63bb802f885f2e64044b3b0670ffb031defbfc..45388c2c95151fd6c526949ba8e2082ed095e307 100644 (file)
@@ -2272,7 +2272,7 @@ public:
   }
 
   int get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool = NULL);
-  void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj);
+  static void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj);
 
   int list_raw_objects(const rgw_pool& pool, const string& prefix_filter, int max,
                        RGWListRawObjsCtx& ctx, list<string>& oids,