diff options
author | Daniel Gryniewicz <dang@redhat.com> | 2020-08-25 16:00:27 +0200 |
---|---|---|
committer | Daniel Gryniewicz <dang@redhat.com> | 2020-09-08 17:51:28 +0200 |
commit | e40270a5d177f583bad96f00a4b6413085e1e9ba (patch) | |
tree | 710960bc322ee1122bbc716c272e6297bf8aeedf /src | |
parent | Zipper - Remove more instances of getRados() from rgw_op.cc (diff) | |
download | ceph-e40270a5d177f583bad96f00a4b6413085e1e9ba.tar.xz ceph-e40270a5d177f583bad96f00a4b6413085e1e9ba.zip |
Zipper - implement copy_object
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/rgw/rgw_file.h | 2 | ||||
-rw-r--r-- | src/rgw/rgw_op.cc | 16 | ||||
-rw-r--r-- | src/rgw/rgw_op.h | 6 | ||||
-rw-r--r-- | src/rgw/rgw_rest_s3.cc | 8 | ||||
-rw-r--r-- | src/rgw/rgw_rest_swift.cc | 8 | ||||
-rw-r--r-- | src/rgw/rgw_sal.cc | 60 | ||||
-rw-r--r-- | src/rgw/rgw_sal.h | 36 |
7 files changed, 116 insertions, 20 deletions
diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 75edffe687d..0dcb3e7646b 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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; } diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 224a0de8775..a608aa157fc 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -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, diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 8b3cc812d54..deaa012273b 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -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; diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index e1bd65a07c2..0f93a88d75e 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -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; } diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index f6471f71079..ff1c24d6775 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -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 { diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index 0f323a4a66c..bee7f670c92 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -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); diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index f330199fbb3..5d00eaf8a14 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -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; |