]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: read and parse put slo obj request
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 22 Sep 2015 03:56:29 +0000 (20:56 -0700)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 8 Dec 2015 16:58:07 +0000 (17:58 +0100)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
Conflicts:
src/rgw/rgw_op.h
src/rgw/rgw_rest_swift.cc

src/common/config_opts.h
src/rgw/rgw_json_enc.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_swift.cc

index 1a7fe61ef8b697405ca403a67c09f80b3de742ea..01609d7b39d7782285955a40c3eb961b99a09764 100644 (file)
@@ -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
 
index cd32d31ff3cd6f642248ceaac27e96af4fff4dbe..e18bbb65844150c74fc9b52a0525011ddd541c1f 100644 (file)
@@ -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);
+};
index e8cda13d2173f61e8942a808686358c24364afb3..ecb3ef8ff6d9b5de0e96f1b8148dd39d7e0c3732 100644 (file)
@@ -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<rgw_slo_entry> 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) {
index e4fad79a249de586c3294c9c458aaec920855097..ac9ffc0816398128dec780b304d5203c5a0ebd22 100644 (file)
@@ -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();
 }