]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
Zipper - Implement check_quota in RGWBucket
authorDaniel Gryniewicz <dang@redhat.com>
Wed, 1 Jul 2020 17:23:02 +0000 (13:23 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Mon, 17 Aug 2020 16:30:57 +0000 (12:30 -0400)
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
src/rgw/rgw_file.cc
src/rgw/rgw_op.cc
src/rgw/rgw_sal.cc
src/rgw/rgw_sal.h

index 7ebd74dba1ac3e3b64882096ea96382ac8ba78c1..3c36aca55840f7730d05f4a9cb5dc709da3d1f04 100644 (file)
@@ -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;
index bcf7af8bc662eb559b10f02cbb5bb3febd353a9c..bfd3fc5a70a5ac7602694b08891d56adedf768fd 100644 (file)
@@ -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;
index 6c7f53b8ea9a80a4ead89c9eafb37d266d012d4f..0d680309509ec3bc83821f0a797d5aa139ee46db 100644 (file)
@@ -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)
index 98953cc208655e14ff42db0eb04cfb322a01fa7c..a834d2ffa71fd171e10e9b35d821f323ac302749 100644 (file)
@@ -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<RGWBucket> clone() {
       return std::unique_ptr<RGWBucket>(new RGWRadosBucket(*this));
     }