]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cls/rgw: adjust types and ops
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 4 May 2017 22:11:09 +0000 (15:11 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:41 +0000 (13:17 -0700)
 - don't keep data bufferlist in struct cls_rgw_bucket_instance_entry
 - remove rgw_get_bucket_instance

We need to keep the reshard info as part of the bucket index header (for
each source bucket shard), and not in a separate object. Otherwise it'll
be impossible to have the resharding check atomic as part of the regular
bucket index updates.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/cls/rgw/cls_rgw_ops.cc
src/cls/rgw/cls_rgw_ops.h
src/cls/rgw/cls_rgw_types.cc
src/cls/rgw/cls_rgw_types.h

index e8d59424288b267bc4b8777603984bb50741362a..f25bbe5fe1d081c683cb35bbb2122a08e3a90208 100644 (file)
@@ -3618,8 +3618,6 @@ static int rgw_reshard_remove(cls_method_context_t hctx, bufferlist *in, bufferl
   return ret;
 }
 
-const string resharding_attr = "resharding";
-
 static int rgw_set_bucket_resharding(cls_method_context_t hctx, bufferlist *in,  bufferlist *out)
 {
   cls_rgw_set_bucket_resharding_op op;
@@ -3639,8 +3637,7 @@ static int rgw_set_bucket_resharding(cls_method_context_t hctx, bufferlist *in,
     return rc;
   }
 
-  header.is_resharding = true;
-  header.new_bucket_instance_id = op.entry.new_bucket_instance_id;
+  header.new_instance.set(op.entry.new_bucket_instance_id);
 
   return write_bucket_header(hctx, &header);
 }
@@ -3663,8 +3660,7 @@ static int rgw_clear_bucket_resharding(cls_method_context_t hctx, bufferlist *in
     CLS_LOG(1, "ERROR: %s(): failed to read header\n", __func__);
     return rc;
   }
-  header.is_resharding = false;
-  header.new_bucket_instance_id.clear();
+  header.new_instance.clear();
 
   return write_bucket_header(hctx, &header);
 }
@@ -3689,7 +3685,7 @@ static int rgw_get_bucket_resharding(cls_method_context_t hctx, bufferlist *in,
   }
 
   cls_rgw_get_bucket_resharding_ret op_ret;
-  op_ret.resharding = header.is_resharding;
+  op_ret.new_instance = header.new_instance;
 
   ::encode(op_ret, *out);
 
@@ -3802,6 +3798,7 @@ CLS_INIT(rgw)
                          rgw_clear_bucket_resharding, &h_rgw_clear_bucket_resharding);
   cls_register_cxx_method(h_class, "get_bucket_resharding", CLS_METHOD_RD ,
                          rgw_get_bucket_resharding, &h_rgw_get_bucket_resharding);
+
   return;
 }
 
index da85cbe4175de5a62dfd510128a884ab9eda6a58..eed5d5b1d0a30c89d62f1255ff441bc9a70ea2f1 100644 (file)
@@ -855,22 +855,19 @@ int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
   return io_ctx.exec(oid, "rgw", "set_bucket_resharding", in, out);
 }
 
-int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
-                                   const cls_rgw_bucket_instance_entry& entry)
+int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid)
 {
   bufferlist in, out;
   struct cls_rgw_clear_bucket_resharding_op call;
-  call.entry = entry;
   ::encode(call, in);
   return io_ctx.exec(oid, "rgw", "clear_bucket_resharding", in, out);
 }
 
 int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
-                                 const cls_rgw_bucket_instance_entry& entry, bool& resharding)
+                                 cls_rgw_bucket_instance_entry *entry)
 {
   bufferlist in, out;
   struct cls_rgw_get_bucket_resharding_op call;
-  call.entry = entry;
   ::encode(call, in);
   int r= io_ctx.exec(oid, "rgw", "get_bucket_resharding", in, out);
   if (r < 0)
@@ -884,7 +881,7 @@ int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
     return -EIO;
   }
 
