]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Revert "jewel: rgw: multipart upload copy" 13160/head
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 27 Jan 2017 20:53:47 +0000 (15:53 -0500)
committerGitHub <noreply@github.com>
Fri, 27 Jan 2017 20:53:47 +0000 (15:53 -0500)
doc/radosgw/s3.rst
src/rgw/rgw_common.h
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_s3.cc

index 15164e3508ee88059fb517de4ddea837008b19fc..67f497ca1491c84e46a4dfaaf7c2d5d8cf312d74 100644 (file)
@@ -70,7 +70,7 @@ The following table describes the support status for current Amazon S3 functiona
 +---------------------------------+-----------------+----------------------------------------+
 | **Copy Object**                 | Supported       |                                        |
 +---------------------------------+-----------------+----------------------------------------+
-| **Multipart Uploads**           | Supported       |                                        |
+| **Multipart Uploads**           | Supported       | (missing Copy Part)                    |
 +---------------------------------+-----------------+----------------------------------------+
 
 Unsupported Header Fields
index 2ea1b6f4efc7cdd38586f6a900004b30c4c655eb..c392bc83818423a08a8f4e9cb6f1d08f9f1f5f88 100644 (file)
@@ -1305,8 +1305,6 @@ struct req_state {
   string req_id;
   string trans_id;
 
-  const char *copy_source;
-
   req_state(CephContext* _cct, RGWEnv* e, RGWUserInfo* u);
   ~req_state();
 };
index 09ca18f796a1d5af6bca0c1adee614c1520d67aa..2da2129dd4ffee0c88adc33bd4ad18b9a3fb41e0 100644 (file)
@@ -1824,7 +1824,7 @@ int RGWCreateBucket::verify_permission()
     if (op_ret < 0)
       return op_ret;
 
-    if (int32_t(buckets.count()) >= s->user->max_buckets) {
+    if (buckets.count() >= s->user->max_buckets) {
       return -ERR_TOO_MANY_BUCKETS;
     }
   }
@@ -2221,30 +2221,8 @@ void RGWDeleteBucket::execute()
 
 int RGWPutObj::verify_permission()
 {
-  if (copy_source) {
-
-    RGWAccessControlPolicy cs_policy(s->cct);
-    map<string, bufferlist> cs_attrs;
-    rgw_bucket cs_bucket(copy_source_bucket_info.bucket);
-    rgw_obj_key cs_object(copy_source_object_name, copy_source_version_id);
-
-    /* check source object permissions */
-    if (read_policy(store, s, copy_source_bucket_info, cs_attrs, &cs_policy, cs_bucket, cs_object) < 0) {
-      return -EACCES;
-    }
-
-    /* system request overrides permission checks */
-    if (!s->system_request &&
-        !cs_policy.verify_permission(s->user->user_id, s->perm_mask,
-                                    RGW_PERM_READ)) {
-      return -EACCES;
-    }
-
-  }
-
-  if (!verify_bucket_permission(s, RGW_PERM_WRITE)) {
+  if (!verify_bucket_permission(s, RGW_PERM_WRITE))
     return -EACCES;
-  }
 
   return 0;
 }
@@ -2420,59 +2398,6 @@ void RGWPutObj::pre_exec()
   rgw_bucket_object_pre_exec(s);
 }
 
