]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix usage accounting
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 21 Nov 2012 22:15:41 +0000 (14:15 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 21 Nov 2012 22:19:36 +0000 (14:19 -0800)
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>
src/rgw/rgw_client_io.cc
src/rgw/rgw_client_io.h
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_log.cc

index 740418c9ab165c2bd1601d4008b65edbf84722b1..46385f41f3328ec2300e780b228a6f4cbdca5d67 100644 (file)
@@ -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;
 }
index d4842e97e6e6f82462b19ca1a0af6be6af164fd6..546b16d51f70235114132ce429f775c2e00827fe 100644 (file)
@@ -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
index db8013e6120c069aa71e827ac9f3acead0b4e90e..35b31be60c07faa441da03fb2c60a81857f1956e 100644 (file)
@@ -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;
 
index c55907a38d35a24409703a9794e64e430cb3609d..f43a2c78a1f3f5d6ec70da5e4faa4da6ea607432 100644 (file)
@@ -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;
index 5406a2c924b39bd7c25fe731d5b3577e2b91121b..ba8a29cdb00fcbcbe1ecbad6a97d153519da97b7 100644 (file)
@@ -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);