From 2c0f1a3117ab862991c1ed04280908afccb5b656 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 4 Aug 2016 13:00:53 -0700 Subject: [PATCH] rgw: log sync module gets source object's meta Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_sync_module.cc | 45 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_sync_module.cc b/src/rgw/rgw_sync_module.cc index dff66ad0c85ea..16c11450c9103 100644 --- a/src/rgw/rgw_sync_module.cc +++ b/src/rgw/rgw_sync_module.cc @@ -1,11 +1,52 @@ #include "rgw_common.h" #include "rgw_coroutine.h" +#include "rgw_cr_rados.h" #include "rgw_sync_module.h" -// #include "rgw_sync.h" #include "rgw_data_sync.h" +#include "rgw_boost_asio_yield.h" #define dout_subsys ceph_subsys_rgw +class RGWLogStatRemoteObjCR : public RGWCoroutine { + RGWDataSyncEnv *sync_env; + + RGWBucketInfo bucket_info; + rgw_obj_key key; + + ceph::real_time mtime; + uint64_t size; + map attrs; + + +public: + RGWLogStatRemoteObjCR(RGWDataSyncEnv *_sync_env, + RGWBucketInfo& _bucket_info, rgw_obj_key& _key) : RGWCoroutine(_sync_env->cct), + sync_env(_sync_env), + bucket_info(_bucket_info), key(_key) { + } + + ~RGWLogStatRemoteObjCR() {} + + int operate() { + reenter(this) { + yield { + call(new RGWStatRemoteObjCR(sync_env->async_rados, sync_env->store, + sync_env->source_zone, + bucket_info, key, &mtime, &size, &attrs)); + } + if (retcode < 0) { + ldout(sync_env->cct, 0) << "RGWStatRemoteObjCR() returned " << retcode << dendl; + return set_cr_error(retcode); + } + ldout(sync_env->cct, 0) << "stat of remote obj: z=" << sync_env->source_zone + << " b=" << bucket_info.bucket << " k=" << key << " size=" << size << " mtime=" << mtime + << " attrs=" << attrs << dendl; + return set_cr_done(); + } + return 0; + } +}; + class RGWLogDataSyncModule : public RGWDataSyncModule { string prefix; public: @@ -13,7 +54,7 @@ public: RGWCoroutine *sync_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, uint64_t versioned_epoch) override { ldout(sync_env->cct, 0) << prefix << ": SYNC_LOG: sync_object: b=" << bucket_info.bucket << " k=" << key << " versioned_epoch=" << versioned_epoch << dendl; - return NULL; + return new RGWLogStatRemoteObjCR(sync_env, bucket_info, key); } RGWCoroutine *remove_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key, real_time& mtime, bool versioned, uint64_t versioned_epoch) override { ldout(sync_env->cct, 0) << prefix << ": SYNC_LOG: rm_object: b=" << bucket_info.bucket << " k=" << key << " mtime=" << mtime << " versioned=" << versioned << " versioned_epoch=" << versioned_epoch << dendl; -- 2.39.5