-class RGWPutObj_CB : public RGWGetDataCB
-{
-  RGWPutObj *op;
-public:
-  RGWPutObj_CB(RGWPutObj *_op) : op(_op) {}
-  virtual ~RGWPutObj_CB() {}
-
-  int handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len) {
-    return op->get_data_cb(bl, bl_ofs, bl_len);
-  }
-};
-
-int RGWPutObj::get_data_cb(bufferlist& bl, off_t bl_ofs, off_t bl_len)
-{
-  bufferlist bl_tmp;
-  bl.copy(bl_ofs, bl_len, bl_tmp);
-
-  bl_aux.append(bl_tmp);
-
-  return bl_len;
-}
-
-int RGWPutObj::get_data(const off_t fst, const off_t lst, bufferlist& bl)
-{
-  RGWPutObj_CB cb(this);
-  int ret = 0;
-
-  int64_t new_ofs, new_end;
-
-  new_ofs = fst;
-  new_end = lst;
-
-  rgw_obj_key obj_key(copy_source_object_name, copy_source_version_id);
-  rgw_obj obj(copy_source_bucket_info.bucket, obj_key.name);
-  obj.set_instance(obj_key.instance);
-
-  RGWRados::Object op_target(store, copy_source_bucket_info, *static_cast<RGWObjectCtx *>(s->obj_ctx), obj);
-  RGWRados::Object::Read read_op(&op_target);
-
-  ret = read_op.prepare(&new_ofs, &new_end);
-  if (ret < 0)
-    return ret;
-
-  ret = read_op.iterate(new_ofs, new_end, &cb);
-  if (ret < 0) {
-    return ret;
-  }
-
-  bl.claim_append(bl_aux);
-
-  return ret;
-}
-
 void RGWPutObj::execute()
 {
   RGWPutObjProcessor *processor = NULL;
@@ -2484,9 +2409,7 @@ void RGWPutObj::execute()
   bufferlist bl, aclbl;
   int len;
   map<string, string>::iterator iter;
-  bool multipart;  
-  off_t fst;
-  off_t lst;
+  bool multipart;
 
   bool need_calc_md5 = (dlo_manifest == NULL) && (slo_info == NULL);
 
@@ -2566,24 +2489,9 @@ void RGWPutObj::execute()
     goto done;
   }
 
