-Subproject commit c332279082854effc00ea93c226f2f211f73631d
+Subproject commit b0d1137d31e4b36b72ccae9c0a9a13de2ec82faa
-Subproject commit 8d271315a541218caada366f84a2690fdbd474a2
+Subproject commit 061cd700231eb8e6e3e6e075e2245debb332b00c
parse_bucket(entry, tenant_name, bucket_name);
rgw_bucket bucket;
+ RGWZonePlacementInfo rule_info;
ret = store->set_bucket_location_by_rule(bci.info.placement_rule,
- tenant_name, bucket_name, bucket);
+ tenant_name, bucket_name, bucket, &rule_info);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: select_bucket_placement() returned " << ret << dendl;
return ret;
}
bci.info.bucket.data_pool = bucket.data_pool;
bci.info.bucket.index_pool = bucket.index_pool;
+ bci.info.index_type = rule_info.index_type;
} else {
/* existing bucket, keep its placement pools */
bci.info.bucket.data_pool = old_bci.info.bucket.data_pool;
bci.info.bucket.index_pool = old_bci.info.bucket.index_pool;
+ bci.info.index_type = old_bci.info.index_type;
}
// are we actually going to perform this put, or is it too old?
BUCKET_VERSIONS_SUSPENDED = 0x4,
};
+enum RGWBucketIndexType {
+ RGWBIType_Normal = 0,
+ RGWBIType_Indexless = 1,
+};
+
struct RGWBucketInfo
{
enum BIShardsHashType {
bool has_website;
RGWBucketWebsiteConf website_conf;
+ RGWBucketIndexType index_type;
+
void encode(bufferlist& bl) const {
- ENCODE_START(14, 4, bl);
+ ENCODE_START(15, 4, bl);
::encode(bucket, bl);
::encode(owner.id, bl);
::encode(flags, bl);
if (has_website) {
::encode(website_conf, bl);
}
+ ::encode((uint32_t)index_type, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
website_conf = RGWBucketWebsiteConf();
}
}
+ if (struct_v >= 15) {
+ uint32_t it;
+ ::decode(it, bl);
+ index_type = (RGWBucketIndexType)it;
+ } else {
+ index_type = RGWBIType_Normal;
+ }
DECODE_FINISH(bl);
}
void dump(Formatter *f) const;
encode_json("index_pool", index_pool, f);
encode_json("data_pool", data_pool, f);
encode_json("data_extra_pool", data_extra_pool, f);
+ encode_json("index_type", (uint32_t)index_type, f);
}
void RGWZonePlacementInfo::decode_json(JSONObj *obj)
JSONDecoder::decode_json("index_pool", index_pool, obj);
JSONDecoder::decode_json("data_pool", data_pool, obj);
JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj);
+ uint32_t it;
+ JSONDecoder::decode_json("index_type", it, obj);
+ index_type = (RGWBucketIndexType)it;
}
void RGWZoneParams::decode_json(JSONObj *obj)
op_ret = store->select_bucket_placement(*(s->user), zonegroup_id,
placement_rule,
s->bucket_tenant, s->bucket_name,
- bucket, &selected_placement_rule);
+ bucket, &selected_placement_rule, nullptr);
if (selected_placement_rule != s->bucket_info.placement_rule) {
op_ret = -EEXIST;
return;
bool exclusive)
{
#define MAX_CREATE_RETRIES 20 /* need to bound retries */
- string selected_placement_rule;
+ string selected_placement_rule_name;
+ RGWZonePlacementInfo rule_info;
+
for (int i = 0; i < MAX_CREATE_RETRIES; i++) {
int ret = 0;
ret = select_bucket_placement(owner, zonegroup_id, placement_rule,
bucket.tenant, bucket.name, bucket,
- &selected_placement_rule);
+ &selected_placement_rule_name, &rule_info);
if (ret < 0)
return ret;
bufferlist bl;
info.bucket = bucket;
info.owner = owner.user_id;
info.zonegroup = zonegroup_id;
- info.placement_rule = selected_placement_rule;
+ info.placement_rule = selected_placement_rule_name;
+ info.index_type = rule_info.index_type;
info.num_shards = bucket_index_max_shards;
info.bucket_index_shard_hash_type = RGWBucketInfo::MOD;
info.requester_pays = false;
}
int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& request_rule,
- const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule)
+ const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule_name,
+ RGWZonePlacementInfo *rule_info)
+
{
/* first check that rule exists within the specific zonegroup */
RGWZoneGroup zonegroup;
return -EIO;
}
- if (!rule.empty()) {
- map<string, RGWZoneGroupPlacementTarget>::iterator titer = zonegroup.placement_targets.find(rule);
- if (titer == zonegroup.placement_targets.end()) {
- ldout(cct, 0) << "could not find placement rule " << rule << " within zonegroup " << dendl;
- return -EINVAL;
- }
+ map<string, RGWZoneGroupPlacementTarget>::iterator titer = zonegroup.placement_targets.find(rule);
+ if (titer == zonegroup.placement_targets.end()) {
+ ldout(cct, 0) << "could not find placement rule " << rule << " within zonegroup " << dendl;
+ return -EINVAL;
+ }
- /* now check tag for the rule, whether user is permitted to use rule */
- RGWZoneGroupPlacementTarget& target_rule = titer->second;
- if (!target_rule.user_permitted(user_info.placement_tags)) {
- ldout(cct, 0) << "user not permitted to use placement rule" << dendl;
- return -EPERM;
- }
+ /* now check tag for the rule, whether user is permitted to use rule */
+ RGWZoneGroupPlacementTarget& target_rule = titer->second;
+ if (!target_rule.user_permitted(user_info.placement_tags)) {
+ ldout(cct, 0) << "user not permitted to use placement rule" << dendl;
+ return -EPERM;
}
- if (pselected_rule)
- *pselected_rule = rule;
-
- return set_bucket_location_by_rule(rule, tenant_name, bucket_name, bucket);
+ if (pselected_rule_name)
+ *pselected_rule_name = rule;
+
+ return set_bucket_location_by_rule(rule, tenant_name, bucket_name, bucket, rule_info);
}
-int RGWRados::set_bucket_location_by_rule(const string& location_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket)
+int RGWRados::set_bucket_location_by_rule(const string& location_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket,
+ RGWZonePlacementInfo *rule_info)
{
bucket.tenant = tenant_name;
bucket.name = bucket_name;
/* we can only reach here if we're trying to set a bucket location from a bucket
* created on a different zone, using a legacy / default pool configuration
*/
- return select_legacy_bucket_placement(tenant_name, bucket_name, bucket);
+ return select_legacy_bucket_placement(tenant_name, bucket_name, bucket, rule_info);
}
/*
bucket.data_extra_pool = placement_info.data_extra_pool;
bucket.index_pool = placement_info.index_pool;
+ if (rule_info) {
+ *rule_info = placement_info;
+ }
+
return 0;
}
int RGWRados::select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& placement_rule,
const string& tenant_name, const string& bucket_name, rgw_bucket& bucket,
- string *pselected_rule)
+ string *pselected_rule_name, RGWZonePlacementInfo *rule_info)
{
if (!get_zone_params().placement_pools.empty()) {
return select_new_bucket_location(user_info, zonegroup_id, placement_rule,
- tenant_name, bucket_name, bucket, pselected_rule);
+ tenant_name, bucket_name, bucket, pselected_rule_name, rule_info);
}
- if (pselected_rule)
- pselected_rule->clear();
+ if (pselected_rule_name) {
+ pselected_rule_name->clear();
+ }
- return select_legacy_bucket_placement(tenant_name, bucket_name, bucket);
+ return select_legacy_bucket_placement(tenant_name, bucket_name, bucket, rule_info);
}
-int RGWRados::select_legacy_bucket_placement(const string& tenant_name, const string& bucket_name, rgw_bucket& bucket)
+int RGWRados::select_legacy_bucket_placement(const string& tenant_name, const string& bucket_name, rgw_bucket& bucket,
+ RGWZonePlacementInfo *rule_info)
{
bufferlist map_bl;
map<string, bufferlist> m;
bucket.data_pool = pool_name;
bucket.index_pool = pool_name;
+ rule_info->data_pool = pool_name;
+ rule_info->data_extra_pool = pool_name;
+ rule_info->index_pool = pool_name;
+ rule_info->index_type = RGWBIType_Normal;
+
return 0;
}
string index_pool;
string data_pool;
string data_extra_pool; /* if not set we should use data_pool */
+ RGWBucketIndexType index_type;
+
+ RGWZonePlacementInfo() : index_type(RGWBIType_Normal) {}
void encode(bufferlist& bl) const {
- ENCODE_START(4, 1, bl);
+ ENCODE_START(5, 1, bl);
::encode(index_pool, bl);
::encode(data_pool, bl);
::encode(data_extra_pool, bl);
+ ::encode((uint32_t)index_type, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator& bl) {
- DECODE_START(4, bl);
+ DECODE_START(5, bl);
::decode(index_pool, bl);
::decode(data_pool, bl);
if (struct_v >= 4) {
::decode(data_extra_pool, bl);
}
+ if (struct_v >= 5) {
+ uint32_t it;
+ ::decode(it, bl);
+ index_type = (RGWBucketIndexType)it;
+ }
DECODE_FINISH(bl);
}
const string& get_data_extra_pool() {
*/
virtual int init_bucket_index(rgw_bucket& bucket, int num_shards);
int select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& rule,
- const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule);
- int select_legacy_bucket_placement(const string& tenant_name, const string& bucket_name, rgw_bucket& bucket);
+ const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule_name,
+ RGWZonePlacementInfo *rule_info);
+ int select_legacy_bucket_placement(const string& tenant_name, const string& bucket_name, rgw_bucket& bucket,
+ RGWZonePlacementInfo *rule_info);
int select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& rule,
- const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule);
- int set_bucket_location_by_rule(const string& location_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket);
+ const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule_name,
+ RGWZonePlacementInfo *rule_info);
+ int set_bucket_location_by_rule(const string& location_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket,
+ RGWZonePlacementInfo *rule_info);
virtual int create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
const string& zonegroup_id,
const string& placement_rule,