#define ERR_NOT_FOUND 2023
#define ERR_PERMANENT_REDIRECT 2024
#define ERR_LOCKED 2025
+#define ERR_QUOTA_EXCEEDED 2026
#define ERR_USER_SUSPENDED 2100
#define ERR_INTERNAL_ERROR 2200
{ EPERM, 403, "AccessDenied" },
{ ERR_USER_SUSPENDED, 403, "UserSuspended" },
{ ERR_REQUEST_TIME_SKEWED, 403, "RequestTimeTooSkewed" },
+ { ERR_QUOTA_EXCEEDED, 403, "QuotaExceeded" },
{ ENOENT, 404, "NoSuchKey" },
{ ERR_NO_SUCH_BUCKET, 404, "NoSuchBucket" },
{ ERR_NO_SUCH_UPLOAD, 404, "NoSuchUpload" },
public:
RGWQuotaHandlerImpl(RGWRados *store) : stats_cache(store) {}
virtual int check_quota(rgw_bucket& bucket, RGWQuotaInfo& bucket_quota,
- uint64_t num_objs, uint64_t size, bool *result) {
+ uint64_t num_objs, uint64_t size) {
+ if (!bucket_quota.enabled) {
+ return 0;
+ }
+
+ RGWBucketStats stats;
+
+ int ret = stats_cache.get_bucket_stats(bucket, stats);
+ if (ret < 0)
+ return ret;
+
+ if (bucket_quota.max_objects &&
+ stats.num_objects + num_objs > bucket_quota.max_objects) {
+ return -ERR_QUOTA_EXCEEDED;
+ }
+ if (bucket_quota.max_size_kb &&
+ stats.num_kb_rounded + size > bucket_quota.max_size_kb) {
+ return -ERR_QUOTA_EXCEEDED;
+ }
+
return 0;
}
};
public:
virtual ~RGWQuotaHandler() {}
virtual int check_quota(rgw_bucket& bucket, RGWQuotaInfo& bucket_quota,
- uint64_t num_objs, uint64_t size, bool *result) = 0;
+ uint64_t num_objs, uint64_t size) = 0;
static RGWQuotaHandler *generate_handler(RGWRados *store);
static void free_handler(RGWQuotaHandler *handler);