{
int ret = RGWBucketReshard::set_reshard_status(rgw::BucketReshardState::InProgress, dpp);
if (ret < 0) {
- cerr << "ERROR: failed to store updated bucket instance info: " << cpp_strerror(-ret) << std::endl;
+ lderr(store->ctx()) << "ERROR: failed to store updated bucket instance info: " << dendl;
return ret;
}
return ::set_target_layout(store, new_num_shards, bucket_info, dpp);
// resharding successful, so remove old bucket index shards; use
// best effort and don't report out an error; the lock isn't needed
- // at this point since all we're using a best effor to to remove old
+ // at this point since all we're using a best effort to remove old
// shard objects
ret = store->svc()->bi->clean_index(bucket_info, prev_index);
ret = RGWBucketReshard::set_reshard_status(rgw::BucketReshardState::None, dpp);
if (ret < 0) {
- cerr << "ERROR: failed to store updated bucket instance info: " << cpp_strerror(-ret) << std::endl;
+ lderr(store->ctx()) << "ERROR: failed to store updated bucket instance info: " << dendl;
return ret;
}
return 0;
}
+static char bucket_obj_with_generation(char *buf, size_t len, const string& bucket_oid_base, uint64_t gen_id,
+ uint32_t shard_id)
+{
+ return snprintf(buf, len, "%s.%" PRIu64 ".%d", bucket_oid_base.c_str(), gen_id, shard_id);
+}
+
+static char bucket_obj_without_generation(char *buf, size_t len, const string& bucket_oid_base, uint32_t shard_id)
+{
+ return snprintf(buf, len, "%s.%d", bucket_oid_base.c_str(), shard_id);
+}
+
static void get_bucket_index_objects(const string& bucket_oid_base,
uint32_t num_shards, uint64_t gen_id,
map<int, string> *_bucket_objects,
if (shard_id < 0) {
for (uint32_t i = 0; i < num_shards; ++i) {
if (gen_id) {
- snprintf(buf, sizeof(buf), "%s.%" PRIu64 ".%d", bucket_oid_base.c_str(), gen_id, i);
- bucket_objects[i] = buf;
- } else {
- snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), i);
- bucket_objects[i] = buf;
- }
+ bucket_obj_with_generation(buf, sizeof(buf), bucket_oid_base, gen_id, i);
+ } else {
+ bucket_obj_without_generation(buf, sizeof(buf), bucket_oid_base, i);
+ }
+ bucket_objects[i] = buf;
}
} else {
- if ((uint32_t)shard_id > num_shards) {
+ if (static_cast<uint32_t>(shard_id) > num_shards) {
return;
} else {
- if (gen_id) {
- snprintf(buf, sizeof(buf), "%s.%" PRIu64 ".%d", bucket_oid_base.c_str(), gen_id, shard_id);
- bucket_objects[shard_id] = buf;
- } else {
- // for backward compatibility, gen_id(0) will not be added in the object name
- snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), shard_id);
- bucket_objects[shard_id] = buf;
- }
+ if (gen_id) {
+ bucket_obj_with_generation(buf, sizeof(buf), bucket_oid_base, gen_id, shard_id);
+ } else {
+ // for backward compatibility, gen_id(0) will not be added in the object name
+ bucket_obj_without_generation(buf, sizeof(buf), bucket_oid_base, shard_id);
+ }
+ bucket_objects[shard_id] = buf;
}
}
}
(*result)[i] = plain_id + buf;
}
} else {
- if ((uint32_t)shard_id > bucket_info.layout.current_index.layout.normal.num_shards) {
+ if (static_cast<uint32_t>(shard_id) > bucket_info.layout.current_index.layout.normal.num_shards) {
return;
}
snprintf(buf, sizeof(buf), ":%d", shard_id);
} else {
char buf[bucket_oid_base.size() + 64];
if (gen_id) {
- snprintf(buf, sizeof(buf), "%s.%" PRIu64 ".%d", bucket_oid_base.c_str(), gen_id, shard_id);
+ bucket_obj_with_generation(buf, sizeof(buf), bucket_oid_base, gen_id, shard_id);
(*bucket_obj) = buf;
ldout(cct, 10) << "bucket_obj is " << (*bucket_obj) << dendl;
} else {
// for backward compatibility, gen_id(0) will not be added in the object name
- snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), shard_id);
+ bucket_obj_without_generation(buf, sizeof(buf), bucket_oid_base, shard_id);
(*bucket_obj) = buf;
}
}
uint32_t sid = bucket_shard_index(obj_key, num_shards);
char buf[bucket_oid_base.size() + 64];
if (gen_id) {
- snprintf(buf, sizeof(buf), "%s.%" PRIu64 ".%d", bucket_oid_base.c_str(), gen_id, sid);
+ bucket_obj_with_generation(buf, sizeof(buf), bucket_oid_base, gen_id, sid);
} else {
- snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), sid);
+ bucket_obj_without_generation(buf, sizeof(buf), bucket_oid_base, sid);
}
(*bucket_obj) = buf;
if (shard_id) {