void init_default_bucket_layout(CephContext *cct, rgw::BucketLayout& layout,
const RGWZone& zone,
- std::optional<rgw::BucketIndexType> type) {
+ std::optional<rgw::BucketIndexType> type,
+ std::optional<uint32_t> shards) {
layout.current_index.gen = 0;
layout.current_index.layout.normal.hash_type = rgw::BucketHashType::Mod;
layout.current_index.layout.type =
type.value_or(rgw::BucketIndexType::Normal);
- if (cct->_conf->rgw_override_bucket_index_max_shards > 0) {
+ if (shards) {
+ layout.current_index.layout.normal.num_shards = *shards;
+ } else if (cct->_conf->rgw_override_bucket_index_max_shards > 0) {
layout.current_index.layout.normal.num_shards =
cct->_conf->rgw_override_bucket_index_max_shards;
} else {
bci.info.layout = rgw::BucketLayout{};
init_default_bucket_layout(dpp->get_cct(), bci.info.layout,
svc_zone->get_zone(),
- std::nullopt);
+ std::nullopt, std::nullopt);
}
}
void init_default_bucket_layout(CephContext *cct, rgw::BucketLayout& layout,
const RGWZone& zone,
- std::optional<rgw::BucketIndexType> type);
+ std::optional<rgw::BucketIndexType> type,
+ std::optional<uint32_t> shards);
struct RGWBucketCompleteInfo {
RGWBucketInfo info;
const std::optional<std::string>& swift_ver_location,
const std::optional<RGWQuotaInfo>& quota,
std::optional<ceph::real_time> creation_time,
+ std::optional<rgw::BucketIndexType> index_type,
+ std::optional<uint32_t> index_shards,
obj_version* pep_objv,
RGWBucketInfo& info)
{
}
if (zone_placement) {
+ if (!index_type) {
+ index_type = zone_placement->index_type;
+ }
init_default_bucket_layout(cct, info.layout, svc.zone->get_zone(),
- zone_placement->index_type);
+ index_type, index_shards);
}
info.requester_pays = false;
const std::optional<std::string>& swift_ver_location,
const std::optional<RGWQuotaInfo>& quota,
std::optional<ceph::real_time> creation_time,
+ std::optional<rgw::BucketIndexType> index_type,
+ std::optional<uint32_t> index_shards,
obj_version* pep_objv,
RGWBucketInfo& info);
dpp, y, key, params.owner, params.zonegroup_id,
params.placement_rule, params.zone_placement, params.attrs,
params.obj_lock_enabled, params.swift_ver_location,
- params.quota, params.creation_time, &bucket_version, info);
+ params.quota, params.creation_time, params.index_type,
+ params.index_shards, &bucket_version, info);
bool existed = false;
if (ret == -EEXIST) {
if (info.owner != params.owner) {
return -ERR_BUCKET_EXISTS;
}
+ // prevent re-creation with different index type or shard count
+ if ((params.index_type && *params.index_type !=
+ info.layout.current_index.layout.type) ||
+ (params.index_shards && *params.index_shards !=
+ info.layout.current_index.layout.normal.num_shards)) {
+ return -ERR_BUCKET_EXISTS;
+ }
ret = 0;
} else if (ret != 0) {
return ret;
std::optional<std::string> swift_ver_location;
std::optional<RGWQuotaInfo> quota;
std::optional<ceph::real_time> creation_time;
+ std::optional<rgw::BucketIndexType> index_type;
+ std::optional<uint32_t> index_shards;
};
/// Create this bucket in the backing store.