From fd2f599aa6718f0067b1ab2078acd1b47ad85ba6 Mon Sep 17 00:00:00 2001 From: Daniel Gryniewicz Date: Wed, 1 Jul 2020 13:23:02 -0400 Subject: [PATCH] Zipper - Implement check_quota in RGWBucket Signed-off-by: Daniel Gryniewicz --- src/rgw/rgw_file.cc | 8 ++------ src/rgw/rgw_op.cc | 21 ++++++--------------- src/rgw/rgw_sal.cc | 4 ++-- src/rgw/rgw_sal.h | 4 ++-- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 7ebd74dba1a..3c36aca5584 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -1609,9 +1609,7 @@ namespace rgw { return -EIO; } - op_ret = get_store()->getRados()->check_quota(s->bucket_owner.get_id(), - s->bucket->get_bi(), user_quota, bucket_quota, - real_ofs, true); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, real_ofs, true); /* max_size exceed */ if (op_ret < 0) return -EIO; @@ -1653,9 +1651,7 @@ namespace rgw { goto done; } - op_ret = get_store()->getRados()->check_quota(s->bucket_owner.get_id(), - s->bucket->get_bi(), user_quota, bucket_quota, - s->obj_size, true); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->obj_size, true); /* max_size exceed */ if (op_ret < 0) { goto done; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index bcf7af8bc66..bfd3fc5a70a 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3769,8 +3769,7 @@ void RGWPutObj::execute() if (!chunked_upload) { /* with chunked upload we don't know how big is the upload. we also check sizes at the end anyway */ - op_ret = store->getRados()->check_quota(s->bucket_owner.get_id(), s->bucket->get_bi(), - user_quota, bucket_quota, s->content_length); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->content_length); if (op_ret < 0) { ldpp_dout(this, 20) << "check_quota() returned ret=" << op_ret << dendl; return; @@ -3972,8 +3971,7 @@ void RGWPutObj::execute() return; } - op_ret = store->getRados()->check_quota(s->bucket_owner.get_id(), s->bucket->get_bi(), - user_quota, bucket_quota, s->obj_size); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->obj_size); if (op_ret < 0) { ldpp_dout(this, 20) << "second check_quota() returned op_ret=" << op_ret << dendl; return; @@ -4151,11 +4149,7 @@ void RGWPostObj::execute() ceph::buffer::list bl, aclbl; int len = 0; - op_ret = store->getRados()->check_quota(s->bucket_owner.get_id(), - s->bucket->get_bi(), - user_quota, - bucket_quota, - s->content_length); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->content_length); if (op_ret < 0) { return; } @@ -4260,8 +4254,7 @@ void RGWPostObj::execute() s->object->set_obj_size(ofs); - op_ret = store->getRados()->check_quota(s->bucket_owner.get_id(), s->bucket->get_bi(), - user_quota, bucket_quota, s->obj_size); + op_ret = s->bucket->check_quota(user_quota, bucket_quota, s->obj_size); if (op_ret < 0) { return; } @@ -7102,8 +7095,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path, return op_ret; } - op_ret = store->getRados()->check_quota(s->user->get_id(), bucket->get_bi(), - user_quota, bucket_quota, size); + op_ret = bucket->check_quota(user_quota, bucket_quota, size); if (op_ret < 0) { return op_ret; } @@ -7183,8 +7175,7 @@ int RGWBulkUploadOp::handle_file(const std::string_view path, return op_ret; } - op_ret = store->getRados()->check_quota(bowner.get_id(), bucket->get_bi(), - user_quota, bucket_quota, size); + op_ret = bucket->check_quota(user_quota, bucket_quota, size); if (op_ret < 0) { ldpp_dout(this, 20) << "quota exceeded for path=" << path << dendl; return op_ret; diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index 6c7f53b8ea9..0d680309509 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -276,10 +276,10 @@ int RGWRadosBucket::check_empty(optional_yield y) return store->getRados()->check_bucket_empty(info, y); } -int RGWRadosBucket::check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size) +int RGWRadosBucket::check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only) { return store->getRados()->check_quota(owner->get_user(), get_bi(), - user_quota, bucket_quota, obj_size); + user_quota, bucket_quota, obj_size, check_size_only); } int RGWRadosBucket::set_acl(RGWAccessControlPolicy &acl, optional_yield y) diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 98953cc2086..a834d2ffa71 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -172,7 +172,7 @@ class RGWBucket { virtual int put_instance_info(bool exclusive, ceph::real_time mtime) = 0; virtual bool is_owner(RGWUser* user) = 0; virtual int check_empty(optional_yield y) = 0; - virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size) = 0; + virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only = false) = 0; bool empty() const { return info.bucket.name.empty(); } const std::string& get_name() const { return info.bucket.name; } @@ -482,7 +482,7 @@ class RGWRadosBucket : public RGWBucket { virtual int put_instance_info(bool exclusive, ceph::real_time mtime) override; virtual bool is_owner(RGWUser* user) override; virtual int check_empty(optional_yield y) override; - virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size) override; + virtual int check_quota(RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size, bool check_size_only = false) override; virtual std::unique_ptr clone() { return std::unique_ptr(new RGWRadosBucket(*this)); } -- 2.39.5