summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-10-02 16:29:23 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-10-02 16:29:23 -0700
commit2c8891088000efde9d4e359b1237bc4d9909c2a4 (patch)
treef1d926c3123718e5e99146745cbb4836a9e6545e
parent07bb72a0abe1b292e3a80c7c58808de57ac5deea (diff)
downloadceph-2c8891088000efde9d4e359b1237bc4d9909c2a4.tar.gz
rgw: handle negative quota as non-assigned values
This means that we can have a 0 as a quota value. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_quota.cc19
-rw-r--r--src/rgw/rgw_quota.h6
2 files changed, 17 insertions, 8 deletions
diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc
index 8dfd52f6cb8..569b2fa74a6 100644
--- a/src/rgw/rgw_quota.cc
+++ b/src/rgw/rgw_quota.cc
@@ -95,9 +95,10 @@ void RGWBucketStatsCache::adjust_bucket_stats(rgw_bucket& bucket, int objs_delta
class RGWQuotaHandlerImpl : public RGWQuotaHandler {
+ RGWRados *store;
RGWBucketStatsCache stats_cache;
public:
- RGWQuotaHandlerImpl(RGWRados *store) : stats_cache(store) {}
+ RGWQuotaHandlerImpl(RGWRados *_store) : store(_store), stats_cache(_store) {}
virtual int check_quota(rgw_bucket& bucket, RGWQuotaInfo& bucket_quota,
uint64_t num_objs, uint64_t size) {
uint64_t size_kb = rgw_rounded_kb(size);
@@ -111,12 +112,20 @@ public:
if (ret < 0)
return ret;
- if (bucket_quota.max_objects &&
- stats.num_objects + num_objs > bucket_quota.max_objects) {
+ ldout(store->ctx(), 20) << "bucket quota: max_objects=" << bucket_quota.max_objects
+ << " max_size_kb=" << bucket_quota.max_size_kb << dendl;
+
+ if (bucket_quota.max_objects >= 0 &&
+ stats.num_objects + num_objs > (uint64_t)bucket_quota.max_objects) {
+ ldout(store->ctx(), 10) << "quota exceeded: stats.num_objects=" << stats.num_objects
+ << " bucket_quota.max_objects=" << bucket_quota.max_objects << dendl;
+
return -ERR_QUOTA_EXCEEDED;
}
- if (bucket_quota.max_size_kb &&
- stats.num_kb_rounded + size_kb > bucket_quota.max_size_kb) {
+ if (bucket_quota.max_size_kb >= 0 &&
+ stats.num_kb_rounded + size_kb > (uint64_t)bucket_quota.max_size_kb) {
+ ldout(store->ctx(), 10) << "quota exceeded: stats.num_kb_rounded=" << stats.num_kb_rounded << " size_kb=" << size_kb
+ << " bucket_quota.max_size_kb=" << bucket_quota.max_size_kb << dendl;
return -ERR_QUOTA_EXCEEDED;
}
diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h
index 8b0404795b8..39cfc62de55 100644
--- a/src/rgw/rgw_quota.h
+++ b/src/rgw/rgw_quota.h
@@ -9,11 +9,11 @@ class RGWRados;
class JSONObj;
struct RGWQuotaInfo {
- uint64_t max_size_kb;
- uint64_t max_objects;
+ int64_t max_size_kb;
+ int64_t max_objects;
bool enabled;
- RGWQuotaInfo() : max_size_kb(0), max_objects(0), enabled(false) {}
+ RGWQuotaInfo() : max_size_kb(-1), max_objects(-1), enabled(false) {}
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);