]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: cloud sync: store source object info in destination object
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 23 Mar 2018 00:49:40 +0000 (17:49 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 12 Apr 2018 22:38:39 +0000 (15:38 -0700)
store extra meta params on target object (original name, version_id, etag,
etc.)

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_cr_rest.h
src/rgw/rgw_sync_module_aws.cc

index 63d1f124ef2ad157317116924fa93a71f555b890..546f1b7eeebb980b292a70cdf47b99e5e4aefe90 100644 (file)
@@ -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<string, string>& headers, bufferlist& extra_data, rgw_rest_obj *info);
+  int decode_rest_obj(map<string, string>& headers, bufferlist& extra_data, rgw_rest_obj *info) override;
   bool has_attrs() override;
   void get_attrs(std::map<string, string> *attrs);
   bool is_done();
index 2f2c380533e1fca462a856ca635f716d7eae37a7..dc680eb064319c416374e94989893d940dc3687a 100644 (file)
@@ -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;