]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add perf counters to fetch_remote_obj()
authorCasey Bodley <cbodley@redhat.com>
Thu, 28 Feb 2019 22:02:17 +0000 (17:02 -0500)
committerCasey Bodley <cbodley@redhat.com>
Thu, 2 May 2019 12:45:08 +0000 (08:45 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 5fcb59060bb03c532e0cf03b32352b046c3f9543)

src/rgw/rgw_cr_rados.cc
src/rgw/rgw_cr_rados.h
src/rgw/rgw_data_sync.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 09e4890b5a70696df63bcced4d43382ce89f57fe..7284c10dc4e4fe49d8bd17e27756618580fc55e2 100644 (file)
@@ -6,6 +6,7 @@
 #include "rgw_zone.h"
 #include "rgw_coroutine.h"
 #include "rgw_cr_rados.h"
+#include "rgw_sync_counters.h"
 
 #include "services/svc_zone.h"
 #include "services/svc_zone_utils.h"
@@ -585,6 +586,7 @@ int RGWAsyncFetchRemoteObj::_send_request()
 
   rgw_obj dest_obj(bucket_info.bucket, dest_key.value_or(key));
 
+  std::optional<uint64_t> bytes_transferred;
   int r = store->fetch_remote_obj(obj_ctx,
                        user_id,
                        NULL, /* req_info */
@@ -611,10 +613,20 @@ int RGWAsyncFetchRemoteObj::_send_request()
                        NULL, /* string *petag, */
                        NULL, /* void (*progress_cb)(off_t, void *), */
                        NULL, /* void *progress_data*); */
-                       &zones_trace);
+                       &zones_trace,
+                       &bytes_transferred);
 
   if (r < 0) {
     ldout(store->ctx(), 0) << "store->fetch_remote_obj() returned r=" << r << dendl;
+    if (counters) {
+      counters->inc(sync_counters::l_fetch_err, 1);
+    }
+  } else if (counters) {
+    if (bytes_transferred) {
+      counters->inc(sync_counters::l_fetch, *bytes_transferred);
+    } else {
+      counters->inc(sync_counters::l_fetch_not_modified);
+    }
   }
   return r;
 }
