From: Yehuda Sadeh Date: Tue, 22 Sep 2015 03:56:29 +0000 (-0700) Subject: rgw: read and parse put slo obj request X-Git-Tag: v10.0.2~36^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d8593b161f98937be5a15f59ea3c86bb55b72bde;p=ceph.git rgw: read and parse put slo obj request Signed-off-by: Yehuda Sadeh Signed-off-by: Radoslaw Zarzynski Conflicts: src/rgw/rgw_op.h src/rgw/rgw_rest_swift.cc --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 1a7fe61ef8b6..01609d7b39d7 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -1166,6 +1166,8 @@ OPTION(rgw_user_default_quota_max_size, OPT_LONGLONG, -1) // Max size of object OPTION(rgw_multipart_min_part_size, OPT_INT, 5 * 1024 * 1024) // min size for each part (except for last one) in multipart upload OPTION(rgw_multipart_part_upload_limit, OPT_INT, 10000) // parts limit in multipart upload +OPTION(rgw_max_slo_entries, OPT_INT, 1000) // default number of max entries in slo + OPTION(rgw_olh_pending_timeout_sec, OPT_INT, 3600) // time until we retire a pending olh change OPTION(rgw_user_max_buckets, OPT_U32, 1000) // global option to set max buckets count for all user diff --git a/src/rgw/rgw_json_enc.cc b/src/rgw/rgw_json_enc.cc index cd32d31ff3cd..e18bbb658441 100644 --- a/src/rgw/rgw_json_enc.cc +++ b/src/rgw/rgw_json_enc.cc @@ -10,6 +10,7 @@ #include "rgw_bucket.h" #include "rgw_keystone.h" #include "rgw_basic_types.h" +#include "rgw_op.h" #include "common/ceph_json.h" #include "common/Formatter.h" @@ -849,3 +850,10 @@ void KeystoneToken::decode_json(JSONObj *access_obj) JSONDecoder::decode_json("user", user, access_obj, true); JSONDecoder::decode_json("serviceCatalog", service_catalog, access_obj); } + +void rgw_slo_entry::decode_json(JSONObj *obj) +{ + JSONDecoder::decode_json("path", path, obj); + JSONDecoder::decode_json("etag", etag, obj); + JSONDecoder::decode_json("size_bytes", size_bytes, obj); +}; diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index e8cda13d2173..ecb3ef8ff6d9 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -425,6 +425,18 @@ public: virtual uint32_t op_mask() { return RGW_OP_TYPE_DELETE; } }; +struct rgw_slo_entry { + string path; + string etag; + uint64_t size_bytes; + + void decode_json(JSONObj *obj); +}; + +struct RGWSLOInfo { + vector entries; +}; + class RGWPutObj : public RGWOp { friend class RGWPutObjProcessor; @@ -440,6 +452,8 @@ protected: bool chunked_upload; RGWAccessControlPolicy policy; const char *dlo_manifest; + RGWSLOInfo *slo_info; + time_t mtime; uint64_t olh_epoch; @@ -448,18 +462,20 @@ protected: time_t delete_at; public: - RGWPutObj() { - ret = 0; - ofs = 0; - supplied_md5_b64 = NULL; - supplied_etag = NULL; - if_match = NULL; - if_nomatch = NULL; - chunked_upload = false; - dlo_manifest = NULL; - mtime = 0; - olh_epoch = 0; - delete_at = 0; + RGWPutObj() : ret(0), ofs(0), + supplied_md5_b64(NULL), + supplied_etag(NULL), + if_match(NULL), + if_nomatch(NULL), + chunked_upload(0), + dlo_manifest(NULL), + slo_info(NULL), + mtime(0), + olh_epoch(0), + delete_at(0) {} + + ~RGWPutObj() { + delete slo_info; } virtual void init(RGWRados *store, struct req_state *s, RGWHandler *h) { diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index e4fad79a249d..ac9ffc081639 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -558,14 +558,37 @@ int RGWPutObj_ObjStore_SWIFT::get_params() policy.create_default(s->user.user_id, s->user.display_name); - dlo_manifest = s->info.env->get("HTTP_X_OBJECT_MANIFEST"); - int r = get_delete_at_param(s, &delete_at); if (r < 0) { ldout(s->cct, 5) << "ERROR: failed to get Delete-At param" << dendl; return r; } + dlo_manifest = s->info.env->get("HTTP_X_OBJECT_MANIFEST"); + bool exists; + string multipart_manifest = s->info.args.get("multipart-manifest", &exists); + if (exists) { + if (multipart_manifest != "put") { + ldout(s->cct, 5) << "invalid multipart-manifest http param: " << multipart_manifest << dendl; + return -EINVAL; + } + +#define MAX_SLO_ENTRY_SIZE (1024 + 128) // 1024 - max obj name, 128 - enough extra for other info + uint64_t max_len = s->cct->_conf->rgw_max_slo_entries * MAX_SLO_ENTRY_SIZE; + + slo_info = new RGWSLOInfo; + int r = rgw_rest_get_json_input(s->cct, s, slo_info->entries, max_len, NULL); + if (r < 0) { + ldout(s->cct, 5) << "failed to read input for slo r=" << r << dendl; + return r; + } + + if (slo_info->entries.size() > s->cct->_conf->rgw_max_slo_entries) { + ldout(s->cct, 5) << "too many entries in slo request: " << slo_info->entries.size() << dendl; + return -EINVAL; + } + } + return RGWPutObj_ObjStore::get_params(); }