string location_constraint;
};
+// BucketIndex
+struct RGWCreateBucketIndex : XMLObj {
+ XMLObj* type = nullptr;
+ XMLObj* num_shards = nullptr;
+
+ bool xml_end(const char*) override {
+ type = find_first("Type");
+ num_shards = find_first("NumShards");
+ return true;
+ }
+};
+
// CreateBucketConfiguration
struct RGWCreateBucketConfig : XMLObj {
XMLObj* location_constraint = nullptr;
+ RGWCreateBucketIndex* index = nullptr;
bool xml_end(const char*) override {
location_constraint = find_first("LocationConstraint");
+ index = static_cast<RGWCreateBucketIndex*>(find_first("BucketIndex"));
return true;
}
};
using namespace std::string_view_literals;
if (el == "CreateBucketConfiguration"sv) {
return new RGWCreateBucketConfig;
+ } else if (el == "BucketIndex"sv) {
+ return new RGWCreateBucketIndex;
}
return new XMLObj;
}
ldpp_dout(this, 10) << "create bucket location constraint: "
<< location_constraint << dendl;
}
+
+ if (config->index) {
+ if (!config->index->type) {
+ s->err.message = "Missing required element Type in BucketIndex";
+ return -EINVAL;
+ }
+ rgw::BucketIndexType type;
+ if (!parse(config->index->type->get_data(), type)) {
+ s->err.message = "Unknown Type in BucketIndex";
+ return -EINVAL;
+ }
+ createparams.index_type = type;
+
+ if (config->index->num_shards) {
+ if (type != rgw::BucketIndexType::Normal) {
+ s->err.message = "NumShards requires Type to be Normal";
+ return -EINVAL;
+ }
+ auto val = ceph::parse<uint32_t>(config->index->num_shards->get_data());
+ if (!val) {
+ s->err.message = "Failed to parse integer NumShards in BucketIndex";
+ return -EINVAL;
+ }
+ if (*val == 0) {
+ s->err.message = "NumShards must be greater than 0";
+ return -EINVAL;
+ }
+ const auto limit = s->cct->_conf.get_val<uint64_t>("rgw_max_dynamic_shards");
+ if (*val > limit) {
+ s->err.message = fmt::format("NumShards cannot exceed {}", limit);
+ return -EINVAL;
+ }
+ createparams.index_shards = val;
+ }
+ }
}
size_t pos = location_constraint.find(':');