From: Yehuda Sadeh Date: Wed, 21 Nov 2012 22:15:41 +0000 (-0800) Subject: rgw: fix usage accounting X-Git-Tag: v0.55~62 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=189d073b2554ce32de7d6c759f03e08b25b3512e;p=ceph.git rgw: fix usage accounting bytes_sent and bytes_received are no longer accounted in the req_state, needed to get them out of the ClientIO object. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_client_io.cc b/src/rgw/rgw_client_io.cc index 740418c9ab16..46385f41f332 100644 --- a/src/rgw/rgw_client_io.cc +++ b/src/rgw/rgw_client_io.cc @@ -53,8 +53,7 @@ int RGWClientIO::read(char *buf, int max, int *actual) *actual = ret; - if (account) - bytes_received += *actual; + bytes_received += *actual; return 0; } diff --git a/src/rgw/rgw_client_io.h b/src/rgw/rgw_client_io.h index d4842e97e6e6..546b16d51f70 100644 --- a/src/rgw/rgw_client_io.h +++ b/src/rgw/rgw_client_io.h @@ -3,6 +3,8 @@ #include +#include "include/types.h" + class RGWClientIO { bool account; @@ -27,6 +29,9 @@ public: void set_account(bool _account) { account = _account; } + + uint64_t get_bytes_sent() { return bytes_sent; } + uint64_t get_bytes_received() { return bytes_received; } }; #endif diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index db8013e6120c..35b31be60c07 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -106,8 +106,6 @@ req_state::req_state(CephContext *_cct, struct RGWEnv *e) : cct(_cct), cio(NULL) object = NULL; header_ended = false; - bytes_sent = 0; - bytes_received = 0; obj_size = 0; prot_flags = 0; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index c55907a38d35..f43a2c78a1f3 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -582,8 +582,6 @@ struct req_state { struct rgw_err err; bool expect_cont; bool header_ended; - uint64_t bytes_sent; // bytes sent as a response, excluding header - uint64_t bytes_received; // data received uint64_t obj_size; bool enable_ops_log; bool enable_usage_log; diff --git a/src/rgw/rgw_log.cc b/src/rgw/rgw_log.cc index 5406a2c924b3..ba8a29cdb00f 100644 --- a/src/rgw/rgw_log.cc +++ b/src/rgw/rgw_log.cc @@ -5,6 +5,7 @@ #include "rgw_log.h" #include "rgw_acl.h" #include "rgw_rados.h" +#include "rgw_client_io.h" #define dout_subsys ceph_subsys_rgw @@ -175,7 +176,10 @@ static void log_usage(struct req_state *s, const string& op_name) rgw_usage_log_entry entry(user, s->bucket.name); - rgw_usage_data data(s->bytes_sent, s->bytes_received); + uint64_t bytes_sent = s->cio->get_bytes_sent(); + uint64_t bytes_received = s->cio->get_bytes_received(); + + rgw_usage_data data(bytes_sent, bytes_received); data.ops = 1; if (!s->err.is_err()) @@ -240,10 +244,13 @@ int rgw_log_op(RGWRados *store, struct req_state *s, const string& op_name) entry.object_owner = s->object_acl->get_owner().get_id(); entry.bucket_owner = s->bucket_owner; + uint64_t bytes_sent = s->cio->get_bytes_sent(); + uint64_t bytes_received = s->cio->get_bytes_received(); + entry.time = s->time; entry.total_time = ceph_clock_now(s->cct) - s->time; - entry.bytes_sent = s->bytes_sent; - entry.bytes_received = s->bytes_received; + entry.bytes_sent = bytes_sent; + entry.bytes_received = bytes_received; if (s->err.http_ret) { char buf[16]; snprintf(buf, sizeof(buf), "%d", s->err.http_ret);