]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Zipper - implement copy_object
authorDaniel Gryniewicz <dang@redhat.com>
Tue, 25 Aug 2020 14:00:27 +0000 (10:00 -0400)
committerDaniel Gryniewicz <dang@redhat.com>
Tue, 8 Sep 2020 15:51:28 +0000 (11:51 -0400)
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
src/rgw/rgw_file.h
src/rgw/rgw_op.cc
src/rgw/rgw_op.h
src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_swift.cc
src/rgw/rgw_sal.cc
src/rgw/rgw_sal.h

index 75edffe687d89b74cc3ce7b64bff70ec9a2cdcdb..0dcb3e7646bad1f4fc436e622d7947281c7ddd0b 100644 (file)
@@ -2535,7 +2535,7 @@ public:
     op = this;
 
     /* allow this request to replace selected attrs */
-    attrs_mod = RGWRados::ATTRSMOD_MERGE;
+    attrs_mod = rgw::sal::ATTRSMOD_MERGE;
   }
 
   bool only_bucket() override { return true; }
index 224a0de87753788f07de21ed6aa05ef428c8b33f..a608aa157fc8727b4c08b8f3f69e749ce41442fa 100644 (file)
@@ -5133,11 +5133,11 @@ int RGWCopyObj::init_common()
   dest_policy.encode(aclbl);
   emplace_attr(RGW_ATTR_ACL, std::move(aclbl));
 
-  op_ret = rgw_get_request_metadata(s->cct, s->info, attrs);
+  op_ret = rgw_get_request_metadata(s->cct, s->info, attrs.attrs);
   if (op_ret < 0) {
     return op_ret;
   }
-  populate_with_generic_attrs(s, attrs);
+  populate_with_generic_attrs(s, attrs.attrs);
 
   return 0;
 }
@@ -5189,7 +5189,7 @@ void RGWCopyObj::execute()
   src_object->set_atomic(&obj_ctx);
   dest_object->set_atomic(&obj_ctx);
 
-  encode_delete_at_attr(delete_at, attrs);
+  encode_delete_at_attr(delete_at, attrs.attrs);
 
   if (!s->system_request) { // no quota enforcement for system requests
     // get src object size (cached in obj_ctx from verify_permission())
@@ -5221,12 +5221,11 @@ void RGWCopyObj::execute()
     return;
   }
 
