#include "rgw_common.h"
#include "rgw_reshard.h"
#include "rgw_lc.h"
+#include "rgw_bucket_layout.h"
// stolen from src/cls/version/cls_version.cc
#define VERSION_ATTR "ceph.objclass.version"
return do_put_operate(&put_op);
}
-void init_default_bucket_layout(CephContext *cct, RGWBucketInfo& info, const RGWZone& zone) {
- info.layout.current_index.gen = 0;
- info.layout.current_index.layout.normal.hash_type = rgw::BucketHashType::Mod;
- info.layout.current_index.layout.type = rgw::BucketIndexType::Normal;
+void init_default_bucket_layout(CephContext *cct, rgw::BucketLayout& layout,
+ const RGWZone& zone,
+ std::optional<uint32_t> shards,
+ std::optional<rgw::BucketIndexType> type) {
+ layout.current_index.gen = 0;
+ layout.current_index.layout.normal.hash_type = rgw::BucketHashType::Mod;
- info.layout.current_index.layout.normal.num_shards = (
- cct->_conf->rgw_override_bucket_index_max_shards > 0 ?
- cct->_conf->rgw_override_bucket_index_max_shards : zone.bucket_index_max_shards);
+ layout.current_index.layout.type =
+ type.value_or(rgw::BucketIndexType::Normal);
+
+ 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 {
+ layout.current_index.layout.normal.num_shards =
+ zone.bucket_index_max_shards;
+ }
+
+ if (layout.current_index.layout.type == rgw::BucketIndexType::Normal) {
+ layout.logs.push_back(log_layout_from_index(
+ layout.current_index.gen,
+ layout.current_index.layout.normal));
+ }
}
int RGWMetadataHandlerPut_BucketInstance::put_check()
RGWBucketCompleteInfo *old_bci = (orig_obj ? &orig_obj->get_bci() : nullptr);
- bool exists = (!!orig_obj);
+ const bool exists = (!!orig_obj);
if (from_remote_zone) {
// don't sync bucket layout changes
if (!exists) {
- init_default_bucket_layout(cct, bci.info, bihandler->svc.zone->get_zone());
+ auto& bci_index = bci.info.layout.current_index.layout;
+ auto index_type = bci_index.type;
+ auto num_shards = bci_index.normal.num_shards;
+ init_default_bucket_layout(cct, bci.info.layout,
+ bihandler->svc.zone->get_zone(),
+ num_shards, index_type);
} else {
bci.info.layout = old_bci->info.layout;
}
// conforms to the type declaration of RGWRados::check_filter_t.
extern bool rgw_bucket_object_check_filter(const string& oid);
-extern void init_default_bucket_layout(CephContext *cct, RGWBucketInfo& info, const RGWZone& zone);
+void init_default_bucket_layout(CephContext *cct, rgw::BucketLayout& layout,
+ const RGWZone& zone,
+ std::optional<uint32_t> shards,
+ std::optional<rgw::BucketIndexType> type);
struct RGWBucketCompleteInfo {
RGWBucketInfo info;
info.placement_rule = selected_placement_rule;
info.swift_ver_location = swift_ver_location;
info.swift_versioning = (!swift_ver_location.empty());
- init_default_bucket_layout(cct, info, svc.zone->get_zone());
- if (pmaster_num_shards) {
- // TODO: remove this once sync doesn't require the same shard count
- info.layout.current_index.layout.normal.num_shards = *pmaster_num_shards;
- }
- info.layout.current_index.layout.normal.hash_type = rgw::BucketHashType::Mod;
- info.layout.current_index.layout.type = rule_info.index_type;
- if (info.layout.current_index.layout.type == rgw::BucketIndexType::Normal) {
- // use the same index layout for the bilog
- const auto gen = info.layout.current_index.gen;
- const auto& index = info.layout.current_index.layout.normal;
- info.layout.logs.push_back(rgw::log_layout_from_index(gen, index));
- }
+
+ init_default_bucket_layout(cct, info.layout, svc.zone->get_zone(),
+ pmaster_num_shards ?
+ std::optional{*pmaster_num_shards} :
+ std::nullopt,
+ rule_info.index_type);
info.requester_pays = false;
if (real_clock::is_zero(creation_time)) {