-  resharding = op_ret.resharding;
+  *entry = op_ret.new_instance;
 
   return 0;
 }
index fa3967ca21695781de298ac98744c09127ae373b..2affa7dc20328d06daadb4a55dfa87d565c68512 100644 (file)
@@ -504,9 +504,8 @@ void cls_rgw_reshard_remove(librados::ObjectWriteOperation& op, const cls_rgw_re
 /* resharding attribute  */
 int cls_rgw_set_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
                                   const cls_rgw_bucket_instance_entry& entry);
-int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
-                                    const cls_rgw_bucket_instance_entry& entry);
+int cls_rgw_clear_bucket_resharding(librados::IoCtx& io_ctx, const string& oid);
 int cls_rgw_get_bucket_resharding(librados::IoCtx& io_ctx, const string& oid,
-                                  const cls_rgw_bucket_instance_entry& entry, bool& resharding);
+                                  cls_rgw_bucket_instance_entry *entry);
 
 #endif
index 192fec85de7277fc3af28449927fe0916c5591f0..13121319963491ad12063ff8875bdb8ef05f13fc 100644 (file)
@@ -514,7 +514,6 @@ void cls_rgw_clear_bucket_resharding_op::generate_test_instances(
 
 void cls_rgw_clear_bucket_resharding_op::dump(Formatter *f) const
 {
-  ::encode_json("entry", entry, f);
 }
 
 void cls_rgw_get_bucket_resharding_op::generate_test_instances(
@@ -526,7 +525,6 @@ void cls_rgw_get_bucket_resharding_op::generate_test_instances(
 
 void cls_rgw_get_bucket_resharding_op::dump(Formatter *f) const
 {
-  ::encode_json("entry", entry, f);
 }
 
 
index b182a8b09483164aa950a41f72e80040f9096f55..5d9a43f5e68df6a9db8c76ac940cb1d47d3a8be7 100644 (file)
@@ -1301,17 +1301,13 @@ struct cls_rgw_set_bucket_resharding_op  {
 WRITE_CLASS_ENCODER(cls_rgw_set_bucket_resharding_op)
 
 struct cls_rgw_clear_bucket_resharding_op {
-  cls_rgw_bucket_instance_entry entry;
-
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
-    ::encode(entry, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
     DECODE_START(1, bl);
-    ::decode(entry, bl);
     DECODE_FINISH(bl);
   }
   static void generate_test_instances(list<cls_rgw_clear_bucket_resharding_op*>& o);
@@ -1320,17 +1316,14 @@ struct cls_rgw_clear_bucket_resharding_op {
 WRITE_CLASS_ENCODER(cls_rgw_clear_bucket_resharding_op)
 
 struct cls_rgw_get_bucket_resharding_op  {
-  cls_rgw_bucket_instance_entry entry;
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
-    ::encode(entry, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
     DECODE_START(1, bl);
-    ::decode(entry, bl);
     DECODE_FINISH(bl);
   }
 
@@ -1340,17 +1333,17 @@ struct cls_rgw_get_bucket_resharding_op  {
 WRITE_CLASS_ENCODER(cls_rgw_get_bucket_resharding_op)
 
 struct cls_rgw_get_bucket_resharding_ret  {
-  bool resharding;
+  cls_rgw_bucket_instance_entry new_instance;
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
-    ::encode(resharding, bl);
+    ::encode(new_instance, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
     DECODE_START(1, bl);
-    ::decode(resharding, bl);
+    ::decode(new_instance, bl);
     DECODE_FINISH(bl);
   }
 
index c0af4c06a7759b280f1ecfa7ad381349e0a0e355..c3a97c65760045169caf79a8fa97937834803501 100644 (file)
@@ -517,8 +517,7 @@ void rgw_bucket_dir_header::dump(Formatter *f) const
     iter->second.dump(f);
     f->close_section();
   }
-  f->dump_bool("is_resharding", is_resharding);
-  f->dump_string("new_bucket_instance_id",new_bucket_instance_id);
+  ::encode_json("new_instance", new_instance, f);
   f->close_section();
 }
 
@@ -597,7 +596,6 @@ void cls_rgw_reshard_entry::generate_test_instances(list<cls_rgw_reshard_entry*>
 
 void cls_rgw_bucket_instance_entry::dump(Formatter *f) const
 {
-  encode_json("data", data, f);
   encode_json("resharding", resharding, f);
   encode_json("new_bucket_instance_id", new_bucket_instance_id, f);
 
index a6eb2ef8e8c12202f50d4395d5e4856f5f16e91a..dd89e73c2f77c0418d5c6bfe9954ef26ec19aae7 100644 (file)
@@ -604,14 +604,46 @@ struct rgw_bucket_category_stats {
 };
 WRITE_CLASS_ENCODER(rgw_bucket_category_stats)
 
+struct cls_rgw_bucket_instance_entry {
+  bool resharding{false};
+  string new_bucket_instance_id;
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ::encode(resharding, bl);
+    ::encode(new_bucket_instance_id, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    ::decode(resharding, bl);
+    ::decode(new_bucket_instance_id, bl);
+    DECODE_FINISH(bl);
+  }
+
+  void dump(Formatter *f) const;
+  static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
+
+  void clear() {
+    resharding = false;
+    new_bucket_instance_id.clear();
+  }
+
+  void set(const string& new_instance_id) {
+    resharding = true;
+    new_bucket_instance_id = new_instance_id;
+  }
+};
+WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
+
 struct rgw_bucket_dir_header {
   map<uint8_t, rgw_bucket_category_stats> stats;
   uint64_t tag_timeout;
   uint64_t ver;
   uint64_t master_ver;
   string max_marker;
-  bool is_resharding;
-  string new_bucket_instance_id;
+  cls_rgw_bucket_instance_entry new_instance;
 
   rgw_bucket_dir_header() : tag_timeout(0), ver(0), master_ver(0) {}
 
@@ -622,8 +654,7 @@ struct rgw_bucket_dir_header {
     ::encode(ver, bl);
     ::encode(master_ver, bl);
     ::encode(max_marker, bl);
-    ::encode(is_resharding, bl);
-    ::encode(new_bucket_instance_id, bl);
+    ::encode(new_instance, bl);
     ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
@@ -644,15 +675,18 @@ struct rgw_bucket_dir_header {
       ::decode(max_marker, bl);
     }
     if (struct_v >= 6) {
-      ::decode(is_resharding, bl);
-      ::decode(new_bucket_instance_id, bl);
+      ::decode(new_instance, bl);
     } else {
-        is_resharding = false;
+      new_instance = cls_rgw_bucket_instance_entry();
     }
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;
   static void generate_test_instances(list<rgw_bucket_dir_header*>& o);
+
+  bool resharding() const {
+    return new_instance.resharding;
+  }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_header)
 
@@ -1054,30 +1088,4 @@ struct cls_rgw_reshard_entry
 };
 WRITE_CLASS_ENCODER(cls_rgw_reshard_entry)
 
-struct cls_rgw_bucket_instance_entry {
-  bool resharding;
-  string new_bucket_instance_id;
-  bufferlist data;
-
-  void encode(bufferlist& bl) const {
-    ENCODE_START(1, 1, bl);
-    ::encode(resharding, bl);
-    ::encode(new_bucket_instance_id, bl);
-    ::encode(data, bl);
-    ENCODE_FINISH(bl);
-  }
-
-  void decode(bufferlist::iterator& bl) {
-    DECODE_START(1, bl);
-    ::decode(resharding, bl);
-    ::decode(new_bucket_instance_id, bl);
-    ::decode(data, bl);
-    DECODE_FINISH(bl);
-  }
-
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
-};
-WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
-
 #endif