]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: clean up PrimaryLogPG::log_op_stats.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 13 Jul 2018 00:12:38 +0000 (02:12 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 13 Jul 2018 00:31:05 +0000 (02:31 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/osd/OpRequest.cc
src/osd/OpRequest.h
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h

index 51d54c6ad5f4d8a0cab73c086c6c43e9797071c0..3784453da67475371520dfba963c12923b5e2860 100644 (file)
@@ -79,29 +79,29 @@ void OpRequest::_unregistered() {
   request->set_connection(nullptr);
 }
 
-bool OpRequest::check_rmw(int flag) {
+bool OpRequest::check_rmw(int flag) const {
   assert(rmw_flags != 0);
   return rmw_flags & flag;
 }
-bool OpRequest::may_read() {
+bool OpRequest::may_read() const {
   return need_read_cap() || check_rmw(CEPH_OSD_RMW_FLAG_CLASS_READ);
 }
-bool OpRequest::may_write() {
+bool OpRequest::may_write() const {
   return need_write_cap() || check_rmw(CEPH_OSD_RMW_FLAG_CLASS_WRITE);
 }
-bool OpRequest::may_cache() { return check_rmw(CEPH_OSD_RMW_FLAG_CACHE); }
-bool OpRequest::rwordered_forced() {
+bool OpRequest::may_cache() const { return check_rmw(CEPH_OSD_RMW_FLAG_CACHE); }
+bool OpRequest::rwordered_forced() const {
   return check_rmw(CEPH_OSD_RMW_FLAG_RWORDERED);
 }
-bool OpRequest::rwordered() {
+bool OpRequest::rwordered() const {
   return may_write() || may_cache() || rwordered_forced();
 }
 
 bool OpRequest::includes_pg_op() { return check_rmw(CEPH_OSD_RMW_FLAG_PGOP); }
-bool OpRequest::need_read_cap() {
+bool OpRequest::need_read_cap() const {
   return check_rmw(CEPH_OSD_RMW_FLAG_READ);
 }
-bool OpRequest::need_write_cap() {
+bool OpRequest::need_write_cap() const {
   return check_rmw(CEPH_OSD_RMW_FLAG_WRITE);
 }
 bool OpRequest::need_promote() {
index 5281a3ba9816be1151e104f21ed404f2ddee08f0..5bfb730f5d001f69ab36b1c9f123117e02a80cb7 100644 (file)
@@ -27,15 +27,15 @@ struct OpRequest : public TrackedOp {
   // rmw flags
   int rmw_flags;
 
-  bool check_rmw(int flag);
-  bool may_read();
-  bool may_write();
-  bool may_cache();
-  bool rwordered_forced();
-  bool rwordered();
+  bool check_rmw(int flag) const ;
+  bool may_read() const;
+  bool may_write() const;
+  bool may_cache() const;
+  bool rwordered_forced() const;
+  bool rwordered() const;
   bool includes_pg_op();
-  bool need_read_cap();
-  bool need_write_cap();
+  bool need_read_cap() const;
+  bool need_write_cap() const;
   bool need_promote();
   bool need_skip_handle_cache();
   bool need_skip_promote();
index cf672837d3108bb5db5f2797cf874e96200fe3c6..7ffaea0145c39c86584d337cde0438f51f9b0b0e 100644 (file)
@@ -3981,8 +3981,7 @@ void PrimaryLogPG::execute_ctx(OpContext *ctx)
   ctx->register_on_commit(
     [m, ctx, this](){
       if (ctx->op)
-       log_op_stats(
-         ctx);
+       log_op_stats(ctx->op, ctx->bytes_written, ctx->bytes_read);
 
       if (m && !ctx->sent_reply) {
        MOSDOpReply *reply = ctx->reply;
@@ -4048,19 +4047,15 @@ void PrimaryLogPG::reply_ctx(OpContext *ctx, int r, eversion_t v, version_t uv)
   close_op_ctx(ctx);
 }
 
-void PrimaryLogPG::log_op_stats(OpContext *ctx)
+void PrimaryLogPG::log_op_stats(const OpRequestRef op,
+                               const uint64_t inb,
+                               const uint64_t outb)
 {
-  OpRequestRef op = ctx->op;
-  const MOSDOp *m = static_cast<const MOSDOp*>(op->get_req());
-
-  utime_t now = ceph_clock_now();
-  utime_t latency = now;
-  latency -= ctx->op->get_req()->get_recv_stamp();
-  utime_t process_latency = now;
-  process_latency -= ctx->op->get_dequeued_time();
+  const MOSDOp* const m = static_cast<const MOSDOp*>(op->get_req());
+  const utime_t now = ceph_clock_now();
 
-  uint64_t inb = ctx->bytes_written;
-  uint64_t outb = ctx->bytes_read;
+  const utime_t latency = now - m->get_recv_stamp();
+  const utime_t process_latency = now - op->get_dequeued_time();
 
   osd->logger->inc(l_osd_op);
 
@@ -4089,8 +4084,9 @@ void PrimaryLogPG::log_op_stats(OpContext *ctx)
     osd->logger->tinc(l_osd_op_w_lat, latency);
     osd->logger->hinc(l_osd_op_w_lat_inb_hist, latency.to_nsec(), inb);
     osd->logger->tinc(l_osd_op_w_process_lat, process_latency);
-  } else
+  } else {
     ceph_abort();
+  }
 
   dout(15) << "log_op_stats " << *m
           << " inb " << inb
@@ -8485,7 +8481,8 @@ void PrimaryLogPG::complete_read_ctx(int result, OpContext *ctx)
 
   if (result >= 0) {
     if (!ctx->ignore_log_op_stats) {
-      log_op_stats(ctx);
+      log_op_stats(ctx->op, ctx->bytes_written, ctx->bytes_read);
+
       publish_stats_to_osd();
     }
 
index 5d0315972c041eba04cc9ec095aee3a445c39a24..19dc377c8a9378bdaacd599593988d85f86f352f 100644 (file)
@@ -1121,7 +1121,7 @@ protected:
   void reply_ctx(OpContext *ctx, int err);
   void reply_ctx(OpContext *ctx, int err, eversion_t v, version_t uv);
   void make_writeable(OpContext *ctx);
-  void log_op_stats(OpContext *ctx);
+  void log_op_stats(const OpRequestRef op, uint64_t inb, uint64_t outb);
 
   void write_update_size_and_usage(object_stat_sum_t& stats, object_info_t& oi,
                                   interval_set<uint64_t>& modified, uint64_t offset,