summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2012-11-21 14:15:41 -0800
committerYehuda Sadeh <yehuda@inktank.com>2012-11-21 14:19:36 -0800
commit189d073b2554ce32de7d6c759f03e08b25b3512e (patch)
tree407d3499452e242c0745fb6f3ea6cf002987e6f7
parent5126bd70850812d69fcc251b88d7d6b88033ad6c (diff)
downloadceph-189d073b2554ce32de7d6c759f03e08b25b3512e.tar.gz
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 <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_client_io.cc3
-rw-r--r--src/rgw/rgw_client_io.h5
-rw-r--r--src/rgw/rgw_common.cc2
-rw-r--r--src/rgw/rgw_common.h2
-rw-r--r--src/rgw/rgw_log.cc13
5 files changed, 16 insertions, 9 deletions
diff --git a/src/rgw/rgw_client_io.cc b/src/rgw/rgw_client_io.cc
index 740418c9ab1..46385f41f33 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 d4842e97e6e..546b16d51f7 100644
--- a/src/rgw/rgw_client_io.h
+++ b/src/rgw/rgw_client_io.h
@@ -3,6 +3,8 @@
#include <stdlib.h>
+#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 db8013e6120..35b31be60c0 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 c55907a38d3..f43a2c78a1f 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 5406a2c924b..ba8a29cdb00 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);