Merge pull request #24062 from nrdmn/fix-quota

rgw: fix max-size in radosgw-admin and REST Admin API

Reviewed-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Yuri Weinstein 2018-09-26 09:00:26 -07:00 committed by GitHub
commit 0fd7413b79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -1862,7 +1862,8 @@ Valid parameters for quotas include:
the maximum number of objects. A negative value disables this setting.
- **Maximum Size:** The ``max-size`` option allows you to specify a quota
for the maximum number of bytes. A negative value disables this setting.
for the maximum number of bytes. The ``max-size-kb`` option allows you
to specify it in KiB. A negative value disables this setting.
- **Quota Type:** The ``quota-type`` option sets the scope for the quota.
The options are ``bucket`` and ``user``.

View File

@ -2842,7 +2842,7 @@ int main(int argc, const char **argv)
return EINVAL;
}
} else if (ceph_argparse_witharg(args, i, &val, "--max-size", (char*)NULL)) {
max_size = strict_iecstrtoll(val.c_str(), &err);
max_size = strict_iec_cast<long long>(val.c_str(), &err);
if (!err.empty()) {
cerr << "ERROR: failed to parse max size: " << err << std::endl;
return EINVAL;

View File

@ -866,11 +866,14 @@ void RGWOp_Quota_Set::execute()
old_quota = &info.bucket_quota;
}
int64_t old_max_size_kb = rgw_rounded_kb(old_quota->max_size);
int64_t max_size_kb;
RESTArgs::get_int64(s, "max-objects", old_quota->max_objects, &quota.max_objects);
RESTArgs::get_int64(s, "max-size-kb", old_max_size_kb, &max_size_kb);
quota.max_size = max_size_kb * 1024;
RESTArgs::get_int64(s, "max-size", old_quota->max_size, &quota.max_size);
int64_t max_size_kb;
bool has_max_size_kb = false;
RESTArgs::get_int64(s, "max-size-kb", 0, &max_size_kb, &has_max_size_kb);
if (has_max_size_kb) {
quota.max_size = max_size_kb * 1024;
}
RESTArgs::get_bool(s, "enabled", old_quota->enabled, &quota.enabled);
}