-  fst = copy_source_range_fst;
-  lst = copy_source_range_lst;
-
   do {
     bufferlist data_in;
-    if (fst > lst)
-      break;
-    if (!copy_source) {
-      len = get_data(data_in);
-    } else {
-      uint64_t cur_lst = min(fst + s->cct->_conf->rgw_max_chunk_size - 1, lst);
-      op_ret = get_data(fst, cur_lst, data_in);
-      if (op_ret < 0)
-        goto done;
-      len = data_in.length();
-      s->content_length += len;
-      fst += len;
-    }
+    len = get_data(data_in);
     if (len < 0) {
       op_ret = len;
       goto done;
index 15ea72362ed48b8cfb592deabd70e8969f3a6e9e..624139b2234800a0006f29ca5c671b71c8160eed 100644 (file)
@@ -650,15 +650,6 @@ protected:
   const char *supplied_etag;
   const char *if_match;
   const char *if_nomatch;
-  const char *copy_source;
-  const char *copy_source_range;
-  RGWBucketInfo copy_source_bucket_info;
-  string copy_source_tenant_name;
-  string copy_source_bucket_name;
-  string copy_source_object_name;
-  string copy_source_version_id;
-  off_t copy_source_range_fst;
-  off_t copy_source_range_lst;
   string etag;
   bool chunked_upload;
   RGWAccessControlPolicy policy;
@@ -668,7 +659,6 @@ protected:
   ceph::real_time mtime;
   uint64_t olh_epoch;
   string version_id;
-  bufferlist bl_aux;
 
   ceph::real_time delete_at;
 
@@ -678,10 +668,6 @@ public:
                 supplied_etag(NULL),
                 if_match(NULL),
                 if_nomatch(NULL),
-                copy_source(NULL),
-                copy_source_range(NULL),
-                copy_source_range_fst(0),
-                copy_source_range_lst(0),
                 chunked_upload(0),
                 dlo_manifest(NULL),
                 slo_info(NULL),
@@ -707,9 +693,6 @@ public:
   void pre_exec();
   void execute();
 
-  int get_data_cb(bufferlist& bl, off_t bl_ofs, off_t bl_len);
-  int get_data(const off_t fst, const off_t lst, bufferlist& bl);
-
   virtual int get_params() = 0;
   virtual int get_data(bufferlist& bl) = 0;
   virtual void send_response() = 0;
index 699be5969b5c9acebf0ef77fd1efe2f99a5f84af..00b7fd46cd8c5bd1898e8fa98f4b13be2f545e67 100644 (file)
@@ -1040,92 +1040,18 @@ void RGWDeleteBucket_ObjStore_S3::send_response()
 
 int RGWPutObj_ObjStore_S3::get_params()
 {
-  RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
-  map<string, bufferlist> src_attrs;
-  size_t pos;
-  int ret;
-
   RGWAccessControlPolicy_S3 s3policy(s->cct);
   if (!s->length)
     return -ERR_LENGTH_REQUIRED;
 
-  ret = create_s3_policy(s, store, s3policy, s->owner);
-  if (ret < 0)
-    return ret;
+  int r = create_s3_policy(s, store, s3policy, s->owner);
+  if (r < 0)
+    return r;
 
   policy = s3policy;
 
   if_match = s->info.env->get("HTTP_IF_MATCH");
   if_nomatch = s->info.env->get("HTTP_IF_NONE_MATCH");
-  copy_source = s->info.env->get("HTTP_X_AMZ_COPY_SOURCE");
-  copy_source_range = s->info.env->get("HTTP_X_AMZ_COPY_SOURCE_RANGE");
-
-  /* handle x-amz-copy-source */
-
-  if (copy_source) {
-    copy_source_bucket_name = copy_source;
-    pos = copy_source_bucket_name.find("/");
-    if (pos == std::string::npos) {
-      ret = -EINVAL;
-      ldout(s->cct, 5) << "x-amz-copy-source bad format" << dendl;
-      return ret;
-    }
-    copy_source_object_name = copy_source_bucket_name.substr(pos + 1, copy_source_bucket_name.size());
-    copy_source_bucket_name = copy_source_bucket_name.substr(0, pos);
-#define VERSION_ID_STR "?versionId="
-    pos = copy_source_object_name.find(VERSION_ID_STR);
-    if (pos == std::string::npos) {
-      url_decode(copy_source_object_name, copy_source_object_name);
-    } else {
-      copy_source_version_id = copy_source_object_name.substr(pos + sizeof(VERSION_ID_STR) - 1);
-      url_decode(copy_source_object_name.substr(0, pos), copy_source_object_name);
-    }
-    pos = copy_source_bucket_name.find(":");
-    if (pos == std::string::npos) {
-       copy_source_tenant_name = s->src_tenant_name;
-    } else {
-       copy_source_tenant_name = copy_source_bucket_name.substr(0, pos);
-       copy_source_bucket_name = copy_source_bucket_name.substr(pos + 1, copy_source_bucket_name.size());
-       if (copy_source_bucket_name.empty()) {
-         ret = -EINVAL;
-         ldout(s->cct, 5) << "source bucket name is empty" << dendl;
-         return ret;
-       }
-    }
-    ret = store->get_bucket_info(obj_ctx,
-                                 copy_source_tenant_name,
-                                 copy_source_bucket_name,
-                                 copy_source_bucket_info,
-                                 NULL, &src_attrs);
-    if (ret < 0) {
-      ldout(s->cct, 5) << __func__ << "(): get_bucket_info() returned ret=" << ret << dendl;
-      return ret;
-    }
-
-    /* handle x-amz-copy-source-range */
-
-    if (copy_source_range) {
-      string range = copy_source_range;
-      pos = range.find("=");
-      if (pos == std::string::npos) {
-        ret = -EINVAL;
-        ldout(s->cct, 5) << "x-amz-copy-source-range bad format" << dendl;
-        return ret;
-      }
-      range = range.substr(pos + 1);
-      pos = range.find("-");
-      if (pos == std::string::npos) {
-        ret = -EINVAL;
-        ldout(s->cct, 5) << "x-amz-copy-source-range bad format" << dendl;
-        return ret;
-      }
-      string first = range.substr(0, pos);
-      string last = range.substr(pos + 1);
-      copy_source_range_fst = strtoull(first.c_str(), NULL, 10);
-      copy_source_range_lst = strtoull(last.c_str(), NULL, 10);
-    }
-
-  } /* copy_source */
 
   return RGWPutObj_ObjStore::get_params();
 }
@@ -1311,28 +1237,8 @@ void RGWPutObj_ObjStore_S3::send_response()
        s->cct->_conf->rgw_s3_success_create_obj_status);
       set_req_state_err(s, op_ret);
     }
