zone_name = g_conf()->rgw_zone;
zonegroup_name = g_conf()->rgw_zonegroup;
- RGWStreamFlusher f(formatter.get(), cout);
+ RGWStreamFlusher stream_flusher(formatter.get(), cout);
RGWUserAdminOpState user_op(store);
if (!user_email.empty()) {
return -ret;
}
} else {
- int ret = RGWBucketAdminOp::get_policy(store, bucket_op, f, dpp());
+ int ret = RGWBucketAdminOp::get_policy(store, bucket_op, stream_flusher, dpp());
if (ret < 0) {
cerr << "ERROR: failed to get policy: " << cpp_strerror(-ret) << std::endl;
return -ret;
if (!rgw::sal::User::empty(user)) {
user_ids.push_back(user->get_id().id);
ret =
- RGWBucketAdminOp::limit_check(store, bucket_op, user_ids, f,
+ RGWBucketAdminOp::limit_check(store, bucket_op, user_ids, stream_flusher,
null_yield, dpp(), warnings_only);
} else {
/* list users in groups of max-keys, then perform user-bucket
} else {
/* ok, do the limit checks for this group */
ret =
- RGWBucketAdminOp::limit_check(store, bucket_op, user_ids, f,
+ RGWBucketAdminOp::limit_check(store, bucket_op, user_ids, stream_flusher,
null_yield, dpp(), warnings_only);
if (ret < 0)
break;
return -ENOENT;
}
}
- RGWBucketAdminOp::info(store, bucket_op, f, null_yield, dpp());
+ RGWBucketAdminOp::info(store, bucket_op, stream_flusher, null_yield, dpp());
} else {
int ret = init_bucket(user.get(), tenant, bucket_name, bucket_id, &bucket);
if (ret < 0) {
}
bucket_op.set_fetch_stats(true);
- int r = RGWBucketAdminOp::info(store, bucket_op, f, null_yield, dpp());
+ int r = RGWBucketAdminOp::info(store, bucket_op, stream_flusher, null_yield, dpp());
if (r < 0) {
cerr << "failure: " << cpp_strerror(-r) << ": " << err << std::endl;
return -r;
}
ret = RGWUsage::show(dpp(), store, user.get(), bucket.get(), start_epoch,
end_epoch, show_log_entries, show_log_sum, &categories,
- f);
+ stream_flusher);
if (ret < 0) {
cerr << "ERROR: failed to show usage" << std::endl;
return 1;
}
if (opt_cmd == OPT::OBJECTS_EXPIRE_STALE_LIST) {
- ret = RGWBucketAdminOp::fix_obj_expiry(store, bucket_op, f, dpp(), true);
+ ret = RGWBucketAdminOp::fix_obj_expiry(store, bucket_op, stream_flusher, dpp(), true);
if (ret < 0) {
cerr << "ERROR: listing returned " << cpp_strerror(-ret) << std::endl;
return -ret;
}
if (opt_cmd == OPT::OBJECTS_EXPIRE_STALE_RM) {
- ret = RGWBucketAdminOp::fix_obj_expiry(store, bucket_op, f, dpp(), false);
+ ret = RGWBucketAdminOp::fix_obj_expiry(store, bucket_op, stream_flusher, dpp(), false);
if (ret < 0) {
cerr << "ERROR: removing returned " << cpp_strerror(-ret) << std::endl;
return -ret;
}
do_check_object_locator(tenant, bucket_name, fix, remove_bad, formatter.get());
} else {
- RGWBucketAdminOp::check_index(store, bucket_op, f, null_yield, dpp());
+ RGWBucketAdminOp::check_index(store, bucket_op, stream_flusher, null_yield, dpp());
}
}
if (opt_cmd == OPT::LC_RESHARD_FIX) {
- ret = RGWBucketAdminOp::fix_lc_shards(store, bucket_op, f, dpp());
+ ret = RGWBucketAdminOp::fix_lc_shards(store, bucket_op, stream_flusher, dpp());
if (ret < 0) {
cerr << "ERROR: listing stale instances" << cpp_strerror(-ret) << std::endl;
}
return EINVAL;
}
- ret = RGWBucketAdminOp::list_stale_instances(store, bucket_op, f, dpp());
+ ret = RGWBucketAdminOp::list_stale_instances(store, bucket_op, stream_flusher, dpp());
if (ret < 0) {
cerr << "ERROR: listing stale instances" << cpp_strerror(-ret) << std::endl;
}
return EINVAL;
}
- ret = RGWBucketAdminOp::clear_stale_instances(store, bucket_op,f, dpp());
+ ret = RGWBucketAdminOp::clear_stale_instances(store, bucket_op, stream_flusher, dpp());
if (ret < 0) {
cerr << "ERROR: deleting stale instances" << cpp_strerror(-ret) << std::endl;
}
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp
-#ifndef CEPH_RGW_BUCKET_H
-#define CEPH_RGW_BUCKET_H
+#pragma once
#include <string>
#include <memory>
/**
* Store a list of the user's buckets, with associated functinos.
*/
-class RGWUserBuckets
-{
+class RGWUserBuckets {
std::map<std::string, RGWBucketEnt> buckets;
public:
bucket_stored(false), sync_bucket(true) {}
};
+
/*
* A simple wrapper class for administrative bucket operations
*/
-
-class RGWBucket
-{
+class RGWBucket {
RGWUserBuckets buckets;
rgw::sal::Store* store;
RGWAccessHandle handle;
const RGWBucketInfo& get_bucket_info() const { return bucket->get_info(); }
};
-class RGWBucketAdminOp
-{
+class RGWBucketAdminOp {
public:
static int get_policy(rgw::sal::Store* store, RGWBucketAdminOpState& op_state,
RGWFormatterFlusher& flusher, const DoutPrefixProvider *dpp);
: ep(ep), attrs(attrs) {}
};
-class RGWBucketCtl
-{
+class RGWBucketCtl {
CephContext *cct;
struct Svc {
bool rgw_find_bucket_by_id(const DoutPrefixProvider *dpp, CephContext *cct, rgw::sal::Store* store, const string& marker,
const string& bucket_id, rgw_bucket* bucket_out);
-
-#endif
map<RGWObjCategory, RGWStorageStats> *calculated_stats)
{
RGWSI_RADOS::Pool index_pool;
+
// key - bucket index object id
// value - bucket index check OP returned result with the given bucket index object (shard)
map<int, string> oids;
- map<int, struct rgw_cls_check_index_ret> bucket_objs_ret;
-
int ret = svc.bi_rados->open_bucket_index(dpp, bucket_info, std::nullopt, &index_pool, &oids, nullptr);
if (ret < 0) {
- return ret;
+ return ret;
}
+ // declare and pre-populate
+ map<int, struct rgw_cls_check_index_ret> bucket_objs_ret;
for (auto& iter : oids) {
- bucket_objs_ret[iter.first] = rgw_cls_check_index_ret();
+ bucket_objs_ret.emplace(iter.first, rgw_cls_check_index_ret());
}
ret = CLSRGWIssueBucketCheck(index_pool.ioctx(), oids, bucket_objs_ret, cct->_conf->rgw_bucket_index_max_aio)();
if (ret < 0) {
- return ret;
+ return ret;
}
- // Aggregate results (from different shards if there is any)
- map<int, struct rgw_cls_check_index_ret>::iterator iter;
- for (iter = bucket_objs_ret.begin(); iter != bucket_objs_ret.end(); ++iter) {
- accumulate_raw_stats(iter->second.existing_header, *existing_stats);
- accumulate_raw_stats(iter->second.calculated_header, *calculated_stats);
+ // aggregate results (from different shards if there are any)
+ for (const auto& iter : bucket_objs_ret) {
+ accumulate_raw_stats(iter.second.existing_header, *existing_stats);
+ accumulate_raw_stats(iter.second.calculated_header, *calculated_stats);
}
return 0;