Skip to content

Commit

Permalink
rgw: add perf counters to fetch_remote_obj()
Browse files Browse the repository at this point in the history
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 5fcb590)
  • Loading branch information
cbodley committed May 2, 2019
1 parent 89bb811 commit d19d2de
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 23 deletions.
14 changes: 13 additions & 1 deletion src/rgw/rgw_cr_rados.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
}
Expand Down
44 changes: 26 additions & 18 deletions src/rgw/rgw_cr_rados.h
Expand Up @@ -861,6 +861,7 @@ class RGWAsyncFetchRemoteObj : public RGWAsyncRadosRequest {

bool copy_if_newer;
rgw_zone_set zones_trace;
PerfCounters* counters;

protected:
int _send_request() override;
Expand All @@ -872,14 +873,16 @@ class RGWAsyncFetchRemoteObj : public RGWAsyncRadosRequest {
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;
Expand All @@ -906,6 +909,7 @@ class RGWFetchRemoteObjCR : public RGWSimpleCoroutine {

RGWAsyncFetchRemoteObj *req;
rgw_zone_set *zones_trace;
PerfCounters* counters;

public:
RGWFetchRemoteObjCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
Expand All @@ -915,15 +919,18 @@ class RGWFetchRemoteObjCR : public RGWSimpleCoroutine {
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 {
Expand All @@ -940,7 +947,8 @@ class RGWFetchRemoteObjCR : public RGWSimpleCoroutine {
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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_data_sync.cc
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/rgw/rgw_rados.cc
Expand Up @@ -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 */

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/rgw/rgw_rados.h
Expand Up @@ -1921,7 +1921,8 @@ class RGWRados : public AdminSocketHook
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
Expand Down

0 comments on commit d19d2de

Please sign in to comment.