diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index a5c50643f1f..4b60a0efaaa 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -661,6 +661,10 @@ namespace rgw { } get<1>(mkr) = rc; + + /* case like : quota exceed will be considered as fail too*/ + if(rc2 < 0) + get<1>(mkr) = rc2; return mkr; } /* RGWLibFS::create */ @@ -1368,6 +1372,12 @@ namespace rgw { return -EIO; } + op_ret = get_store()->check_quota(s->bucket_owner.get_id(), s->bucket, + user_quota, bucket_quota, real_ofs, true); + /* max_size exceed */ + if (op_ret < 0) + return -EIO; + size_t len = data.length(); if (! len) return 0; @@ -1406,7 +1416,8 @@ namespace rgw { } op_ret = get_store()->check_quota(s->bucket_owner.get_id(), s->bucket, - user_quota, bucket_quota, s->obj_size); + user_quota, bucket_quota, s->obj_size, true); + /* max_size exceed */ if (op_ret < 0) { goto done; } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d352f9d15ed..25a28730274 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -9750,8 +9750,12 @@ int RGWRados::add_bucket_to_reshard(const RGWBucketInfo& bucket_info, uint32_t n } int RGWRados::check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, - RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size) + RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only) { + // if we only check size, then num_objs will set to 0 + if(check_size_only) + return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 0, obj_size); + return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 1, obj_size); } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index a58f50bed25..786c6a336b0 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -2320,7 +2320,7 @@ public: int cls_user_get_bucket_stats(const rgw_bucket& bucket, cls_user_bucket_entry& entry); int check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, - RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size); + RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only = false); int check_bucket_shards(const RGWBucketInfo& bucket_info, const rgw_bucket& bucket, RGWQuotaInfo& bucket_quota);