#include <limits>
#include <sstream>
-#include "rgw_rados.h"
#include "rgw_zone.h"
#include "rgw_bucket.h"
#include "rgw_reshard.h"
#include "rgw_sal.h"
+#include "rgw_sal_rados.h"
#include "cls/rgw/cls_rgw_client.h"
#include "cls/lock/cls_lock_client.h"
#include "common/errno.h"
rgw::sal::RGWRadosStore *store;
const RGWBucketInfo& bucket_info;
int num_shard;
+ const rgw::bucket_index_layout_generation& idx_layout;
RGWRados::BucketShard bs;
vector<rgw_cls_bi_entry> entries;
map<RGWObjCategory, rgw_bucket_category_stats> stats;
public:
BucketReshardShard(rgw::sal::RGWRadosStore *_store, const RGWBucketInfo& _bucket_info,
- int _num_shard,
+ int _num_shard, const rgw::bucket_index_layout_generation& _idx_layout,
deque<librados::AioCompletion *>& _completions) :
- store(_store), bucket_info(_bucket_info), bs(store->getRados()),
+ store(_store), bucket_info(_bucket_info), idx_layout(_idx_layout), bs(store->getRados()),
aio_completions(_completions)
{
- num_shard = (bucket_info.num_shards > 0 ? _num_shard : -1);
- bs.init(bucket_info.bucket, num_shard, nullptr /* no RGWBucketInfo */);
+ num_shard = (idx_layout.layout.normal.num_shards > 0 ? _num_shard : -1);
+
+ bs.init(bucket_info.bucket, num_shard, idx_layout, nullptr /* no RGWBucketInfo */);
max_aio_completions =
store->ctx()->_conf.get_val<uint64_t>("rgw_reshard_max_aio");
int _num_target_shards) :
store(_store), target_bucket_info(_target_bucket_info),
num_target_shards(_num_target_shards)
- {
+ {
+ const auto& idx_layout = target_bucket_info.layout.current_index;
target_shards.resize(num_target_shards);
for (int i = 0; i < num_target_shards; ++i) {
- target_shards[i] = new BucketReshardShard(store, target_bucket_info, i, completions);
+ target_shards[i] = new BucketReshardShard(store, target_bucket_info, i, idx_layout, completions);
}
}
int RGWBucketReshard::clear_index_shard_reshard_status(rgw::sal::RGWRadosStore* store,
const RGWBucketInfo& bucket_info)
{
- uint32_t num_shards = bucket_info.num_shards;
+ uint32_t num_shards = bucket_info.layout.current_index.layout.normal.num_shards;
if (num_shards < std::numeric_limits<uint32_t>::max()) {
int ret = set_resharding_status(store, bucket_info,
store->getRados()->create_bucket_id(&new_bucket_info.bucket.bucket_id);
- new_bucket_info.num_shards = new_num_shards;
+ new_bucket_info.layout.current_index.layout.normal.num_shards = new_num_shards;
new_bucket_info.objv_tracker.clear();
new_bucket_info.new_bucket_instance_id.clear();
ostream *out,
Formatter *formatter)
{
- rgw_bucket& bucket = bucket_info.bucket;
-
- int ret = 0;
-
if (out) {
- (*out) << "tenant: " << bucket_info.bucket.tenant << std::endl;
- (*out) << "bucket name: " << bucket_info.bucket.name << std::endl;
- (*out) << "old bucket instance id: " << bucket_info.bucket.bucket_id <<
+ const rgw_bucket& bucket = bucket_info.bucket;
+ (*out) << "tenant: " << bucket.tenant << std::endl;
+ (*out) << "bucket name: " << bucket.name << std::endl;
+ (*out) << "old bucket instance id: " << bucket.bucket_id <<
std::endl;
(*out) << "new bucket instance id: " << new_bucket_info.bucket.bucket_id <<
std::endl;
// complete successfully
BucketInfoReshardUpdate bucket_info_updater(store, bucket_info, bucket_attrs, new_bucket_info.bucket.bucket_id);
- ret = bucket_info_updater.start();
+ int ret = bucket_info_updater.start();
if (ret < 0) {
ldout(store->ctx(), 0) << __func__ << ": failed to update bucket info ret=" << ret << dendl;
return ret;
}
- int num_target_shards = (new_bucket_info.num_shards > 0 ? new_bucket_info.num_shards : 1);
+ int num_target_shards = (new_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? new_bucket_info.layout.current_index.layout.normal.num_shards : 1);
BucketReshardManager target_shards_mgr(store, new_bucket_info, num_target_shards);
}
const int num_source_shards =
- (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+ (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
string marker;
for (int i = 0; i < num_source_shards; ++i) {
bool is_truncated = true;
marker.clear();
while (is_truncated) {
entries.clear();
- ret = store->getRados()->bi_list(bucket, i, string(), marker, max_entries, &entries, &is_truncated);
+ ret = store->getRados()->bi_list(bucket_info, i, string(), marker, max_entries, &entries, &is_truncated);
if (ret < 0 && ret != -ENOENT) {
derr << "ERROR: bi_list(): " << cpp_strerror(-ret) << dendl;
return ret;
// place the multipart .meta object on the same shard as its head object
obj.index_hash_source = mp.get_key();
}
- int ret = store->getRados()->get_target_shard_id(new_bucket_info, obj.get_hash_object(), &target_shard_id);
+ int ret = store->getRados()->get_target_shard_id(new_bucket_info.layout.current_index.layout.normal, obj.get_hash_object(), &target_shard_id);
if (ret < 0) {
lderr(store->ctx()) << "ERROR: get_target_shard_id() returned ret=" << ret << dendl;
return ret;
int ret = cls_rgw_reshard_list(store->getRados()->reshard_pool_ctx, logshard_oid, marker, max, entries, is_truncated);
if (ret < 0) {
+ lderr(store->ctx()) << "ERROR: failed to list reshard log entries, oid=" << logshard_oid << " "
+ << "marker=" << marker << " " << cpp_strerror(ret) << dendl;
if (ret == -ENOENT) {
*is_truncated = false;
ret = 0;
} else {
- lderr(store->ctx()) << "ERROR: failed to list reshard log entries, oid=" << logshard_oid << dendl;
if (ret == -EACCES) {
lderr(store->ctx()) << "access denied to pool " << store->svc()->zone->get_zone_params().reshard_pool
<< ". Fix the pool access permissions of your client" << dendl;
return -ECANCELED;
}
-#ifdef HAVE_BOOST_CONTEXT
if (y) {
auto& context = y.get_io_context();
auto& yield = y.get_yield_context();
waiters.erase(waiters.iterator_to(waiter));
return -ec.value();
}
-#endif
cond.wait_for(lock, duration);