]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add quota enforcement to CopyObj 36184/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 14 May 2020 15:43:39 +0000 (11:43 -0400)
committerNathan Cutler <ncutler@suse.com>
Sat, 18 Jul 2020 20:57:40 +0000 (22:57 +0200)
Fixes: https://tracker.ceph.com/issues/45382
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 70d397541cc8c0a68b3e420a78fec8f0f66f06b0)

Conflicts:
    src/rgw/rgw_op.cc
- nautilus uses plain "store->" where master has "store->getRados()->"
- nautilus store->get_object_state takes 6 arguments instead of 7 in
  master

src/rgw/rgw_op.cc

index a0c0e81801e5176dd0d2faa4ad2d6f2fafd06ba9..117cc76a0e5b91e9b813f23a317ecd46b1378a14 100644 (file)
@@ -5063,6 +5063,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->get_obj_state(s->obj_ctx, src_bucket_info, src_obj,
+                                  &astate, true, false);
+    if (op_ret < 0) {
+      return;
+    }
+    // enforce quota against the destination bucket owner
+    op_ret = store->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