index 4480c5e8e05d6249151f4035458f14ad6e4f9243..e919217cbaac02b9a4248ea86fa2f378868cb289 100644 (file)
@@ -861,6 +861,7 @@ class RGWAsyncFetchRemoteObj : public RGWAsyncRadosRequest {
 
   bool copy_if_newer;
   rgw_zone_set zones_trace;
+  PerfCounters* counters;
 
 protected:
   int _send_request() override;
@@ -872,14 +873,16 @@ public:
                          const rgw_obj_key& _key,
                          const std::optional<rgw_obj_key>& _dest_key,
                          std::optional<uint64_t> _versioned_epoch,
-                         bool _if_newer, rgw_zone_set *_zones_trace) : RGWAsyncRadosRequest(caller, cn), store(_store),
-                                                      source_zone(_source_zone),
-                                                      bucket_info(_bucket_info),
-                                                     dest_placement_rule(_dest_placement_rule),
-                                                      key(_key),
-                                                      dest_key(_dest_key),
-                                                      versioned_epoch(_versioned_epoch),
-                                                      copy_if_newer(_if_newer)
+                         bool _if_newer, rgw_zone_set *_zones_trace,
+                         PerfCounters* counters)
+    : RGWAsyncRadosRequest(caller, cn), store(_store),
+      source_zone(_source_zone),
+      bucket_info(_bucket_info),
+      dest_placement_rule(_dest_placement_rule),
+      key(_key),
+      dest_key(_dest_key),
+      versioned_epoch(_versioned_epoch),
+      copy_if_newer(_if_newer), counters(counters)
   {
     if (_zones_trace) {
       zones_trace = *_zones_trace;
@@ -906,6 +909,7 @@ class RGWFetchRemoteObjCR : public RGWSimpleCoroutine {
 
   RGWAsyncFetchRemoteObj *req;
   rgw_zone_set *zones_trace;
+  PerfCounters* counters;
 
 public:
   RGWFetchRemoteObjCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
@@ -915,15 +919,18 @@ public:
                       const rgw_obj_key& _key,
                       const std::optional<rgw_obj_key>& _dest_key,
                       std::optional<uint64_t> _versioned_epoch,
-                      bool _if_newer, rgw_zone_set *_zones_trace) : RGWSimpleCoroutine(_store->ctx()), cct(_store->ctx()),
-                                       async_rados(_async_rados), store(_store),
-                                       source_zone(_source_zone),
-                                       bucket_info(_bucket_info),
-                                      dest_placement_rule(_dest_placement_rule),
-                                       key(_key),
-                                       dest_key(_dest_key),
-                                       versioned_epoch(_versioned_epoch),
-                                       copy_if_newer(_if_newer), req(NULL), zones_trace(_zones_trace) {}
+                      bool _if_newer, rgw_zone_set *_zones_trace,
+                      PerfCounters* counters)
+    : RGWSimpleCoroutine(_store->ctx()), cct(_store->ctx()),
+      async_rados(_async_rados), store(_store),
+      source_zone(_source_zone),
+      bucket_info(_bucket_info),
+      dest_placement_rule(_dest_placement_rule),
+      key(_key),
+      dest_key(_dest_key),
+      versioned_epoch(_versioned_epoch),
+      copy_if_newer(_if_newer), req(NULL),
+      zones_trace(_zones_trace), counters(counters) {}
 
 
   ~RGWFetchRemoteObjCR() override {
@@ -940,7 +947,8 @@ public:
   int send_request() override {
     req = new RGWAsyncFetchRemoteObj(this, stack->create_completion_notifier(), store,
                                     source_zone, bucket_info, dest_placement_rule,
-                                     key, dest_key, versioned_epoch, copy_if_newer, zones_trace);
+                                     key, dest_key, versioned_epoch, copy_if_newer,
+                                     zones_trace, counters);
     async_rados->queue(req);
     return 0;
   }
index f4d361bed4179b9cc219321002ec9f76d69aa054..1ec599038b953b35b42a1d70530e34e00d07f96c 100644 (file)
@@ -1679,7 +1679,7 @@ RGWCoroutine *RGWDefaultDataSyncModule::sync_object(RGWDataSyncEnv *sync_env, RG
   return new RGWFetchRemoteObjCR(sync_env->async_rados, sync_env->store, sync_env->source_zone, bucket_info,
                                 std::nullopt,
                                  key, std::nullopt, versioned_epoch,
-                                 true, zones_trace);
+                                 true, zones_trace, sync_env->counters);
 }
 
 RGWCoroutine *RGWDefaultDataSyncModule::remove_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key,
@@ -1756,7 +1756,7 @@ RGWCoroutine *RGWArchiveDataSyncModule::sync_object(RGWDataSyncEnv *sync_env, RG
   return new RGWFetchRemoteObjCR(sync_env->async_rados, sync_env->store, sync_env->source_zone,
                                  bucket_info, std::nullopt,
                                  key, dest_key, versioned_epoch,
-                                 true, zones_trace);
+                                 true, zones_trace, nullptr);
 }
 
 RGWCoroutine *RGWArchiveDataSyncModule::remove_object(RGWDataSyncEnv *sync_env, RGWBucketInfo& bucket_info, rgw_obj_key& key,
index 5b84614e79b4e84bea1d04409854c26cdee128f2..866f1826d8c07c38899c5bd7a1d7b458fc34f698 100644 (file)
@@ -4299,7 +4299,8 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
                string *petag,
                void (*progress_cb)(off_t, void *),
                void *progress_data,
-               rgw_zone_set *zones_trace)
+               rgw_zone_set *zones_trace,
+               std::optional<uint64_t>* bytes_transferred)
 {
   /* source is in a different zonegroup, copy from there */
 
@@ -4513,6 +4514,9 @@ int RGWRados::fetch_remote_obj(RGWObjectCtx& obj_ctx,
     goto set_err_state;
   }
 
+  if (bytes_transferred) {
+    *bytes_transferred = cb.get_data_len();
+  }
   return 0;
 set_err_state:
   if (copy_if_newer && ret == -ERR_NOT_MODIFIED) {
index ddb60788310277f1bf7c42ef90f9c37e44d69737..b3d3f52d012a38f1b9143f0956c96e931f6abc84 100644 (file)
@@ -1921,7 +1921,8 @@ public:
                        string *petag,
                        void (*progress_cb)(off_t, void *),
                        void *progress_data,
-                       rgw_zone_set *zones_trace= nullptr);
+                       rgw_zone_set *zones_trace= nullptr,
+                       std::optional<uint64_t>* bytes_transferred = 0);
   /**
    * Copy an object.
    * dest_obj: the object to copy into