From: Casey Bodley Date: Thu, 28 Feb 2019 22:02:17 +0000 (-0500) Subject: rgw: add perf counters to fetch_remote_obj() X-Git-Tag: v14.2.2~129^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d19d2de345ab6ee1ffae93fa859263b1ed7fd1b2;p=ceph.git rgw: add perf counters to fetch_remote_obj() Signed-off-by: Casey Bodley (cherry picked from commit 5fcb59060bb03c532e0cf03b32352b046c3f9543) --- diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 09e4890b5a7..7284c10dc4e 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -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 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; } diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index 4480c5e8e05..e919217cbaa 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -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& _dest_key, std::optional _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& _dest_key, std::optional _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; } diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index f4d361bed41..1ec599038b9 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -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, diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 5b84614e79b..866f1826d8c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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* 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) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index ddb60788310..b3d3f52d012 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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* bytes_transferred = 0); /** * Copy an object. * dest_obj: the object to copy into