-  op_ret = store->getRados()->copy_obj(obj_ctx,
-          s->user->get_id(),
+  op_ret = src_object->copy_object(obj_ctx,
+          s->user,
           &s->info,
           source_zone,
           dest_object.get(),
-          src_object.get(),
           dest_bucket.get(),
           src_bucket.get(),
           s->dest_placement,
@@ -5239,9 +5238,10 @@ void RGWCopyObj::execute()
           if_nomatch,
           attrs_mod,
           copy_if_newer,
-          attrs, RGWObjCategory::Main,
+          attrs,
+          RGWObjCategory::Main,
           olh_epoch,
-          (delete_at ? *delete_at : real_time()),
+          delete_at,
           (version_id.empty() ? NULL : &version_id),
           &s->req_id, /* use req_id as tag */
           &etag,
index 8b3cc812d54d94a63705fe9b59aa5fced54273f7..deaa012273bc6e6de87b67db7ecc5278c1b73281 100644 (file)
@@ -1427,7 +1427,7 @@ protected:
   ceph::real_time unmod_time;
   ceph::real_time *mod_ptr;
   ceph::real_time *unmod_ptr;
-  map<string, buffer::list> attrs;
+  rgw::sal::RGWAttrs attrs;
   string src_tenant_name, src_bucket_name, src_obj_name;
   std::unique_ptr<rgw::sal::RGWBucket> src_bucket;
   std::unique_ptr<rgw::sal::RGWObject> src_object;
@@ -1436,7 +1436,7 @@ protected:
   std::unique_ptr<rgw::sal::RGWObject> dest_object;
   ceph::real_time src_mtime;
   ceph::real_time mtime;
-  RGWRados::AttrsMod attrs_mod;
+  rgw::sal::AttrsMod attrs_mod;
   string source_zone;
   string etag;
 
@@ -1463,7 +1463,7 @@ public:
     end = -1;
     mod_ptr = NULL;
     unmod_ptr = NULL;
-    attrs_mod = RGWRados::ATTRSMOD_NONE;
+    attrs_mod = rgw::sal::ATTRSMOD_NONE;
     last_ofs = 0;
     olh_epoch = 0;
     copy_if_newer = false;
index e1bd65a07c27c3a8ee77ee8dfa16e1af1e090ab5..0f93a88d75e02d52b848bc8a2379042386133be6 100644 (file)
@@ -3214,11 +3214,11 @@ int RGWCopyObj_ObjStore_S3::get_params()
   auto tmp_md_d = s->info.env->get("HTTP_X_AMZ_METADATA_DIRECTIVE");
   if (tmp_md_d) {
     if (strcasecmp(tmp_md_d, "COPY") == 0) {
-      attrs_mod = RGWRados::ATTRSMOD_NONE;
+      attrs_mod = rgw::sal::ATTRSMOD_NONE;
     } else if (strcasecmp(tmp_md_d, "REPLACE") == 0) {
-      attrs_mod = RGWRados::ATTRSMOD_REPLACE;
+      attrs_mod = rgw::sal::ATTRSMOD_REPLACE;
     } else if (!source_zone.empty()) {
-      attrs_mod = RGWRados::ATTRSMOD_NONE; // default for intra-zone_group copy
+      attrs_mod = rgw::sal::ATTRSMOD_NONE; // default for intra-zone_group copy
     } else {
       s->err.message = "Unknown metadata directive.";
       ldpp_dout(this, 0) << s->err.message << dendl;
@@ -3232,7 +3232,7 @@ int RGWCopyObj_ObjStore_S3::get_params()
       (dest_bucket_name.compare(src_bucket_name) == 0) &&
       (dest_obj_name.compare(src_object->get_name()) == 0) &&
       src_object->get_instance().empty() &&
-      (attrs_mod != RGWRados::ATTRSMOD_REPLACE)) {
+      (attrs_mod != rgw::sal::ATTRSMOD_REPLACE)) {
     need_to_check_storage_class = true;
   }
 
index f6471f710790e64acef6f282b36f6df9cc9b2207..ff1c24d6775875efa5b497170c68a492f0c86007 100644 (file)
@@ -1396,9 +1396,9 @@ int RGWCopyObj_ObjStore_SWIFT::get_params()
 
   const char * const fresh_meta = s->info.env->get("HTTP_X_FRESH_METADATA");
   if (fresh_meta && strcasecmp(fresh_meta, "TRUE") == 0) {
-    attrs_mod = RGWRados::ATTRSMOD_REPLACE;
+    attrs_mod = rgw::sal::ATTRSMOD_REPLACE;
   } else {
-    attrs_mod = RGWRados::ATTRSMOD_MERGE;
+    attrs_mod = rgw::sal::ATTRSMOD_MERGE;
   }
 
   int r = get_delete_at_param(s, delete_at);
@@ -1457,8 +1457,8 @@ void RGWCopyObj_ObjStore_SWIFT::send_response()
     dump_etag(s, etag);
     dump_last_modified(s, mtime);
     dump_copy_info();
-    get_contype_from_attrs(attrs, content_type);
-    dump_object_metadata(this, s, attrs);
+    get_contype_from_attrs(attrs.attrs, content_type);
+    dump_object_metadata(this, s, attrs.attrs);
     end_header(s, this, !content_type.empty() ? content_type.c_str()
               : "binary/octet-stream");
   } else {
index 0f323a4a66cba10e335a142ffb56285f1f1757ec..bee7f670c92721b5e45c796fdc3a11d19aeb94ed 100644 (file)
@@ -612,6 +612,66 @@ int RGWRadosObject::delete_object(RGWObjectCtx* obj_ctx, ACLOwner obj_owner, ACL
 }
 
 
+int RGWRadosObject::copy_object(RGWObjectCtx& obj_ctx,
+                               RGWUser* user,
+                               req_info *info,
+                               const rgw_zone_id& source_zone,
+                               rgw::sal::RGWObject* dest_object,
+                               rgw::sal::RGWBucket* dest_bucket,
+                               rgw::sal::RGWBucket* src_bucket,
+                               const rgw_placement_rule& dest_placement,
+                               ceph::real_time *src_mtime,
+                               ceph::real_time *mtime,
+                               const ceph::real_time *mod_ptr,
+                               const ceph::real_time *unmod_ptr,
+                               bool high_precision_time,
+                               const char *if_match,
+                               const char *if_nomatch,
+                               AttrsMod attrs_mod,
+                               bool copy_if_newer,
+                               RGWAttrs& attrs,
+                               RGWObjCategory category,
+                               uint64_t olh_epoch,
+                               boost::optional<ceph::real_time> delete_at,
+                               string *version_id,
+                               string *tag,
+                               string *etag,
+                               void (*progress_cb)(off_t, void *),
+                               void *progress_data,
+                               const DoutPrefixProvider *dpp,
+                               optional_yield y)
+{
+  return store->getRados()->copy_obj(obj_ctx,
+                                    user->get_id(),
+                                    info,
+                                    source_zone,
+                                    dest_object,
+                                    this,
+                                    dest_bucket,
+                                    src_bucket,
+                                    dest_placement,
+                                    src_mtime,
+                                    mtime,
+                                    mod_ptr,
+                                    unmod_ptr,
+                                    high_precision_time,
+                                    if_match,
+                                    if_nomatch,
+                                    static_cast<RGWRados::AttrsMod>(attrs_mod),
+                                    copy_if_newer,
+                                    attrs.attrs,
+                                    category,
+                                    olh_epoch,
+                                    (delete_at ? *delete_at : real_time()),
+                                    version_id,
+                                    tag,
+                                    etag,
+                                    progress_cb,
+                                    progress_data,
+                                    dpp,
+                                    y);
+}
+
 int RGWRadosObject::RadosReadOp::iterate(int64_t ofs, int64_t end, RGWGetDataCB *cb, optional_yield y)
 {
   return parent_op.iterate(ofs, end, cb, y);
index f330199fbb30e5048ddf2d7ddee35b88f18e51c5..5d00eaf8a1430e27544658727e35ff227c604eb7 100644 (file)
@@ -27,6 +27,12 @@ class RGWBucket;
 class RGWObject;
 class RGWBucketList;
 
+enum AttrsMod {
+  ATTRSMOD_NONE    = 0,
+  ATTRSMOD_REPLACE = 1,
+  ATTRSMOD_MERGE   = 2
+};
+
 struct RGWAttrs {
   std::map<std::string, ceph::buffer::list> attrs;
 
@@ -354,6 +360,21 @@ class RGWObject {
                              ACLOwner bucket_owner, ceph::real_time unmod_since,
                              bool high_precision_time, uint64_t epoch,
                              std::string& version_id,optional_yield y) = 0;
+    virtual int copy_object(RGWObjectCtx& obj_ctx, RGWUser* user,
+               req_info *info, const rgw_zone_id& source_zone,
+               rgw::sal::RGWObject* dest_object, rgw::sal::RGWBucket* dest_bucket,
+               rgw::sal::RGWBucket* src_bucket,
+               const rgw_placement_rule& dest_placement,
+               ceph::real_time *src_mtime, ceph::real_time *mtime,
+               const ceph::real_time *mod_ptr, const ceph::real_time *unmod_ptr,
+               bool high_precision_time,
+               const char *if_match, const char *if_nomatch,
+               AttrsMod attrs_mod, bool copy_if_newer, RGWAttrs& attrs,
+               RGWObjCategory category, uint64_t olh_epoch,
+              boost::optional<ceph::real_time> delete_at,
+               string *version_id, string *tag, string *etag,
+               void (*progress_cb)(off_t, void *), void *progress_data,
+               const DoutPrefixProvider *dpp, optional_yield y) = 0;
     virtual RGWAccessControlPolicy& get_acl(void) = 0;
     virtual int set_acl(const RGWAccessControlPolicy& acl) = 0;
     virtual void set_atomic(RGWObjectCtx *rctx) const = 0;
@@ -488,6 +509,21 @@ class RGWRadosObject : public RGWObject {
                              ACLOwner bucket_owner, ceph::real_time unmod_since,
                              bool high_precision_time, uint64_t epoch,
                              std::string& version_id,optional_yield y) override;
+    virtual int copy_object(RGWObjectCtx& obj_ctx, RGWUser* user,
+               req_info *info, const rgw_zone_id& source_zone,
+               rgw::sal::RGWObject* dest_object, rgw::sal::RGWBucket* dest_bucket,
+               rgw::sal::RGWBucket* src_bucket,
+               const rgw_placement_rule& dest_placement,
+               ceph::real_time *src_mtime, ceph::real_time *mtime,
+               const ceph::real_time *mod_ptr, const ceph::real_time *unmod_ptr,
+               bool high_precision_time,
+               const char *if_match, const char *if_nomatch,
+               AttrsMod attrs_mod, bool copy_if_newer, RGWAttrs& attrs,
+               RGWObjCategory category, uint64_t olh_epoch,
+              boost::optional<ceph::real_time> delete_at,
+               string *version_id, string *tag, string *etag,
+               void (*progress_cb)(off_t, void *), void *progress_data,
+               const DoutPrefixProvider *dpp, optional_yield y) override;
     RGWAccessControlPolicy& get_acl(void) { return acls; }
     int set_acl(const RGWAccessControlPolicy& acl) { acls = acl; return 0; }
     virtual void set_atomic(RGWObjectCtx *rctx) const;