Skip to content

Commit

Permalink
rgw: rename the configurables for metadata limits to start with rgw_.
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
  • Loading branch information
rzarzynski committed Sep 19, 2017
1 parent 308c8d3 commit 9b06985
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
8 changes: 8 additions & 0 deletions src/common/options.cc
Expand Up @@ -4163,6 +4163,14 @@ std::vector<Option> get_rgw_options() {
.set_default(1 * 1024 * 1024)
.set_description(""),

Option("rgw_max_attr_size", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(0)
.set_description("The maximum length of metadata value. 0 skips the check"),

Option("rgw_max_attr_name_len", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(0)
.set_description("The maximum length of metadata name. 0 skips the check"),

Option("rgw_max_attrs_num_in_req", Option::TYPE_UINT, Option::LEVEL_ADVANCED)
.set_default(0)
.set_description("The maximum number of metadata items that can be put via single request"),
Expand Down
14 changes: 8 additions & 6 deletions src/rgw/rgw_op.h
Expand Up @@ -1914,19 +1914,21 @@ static inline int rgw_get_request_metadata(CephContext* const cct,
std::string attr_name(RGW_ATTR_PREFIX);
attr_name.append(name);

/* Check early whether we aren't going behind the limit on attribute
/* Check roughly whether we aren't going behind the limit on attribute
* name. Passing here doesn't guarantee that an OSD will accept that
* as ObjectStore::get_max_attr_name_length() can set the limit even
* lower. However, we're claiming "max_meta_name_length" in /info as
* being dependent on the "osd_max_attr_name_len". */
if (attr_name.length() > cct->_conf->osd_max_attr_name_len) {
* lower than the "osd_max_attr_name_len" configurable. */
const size_t max_attr_name_len = \
cct->_conf->get_val<size_t>("rgw_max_attr_name_len");
if (max_attr_name_len && attr_name.length() > max_attr_name_len) {
return -ENAMETOOLONG;
}

/* Similar remarks apply to the check for value size. We're veryfing
* it early at the RGW's side as it's being claimed in /info. */
if (cct->_conf->osd_max_attr_size &&
xattr.length() > cct->_conf->osd_max_attr_size) {
const size_t max_attr_size = \
cct->_conf->get_val<size_t>("rgw_max_attr_size");
if (max_attr_size && xattr.length() > max_attr_size) {
return -EFBIG;
}

Expand Down
14 changes: 9 additions & 5 deletions src/rgw/rgw_rest_swift.cc
Expand Up @@ -654,7 +654,7 @@ static inline int handle_metadata_errors(req_state* const s, const int op_ret)
* (stored as xattr) size. */
const auto error_message = boost::str(
boost::format("Metadata value longer than %lld")
% int(s->cct->_conf->osd_max_attr_size));
% s->cct->_conf->get_val<size_t>("rgw_max_attr_size"));
set_req_state_err(s, EINVAL, error_message);
return -EINVAL;
} else if (op_ret == -E2BIG) {
Expand Down Expand Up @@ -1715,11 +1715,15 @@ void RGWInfo_ObjStore_SWIFT::list_swift_data(Formatter& formatter,
string ceph_version(CEPH_GIT_NICE_VER);
formatter.dump_string("version", ceph_version);

const size_t meta_name_limit = g_conf->osd_max_attr_name_len
- strlen(RGW_ATTR_PREFIX RGW_AMZ_META_PREFIX);
formatter.dump_int("max_meta_name_length", meta_name_limit);
const size_t max_attr_name_len = \
g_conf->get_val<size_t>("rgw_max_attr_name_len");
if (max_attr_name_len) {
const size_t meta_name_limit = \
max_attr_name_len - strlen(RGW_ATTR_PREFIX RGW_AMZ_META_PREFIX);
formatter.dump_int("max_meta_name_length", meta_name_limit);
}

const size_t meta_value_limit = g_conf->osd_max_attr_size;
const size_t meta_value_limit = g_conf->get_val<size_t>("rgw_max_attr_size");
if (meta_value_limit) {
formatter.dump_int("max_meta_value_length", meta_value_limit);
}
Expand Down

0 comments on commit 9b06985

Please sign in to comment.