-    if (!copy_source) {
-      dump_etag(s, etag.c_str());
-      dump_content_length(s, 0);
-    } else {
-      dump_errno(s);
-      end_header(s, this, "application/xml");
-      dump_start(s);
-      struct tm tmp;
-      utime_t ut(mtime);
-      time_t secs = (time_t)ut.sec();
-      gmtime_r(&secs, &tmp);
-      char buf[TIME_BUF_SIZE];
-      s->formatter->open_object_section_in_ns("CopyPartResult",
-          "http://s3.amazonaws.com/doc/2006-03-01/");
-      if (strftime(buf, sizeof(buf), "%Y-%m-%dT%T.000Z", &tmp) > 0) {
-        s->formatter->dump_string("LastModified", buf);
-      }
-      s->formatter->dump_string("ETag", etag);
-      s->formatter->close_section();
-      rgw_flush_formatter_and_reset(s, s->formatter);
-      return;
-    }
+    dump_etag(s, etag.c_str());
+    dump_content_length(s, 0);
   }
   if (s->system_request && !real_clock::is_zero(mtime)) {
     dump_epoch_header(s, "Rgwx-Mtime", mtime);
@@ -2207,6 +2113,10 @@ int RGWCopyObj_ObjStore_S3::init_dest_policy()
 
 int RGWCopyObj_ObjStore_S3::get_params()
 {
+  if (s->info.env->get("HTTP_X_AMZ_COPY_SOURCE_RANGE")) {
+    return -ERR_NOT_IMPLEMENTED;
+  }
+
   if_mod = s->info.env->get("HTTP_X_AMZ_COPY_IF_MODIFIED_SINCE");
   if_unmod = s->info.env->get("HTTP_X_AMZ_COPY_IF_UNMODIFIED_SINCE");
   if_match = s->info.env->get("HTTP_X_AMZ_COPY_IF_MATCH");
@@ -3167,16 +3077,15 @@ int RGWHandler_REST_S3::init(RGWRados *store, struct req_state *s,
 
   s->has_acl_header = s->info.env->exists_prefix("HTTP_X_AMZ_GRANT");
 
-  if (!s->info.env->get("HTTP_X_AMZ_COPY_SOURCE_RANGE") &&
-       s->info.env->get("HTTP_X_AMZ_COPY_SOURCE")) {
-
-      ret = RGWCopyObj::parse_copy_location(s->copy_source,
-                                            s->init_state.src_bucket,
-                                            s->src_object);
-      if (!ret) {
-          ldout(s->cct, 0) << "failed to parse copy location" << dendl;
-          return -EINVAL; // XXX why not -ERR_INVALID_BUCKET_NAME or -ERR_BAD_URL?
-      }
+  const char *copy_source = s->info.env->get("HTTP_X_AMZ_COPY_SOURCE");
+  if (copy_source) {
+    ret = RGWCopyObj::parse_copy_location(copy_source,
+                                         s->init_state.src_bucket,
+                                         s->src_object);
+    if (!ret) {
+      ldout(s->cct, 0) << "failed to parse copy location" << dendl;
+      return -EINVAL; // XXX why not -ERR_INVALID_BUCKET_NAME or -ERR_BAD_URL?
+    }
   }
 
   return RGWHandler_REST::init(store, s, cio);