rgw: make max number of bucket/object tags configurble

Signed-off-by: Chang Liu <liuchang0812@gmail.com>
This commit is contained in:
Chang Liu 2019-05-08 17:16:03 +08:00
parent 8eedfddc01
commit 5248a81bc5
3 changed files with 13 additions and 10 deletions

View File

@ -534,7 +534,7 @@ int RGWPutBucketTags_ObjStore_S3::get_params()
return -ERR_MALFORMED_XML;
}
RGWObjTags obj_tags;
RGWObjTags obj_tags(50); // A tag set can contain as many as 50 tags, or it can be empty.
r = tagging.rebuild(obj_tags);
if (r < 0)
return r;

View File

@ -9,10 +9,6 @@
#include "rgw_tag.h"
static constexpr uint32_t MAX_OBJ_TAGS=10;
static constexpr uint32_t MAX_TAG_KEY_SIZE=128;
static constexpr uint32_t MAX_TAG_VAL_SIZE=256;
bool RGWObjTags::add_tag(const string&key, const string& val){
return tag_map.emplace(std::make_pair(key,val)).second;
}
@ -22,9 +18,9 @@ bool RGWObjTags::emplace_tag(std::string&& key, std::string&& val){
}
int RGWObjTags::check_and_add_tag(const string&key, const string& val){
if (tag_map.size() == MAX_OBJ_TAGS ||
key.size() > MAX_TAG_KEY_SIZE ||
val.size() > MAX_TAG_VAL_SIZE ||
if (tag_map.size() == max_obj_tags ||
key.size() > max_tag_key_size ||
val.size() > max_tag_val_size ||
key.size() == 0){
return -ERR_INVALID_TAG;
}

View File

@ -15,9 +15,16 @@ class RGWObjTags
protected:
using tag_map_t = boost::container::flat_map <std::string, std::string>;
tag_map_t tag_map;
uint32_t max_obj_tags{10};
uint32_t max_tag_key_size{128};
uint32_t max_tag_val_size{256};
public:
RGWObjTags() {}
~RGWObjTags() {}
RGWObjTags() = default;
RGWObjTags(uint32_t max_obj_tags):max_obj_tags(max_obj_tags) {}
virtual ~RGWObjTags() = default;
void encode(bufferlist& bl) const {
ENCODE_START(1,1,bl);