]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: a few fixes
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 10 May 2017 16:39:55 +0000 (09:39 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:44 +0000 (13:17 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/common/config_opts.h
src/rgw/rgw_admin.cc
src/rgw/rgw_reshard.cc

index 9c0c626ba0538efcb422cbc5692a6d1e02f4a3c6..ac95b1540d4d42d94e818c96c7c283aed35afb29 100644 (file)
@@ -1734,3 +1734,4 @@ OPTION(rgw_swift_custom_header, OPT_STR, "") // option to enable swift custom he
 
 /* resharding tunables */
 OPTION(rgw_reshard_max_jobs, OPT_INT, 1024)
+OPTION(rgw_reshard_bucket_lock_duration, OPT_INT, 120) // duration of lock on bucket obj during resharding
index a5692985dbdb29ffe47a5dbd42ca95e1350b89e7..a7abc56142aaf5aa10ea25745c04e2ce87d9c7f0 100644 (file)
@@ -517,7 +517,6 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_
       strcmp(cmd, "quota") == 0 ||
       strcmp(cmd, "realm") == 0 ||
       strcmp(cmd, "replicalog") == 0 ||
-      strcmp(cmd, "reshard") == 0 ||
       strcmp(cmd, "role") == 0 ||
       strcmp(cmd, "role-policy") == 0 ||
       strcmp(cmd, "subuser") == 0 ||
@@ -526,8 +525,13 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_
       strcmp(cmd, "user") == 0 ||
       strcmp(cmd, "zone") == 0 ||
       strcmp(cmd, "zonegroup") == 0 ||
-      strcmp(cmd, "zonegroups") == 0)
-{
+      strcmp(cmd, "zonegroups") == 0) {
+    *need_more = true;
+    return 0;
+  }
+
+  if (strcmp(cmd, "reshard") == 0 &&
+      !(prev_cmd && strcmp(prev_cmd, "bucket") == 0)) {
     *need_more = true;
     return 0;
   }
@@ -2228,17 +2232,17 @@ int check_reshard_bucket_params(RGWRados *store,
 {
   if (bucket_name.empty()) {
     cerr << "ERROR: bucket not specified" << std::endl;
-    return EINVAL;
+    return -EINVAL;
   }
 
   if (!num_shards_specified) {
     cerr << "ERROR: --num-shards not specified" << std::endl;
-    return EINVAL;
+    return -EINVAL;
   }
 
   if (num_shards > (int)store->get_max_bucket_shards()) {
     cerr << "ERROR: num_shards too high, max value: " << store->get_max_bucket_shards() << std::endl;
-    return EINVAL;
+    return -EINVAL;
   }
 
   int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket, &attrs);
@@ -2252,7 +2256,7 @@ int check_reshard_bucket_params(RGWRados *store,
   if (num_shards <= num_source_shards && !yes_i_really_mean_it) {
     cerr << "num shards is less or equal to current shards count" << std::endl
         << "do you really mean it? (requires --yes-i-really-mean-it)" << std::endl;
-    return EINVAL;
+    return -EINVAL;
   }
   return 0;
 }
@@ -5546,6 +5550,11 @@ next:
 
     RGWBucketReshard br(store, bucket_info, attrs);
 
+#define DEFAULT_RESHARD_MAX_ENTRIES 1000
+    if (max_entries < 1) {
+      max_entries = DEFAULT_RESHARD_MAX_ENTRIES;
+    }
+
     return br.execute(num_shards, max_entries,
                       verbose, &cout, formatter);
   }
index 94ef05adf3788e8bc1b73540ac2027e2d5b3ebbd..6033591bff4e9596d4a9a4b50318c7b631f7b5d7 100644 (file)
@@ -192,12 +192,18 @@ RGWBucketReshard::RGWBucketReshard(RGWRados *_store, const RGWBucketInfo& _bucke
                                                      reshard_lock(reshard_lock_name) {
   const rgw_bucket& b = bucket_info.bucket;                                                       
   reshard_oid = b.tenant + (b.tenant.empty() ? "" : ":") + b.name + ":" + b.bucket_id;
+
+  utime_t lock_duration(store->ctx()->_conf->rgw_reshard_bucket_lock_duration, 0);
+#define COOKIE_LEN 16
+  char cookie_buf[COOKIE_LEN + 1];
+  gen_rand_alphanumeric(store->ctx(), cookie_buf, sizeof(cookie_buf) - 1);
+
+  reshard_lock.set_cookie(cookie_buf);
+  reshard_lock.set_duration(lock_duration);
 }
 
 int RGWBucketReshard::lock_bucket()
 {
-#warning set timeout for guard lock
-
   int ret = reshard_lock.lock_exclusive(&store->reshard_pool_ctx, reshard_oid);
   if (ret < 0) {
     ldout(store->ctx(), 0) << "RGWReshard::add failed to acquire lock on " << reshard_oid << " ret=" << ret << dendl;
@@ -249,6 +255,8 @@ int RGWBucketReshard::clear_resharding()
 int RGWBucketReshard::create_new_bucket_instance(int new_num_shards,
                                                  RGWBucketInfo& new_bucket_info)
 {
+  new_bucket_info = bucket_info;
+
   store->create_bucket_id(&new_bucket_info.bucket.bucket_id);
   new_bucket_info.bucket.oid.clear();
 
@@ -389,7 +397,7 @@ int RGWBucketReshard::do_reshard(
   string err;
   int r = RGWBucketAdminOp::link(store, bucket_op, &err);
   if (r < 0) {
-    lderr(store->ctx()) << "failed to link new bucket instance (bucket_id=" << new_bucket_info.bucket.bucket_id << ": " << err << "; " << cpp_strerror(-r) << dendl;
+    lderr(store->ctx()) << "failed to link new bucket instance (bucket_id=" << new_bucket_info.bucket.bucket_id << ": " << err << "; " << cpp_strerror(-r) << ")" << dendl;
     return -r;
   }
   return 0;