]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add quota enforcement to CopyObj 36020/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 14 May 2020 15:43:39 +0000 (11:43 -0400)
committerNathan Cutler <ncutler@suse.com>
Fri, 10 Jul 2020 19:30:12 +0000 (21:30 +0200)
Fixes: https://tracker.ceph.com/issues/45382
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 70d397541cc8c0a68b3e420a78fec8f0f66f06b0)

src/rgw/rgw_op.cc

index 51e21fe361237b7b529d991606504a9d9deafc28..d42249272904b71074287da4c6ea98dd15d50d50 100644 (file)
@@ -5243,6 +5243,24 @@ void RGWCopyObj::execute()
 
   encode_delete_at_attr(delete_at, attrs);
 
+  if (!s->system_request) { // no quota enforcement for system requests
+    // get src object size (cached in obj_ctx from verify_permission())
+    RGWObjState* astate = nullptr;
+    op_ret = store->getRados()->get_obj_state(s->obj_ctx, src_bucket_info, src_obj,
+                                              &astate, true, s->yield, false);
+    if (op_ret < 0) {
+      return;
+    }
+    // enforce quota against the destination bucket owner
+    op_ret = store->getRados()->check_quota(dest_bucket_info.owner,
+                                            dest_bucket_info.bucket,
+                                            user_quota, bucket_quota,
+                                            astate->accounted_size);
+    if (op_ret < 0) {
+      return;
+    }
+  }
+
   bool high_precision_time = (s->system_request);
 
   /* Handle object versioning of Swift API. In case of copying to remote this