]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: more detailed resharding status kept in bucket header
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 10 May 2017 18:46:57 +0000 (11:46 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:44 +0000 (13:17 -0700)
So that we can differentiate between in-progress and complete status.

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

index abae4bfbf17a1a77838082f444e22de826686bfa..17ce100b7723e900fcfacf5ece5f04a07f93d936 100644 (file)
@@ -3637,7 +3637,7 @@ static int rgw_set_bucket_resharding(cls_method_context_t hctx, bufferlist *in,
     return rc;
   }
 
-  header.new_instance.set(op.entry.new_bucket_instance_id);
+  header.new_instance.set_status(op.entry.new_bucket_instance_id, op.entry.reshard_status);
 
   return write_bucket_header(hctx, &header);
 }
index c3a97c65760045169caf79a8fa97937834803501..acf782f1f48bff709f55bc01369ecf4a460f43b9 100644 (file)
@@ -596,7 +596,7 @@ 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("resharding", resharding, f);
+  encode_json("reshard_status", (int)reshard_status, f);
   encode_json("new_bucket_instance_id", new_bucket_instance_id, f);
 
 }
@@ -605,6 +605,6 @@ void cls_rgw_bucket_instance_entry::generate_test_instances(list<cls_rgw_bucket_
 {
   ls.push_back(new cls_rgw_bucket_instance_entry);
   ls.push_back(new cls_rgw_bucket_instance_entry);
-  ls.back()->resharding = true;
+  ls.back()->reshard_status = CLS_RGW_RESHARD_IN_PROGRESS;
   ls.back()->new_bucket_instance_id = "new_instance_id";
 }
index dd89e73c2f77c0418d5c6bfe9954ef26ec19aae7..8244a48dff4369a71b6e7a6ca1360f29375a35b4 100644 (file)
@@ -604,20 +604,28 @@ struct rgw_bucket_category_stats {
 };
 WRITE_CLASS_ENCODER(rgw_bucket_category_stats)
 
+enum cls_rgw_reshard_status {
+  CLS_RGW_RESHARD_NONE        = 0,
+  CLS_RGW_RESHARD_IN_PROGRESS = 1,
+  CLS_RGW_RESHARD_DONE        = 2,
+};
+
 struct cls_rgw_bucket_instance_entry {
-  bool resharding{false};
+  cls_rgw_reshard_status reshard_status{CLS_RGW_RESHARD_NONE};
   string new_bucket_instance_id;
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
-    ::encode(resharding, bl);
+    ::encode((uint8_t)reshard_status, bl);
     ::encode(new_bucket_instance_id, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
     DECODE_START(1, bl);
-    ::decode(resharding, bl);
+    uint8_t s;
+    ::decode(s, bl);
+    reshard_status = (cls_rgw_reshard_status)s;
     ::decode(new_bucket_instance_id, bl);
     DECODE_FINISH(bl);
   }
@@ -626,14 +634,18 @@ struct cls_rgw_bucket_instance_entry {
   static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
 
   void clear() {
-    resharding = false;
+    reshard_status = CLS_RGW_RESHARD_NONE;
     new_bucket_instance_id.clear();
   }
 
-  void set(const string& new_instance_id) {
-    resharding = true;
+  void set_status(const string& new_instance_id, cls_rgw_reshard_status s) {
+    reshard_status = s;
     new_bucket_instance_id = new_instance_id;
   }
+
+  bool resharding() const {
+    return reshard_status != CLS_RGW_RESHARD_NONE;
+  }
 };
 WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
 
@@ -685,7 +697,7 @@ struct rgw_bucket_dir_header {
   static void generate_test_instances(list<rgw_bucket_dir_header*>& o);
 
   bool resharding() const {
-    return new_instance.resharding;
+    return new_instance.resharding();
   }
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_header)
index 6033591bff4e9596d4a9a4b50318c7b631f7b5d7..385fdd0b6d71cbce8b65649538452fe45677ecab 100644 (file)
@@ -228,7 +228,7 @@ int RGWBucketReshard::init_resharding(const string& new_instance_id)
   }
 
   cls_rgw_bucket_instance_entry instance_entry;
-  instance_entry.set(new_instance_id);
+  instance_entry.set_status(new_instance_id, CLS_RGW_RESHARD_IN_PROGRESS);
 
   int ret = store->bucket_set_reshard(bucket_info, instance_entry);
   if (ret < 0) {
@@ -571,33 +571,23 @@ int RGWReshard::unlock_bucket_index(const string& oid)
 const int num_retries = 10;
 const int default_reshard_sleep_duration = 30;
 
-int RGWReshard::block_while_resharding(const string& bucket_instance_oid,
-                                      BucketIndexLockGuard& guard)
+int RGWReshard::block_while_resharding(const string& bucket_instance_oid)
 {
   int ret = 0;
   cls_rgw_bucket_instance_entry entry;
 
   for (int i=0; i< num_retries;i++) {
-    ret = guard.lock();
-    if (ret < 0) {
-      return ret;
-    }
-
     ret = cls_rgw_get_bucket_resharding(store->reshard_pool_ctx, bucket_instance_oid, &entry);
     if (ret < 0) {
       ldout(store->ctx(), 0) << "RGWReshard::" << __func__ << " ERROR: failed to get bucket resharding :"  <<
        cpp_strerror(-ret)<< dendl;
       return ret;
     }
-
-    ret = guard.unlock();
-    if (ret < 0) {
-      return ret;
-    }
-    if (!entry.resharding) {
+    if (!entry.resharding()) {
       return 0;
     }
     /* needed to unlock as clear resharding uses the same lock */
+#warning replace sleep with interruptible condition
     sleep(default_reshard_sleep_duration);
   }
   ldout(store->ctx(), 0) << "RGWReshard::" << __func__ << " ERROR: bucket is still resharding, please retry" << dendl;
index da9ede7d1893cb8c482ff432e0f434538b911ef3..d20412f59ba9c3b5eadddc5a944462eb22c1f9b0 100644 (file)
@@ -85,7 +85,7 @@ class RGWReshard {
       if succefull, keeps the bucket index locked. It will be unlocked
       in the guard dtor.
      */
-    int block_while_resharding(const string& bucket_instance_oid, BucketIndexLockGuard& guard);
+    int block_while_resharding(const string& bucket_instance_oid);
 };
 
 #endif