From 4ba4bc9b8e96077a02af64d90ed20b3f922d81fa Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 22 Mar 2018 17:49:40 -0700 Subject: [PATCH] rgw: cloud sync: store source object info in destination object store extra meta params on target object (original name, version_id, etag, etc.) Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_cr_rest.h | 9 ++++++--- src/rgw/rgw_sync_module_aws.cc | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_cr_rest.h b/src/rgw/rgw_cr_rest.h index 63d1f124ef2ad..546f1b7eeebb9 100644 --- a/src/rgw/rgw_cr_rest.h +++ b/src/rgw/rgw_cr_rest.h @@ -390,15 +390,18 @@ public: RGWStreamReadHTTPResourceCRF(CephContext *_cct, RGWCoroutinesEnv *_env, RGWCoroutine *_caller, - RGWHTTPManager *_http_manager) : cct(_cct), + RGWHTTPManager *_http_manager, + const rgw_obj_key& _src_key) : cct(_cct), env(_env), caller(_caller), - http_manager(_http_manager) {} + http_manager(_http_manager) { + rest_obj.key = _src_key; + } ~RGWStreamReadHTTPResourceCRF() override; int init() override; int read(bufferlist *data, uint64_t max, bool *need_retry) override; /* reentrant */ - int decode_rest_obj(map& headers, bufferlist& extra_data, rgw_rest_obj *info); + int decode_rest_obj(map& headers, bufferlist& extra_data, rgw_rest_obj *info) override; bool has_attrs() override; void get_attrs(std::map *attrs); bool is_done(); diff --git a/src/rgw/rgw_sync_module_aws.cc b/src/rgw/rgw_sync_module_aws.cc index 2f2c380533e1f..dc680eb064319 100644 --- a/src/rgw/rgw_sync_module_aws.cc +++ b/src/rgw/rgw_sync_module_aws.cc @@ -691,7 +691,8 @@ public: RGWDataSyncEnv *_sync_env, RGWRESTConn *_conn, rgw_obj& _src_obj, - const rgw_sync_aws_src_obj_properties& _src_properties) : RGWStreamReadHTTPResourceCRF(_cct, _env, _caller, _sync_env->http_manager), + const rgw_sync_aws_src_obj_properties& _src_properties) : RGWStreamReadHTTPResourceCRF(_cct, _env, _caller, + _sync_env->http_manager, _src_obj.key), sync_env(_sync_env), conn(_conn), src_obj(_src_obj), src_properties(_src_properties) { } @@ -911,6 +912,18 @@ public: snprintf(buf, sizeof(buf), "%llu", (long long)src_properties.versioned_epoch); new_attrs["x-amz-meta-rgwx-versioned-epoch"] = buf; + utime_t ut(src_properties.mtime); + snprintf(buf, sizeof(buf), "%lld.%09lld", + (long long)ut.sec(), + (long long)ut.nsec()); + + new_attrs["x-amz-meta-rgwx-source-mtime"] = buf; + new_attrs["x-amz-meta-rgwx-source-etag"] = src_properties.etag; + new_attrs["x-amz-meta-rgwx-source-key"] = rest_obj.key.name; + if (!rest_obj.key.instance.empty()) { + new_attrs["x-amz-meta-rgwx-source-version-id"] = rest_obj.key.instance; + } + r->set_send_length(rest_obj.content_len); RGWAccessControlPolicy policy; -- 2.39.5