From 80c6d095636ae26a05ccae254d8d9d1f08ec0915 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 14 May 2020 11:43:39 -0400 Subject: [PATCH] rgw: add quota enforcement to CopyObj Fixes: https://tracker.ceph.com/issues/45382 Signed-off-by: Casey Bodley (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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index a0c0e81801e51..117cc76a0e5b9 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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 -- 2.39.5