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 ||
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;
}
{
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);
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;
}
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);
}
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;
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();
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;