From: Lei Dong Date: Mon, 27 Oct 2014 02:29:48 +0000 (+0800) Subject: fix can not disable max_size quota X-Git-Tag: v0.80.9~22^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ac799f0834783590cbb6eb91784c8e0753cb1e03;p=ceph.git fix can not disable max_size quota Currently if we enable quota and set max_size = -1, it doesn’t mean max_size is unlimited as expected. Instead, it means object with any size is not allowed to upload because of “QuotaExceeded”. The root cause is the function rgw_rounded_kb which convert max_size to max_size_kb returns 0 for -1 because it takes an unsigned int but we pass an int to it. A simple fix is check max_size before it’s rounded to max_size_kb. Test case: 1 enable and set quota: radosgw-admin quota enable --uid={user_id} --quota-scope=user radosgw-admin quota set --quota-scope=user --uid={user_id}\ --max-objects=100 --max-size=-1 2 upload any object with non-zero length it will return 403 with “QuotaExceeded” and return 200 if you apply the fix. Fixes: #9907 Backport: giant, firefly Signed-off-by: Dong Lei leidong@yahoo-inc.com (cherry picked from commit abd3fd3ef9ee9999b99811937af60b7a5e673e35) --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 730c57df27e44..f6c5619e5ef84 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -679,7 +679,11 @@ void set_quota_info(RGWQuotaInfo& quota, int opt_cmd, int64_t max_size, int64_t quota.max_objects = max_objects; } if (have_max_size) { - quota.max_size_kb = rgw_rounded_kb(max_size); + if (max_size < 0) { + quota.max_size_kb = -1; + } else { + quota.max_size_kb = rgw_rounded_kb(max_size); + } } break; case OPT_QUOTA_DISABLE: