From: Radoslaw Zarzynski Date: Mon, 9 May 2016 12:24:36 +0000 (+0200) Subject: rgw: add support for setting container quota of Swift API during PUT. X-Git-Tag: v11.0.0~349^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bc57d7e84aa105a57a97a6bd50338a5558f58e09;p=ceph.git rgw: add support for setting container quota of Swift API during PUT. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index c68199cf5dab..690d8f240b00 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2060,18 +2060,28 @@ void RGWCreateBucket::execute() emplace_attr(RGW_ATTR_CORS, std::move(corsbl)); } + RGWQuotaInfo quota_info; + const RGWQuotaInfo * pquota_info = nullptr; if (need_metadata_upload()) { /* It's supposed that following functions WILL NOT change any special * attributes (like RGW_ATTR_ACL) if they are already present in attrs. */ rgw_get_request_metadata(s->cct, s->info, attrs, false); prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs); populate_with_generic_attrs(s, attrs); + + op_ret = filter_out_bucket_quota(attrs, rmattr_names, quota_info); + if (op_ret < 0) { + return; + } + + pquota_info = "a_info; } s->bucket.tenant = s->bucket_tenant; /* ignored if bucket exists */ s->bucket.name = s->bucket_name; op_ret = store->create_bucket(*(s->user), s->bucket, zonegroup_id, - placement_rule, swift_ver_location, attrs, + placement_rule, swift_ver_location, + pquota_info, attrs, info, pobjv, &ep_objv, creation_time, pmaster_bucket, true); /* continue if EEXIST and create_bucket will fail below. this way we can @@ -2140,7 +2150,12 @@ void RGWCreateBucket::execute() rgw_get_request_metadata(s->cct, s->info, attrs, false); prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs); populate_with_generic_attrs(s, attrs); + op_ret = filter_out_bucket_quota(attrs, rmattr_names, s->bucket_info.quota); + if (op_ret < 0) { + return; + } + /* This will also set the quota on the bucket. */ op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker); } while (op_ret == -ECANCELED && tries++ < 20); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 446d78e66b38..9fc543f32166 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5032,6 +5032,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, const string& zonegroup_id, const string& placement_rule, const string& swift_ver_location, + const RGWQuotaInfo * pquota_info, map& attrs, RGWBucketInfo& info, obj_version *pobjv, @@ -5089,10 +5090,14 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, info.num_shards = bucket_index_max_shards; info.bucket_index_shard_hash_type = RGWBucketInfo::MOD; info.requester_pays = false; - if (real_clock::is_zero(creation_time)) + if (real_clock::is_zero(creation_time)) { creation_time = ceph::real_clock::now(cct); - else + } else { info.creation_time = creation_time; + } + if (pquota_info) { + info.quota = *pquota_info; + } ret = put_linked_bucket_info(info, exclusive, ceph::real_time(), pep_objv, &attrs, true); if (ret == -EEXIST) { /* we need to reread the info and return it, caller will have a use for it */ diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index af290cb44def..00d9d883f31e 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -2051,6 +2051,7 @@ public: const string& zonegroup_id, const string& placement_rule, const string& swift_ver_location, + const RGWQuotaInfo * pquota_info, map& attrs, RGWBucketInfo& bucket_info, obj_version *pobjv,