]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add quota enforcement to CopyObj 35073/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 14 May 2020 15:43:39 +0000 (11:43 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 14 May 2020 16:20:56 +0000 (12:20 -0400)
Fixes: https://tracker.ceph.com/issues/45382
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_op.cc

index 49a12e7eab84d3ae33bf967542149e312909d0d8..bc80d1ce0b25c31b6fa3fa9891e62506302d36c0 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