diff --git a/osd_cluster.cpp b/osd_cluster.cpp index 0ea16905..f3aca1a1 100644 --- a/osd_cluster.cpp +++ b/osd_cluster.cpp @@ -155,7 +155,6 @@ json11::Json osd_t::get_statistics() st["free"] = bs->get_free_block_count() * bs->get_block_size(); } st["host"] = self_state["host"]; - // FIXME: handle integer overflow json11::Json::object op_stats, subop_stats; for (int i = 0; i <= OSD_OP_MAX; i++) { diff --git a/osd_primary.cpp b/osd_primary.cpp index 02ee032c..fc14850f 100644 --- a/osd_primary.cpp +++ b/osd_primary.cpp @@ -247,6 +247,11 @@ resume_5: { int recovery_type = op_data->object_state->state & (OBJ_DEGRADED|OBJ_INCOMPLETE) ? 0 : 1; recovery_stat_count[0][recovery_type]++; + if (recovery_stat_count[0][recovery_type]) + { + recovery_stat_count[0][recovery_type]++; + recovery_stat_bytes[0][recovery_type] = 0; + } for (int role = 0; role < pg.pg_size; role++) { recovery_stat_bytes[0][recovery_type] += op_data->stripes[role].write_end - op_data->stripes[role].write_start; diff --git a/osd_primary_subops.cpp b/osd_primary_subops.cpp index 0e1a97d8..7af085c8 100644 --- a/osd_primary_subops.cpp +++ b/osd_primary_subops.cpp @@ -212,6 +212,12 @@ void osd_t::add_bs_subop_stats(osd_op_t *subop) timespec tv_end; clock_gettime(CLOCK_REALTIME, &tv_end); op_stat_count[0][opcode]++; + if (!op_stat_count[0][opcode]) + { + op_stat_count[0][opcode] = 1; + op_stat_sum[0][opcode] = 0; + op_stat_bytes[0][opcode] = 0; + } op_stat_sum[0][opcode] += ( (tv_end.tv_sec - subop->tv_begin.tv_sec)*1000000 + (tv_end.tv_nsec - subop->tv_begin.tv_nsec)/1000 diff --git a/osd_receive.cpp b/osd_receive.cpp index 06e4f7d1..4dbf27f7 100644 --- a/osd_receive.cpp +++ b/osd_receive.cpp @@ -140,6 +140,11 @@ void osd_t::handle_finished_read(osd_client_t & cl) timespec tv_end; clock_gettime(CLOCK_REALTIME, &tv_end); subop_stat_count[0][request->req.hdr.opcode]++; + if (!subop_stat_count[0][request->req.hdr.opcode]) + { + subop_stat_count[0][request->req.hdr.opcode]++; + subop_stat_sum[0][request->req.hdr.opcode] = 0; + } subop_stat_sum[0][request->req.hdr.opcode] += ( (tv_end.tv_sec - request->tv_begin.tv_sec)*1000000 + (tv_end.tv_nsec - request->tv_begin.tv_nsec)/1000 @@ -252,6 +257,11 @@ void osd_t::handle_reply_hdr(osd_client_t *cl) timespec tv_end; clock_gettime(CLOCK_REALTIME, &tv_end); subop_stat_count[0][op->req.hdr.opcode]++; + if (!subop_stat_count[0][op->req.hdr.opcode]) + { + subop_stat_count[0][op->req.hdr.opcode]++; + subop_stat_sum[0][op->req.hdr.opcode] = 0; + } subop_stat_sum[0][op->req.hdr.opcode] += ( (tv_end.tv_sec - op->tv_begin.tv_sec)*1000000 + (tv_end.tv_nsec - op->tv_begin.tv_nsec)/1000 diff --git a/osd_send.cpp b/osd_send.cpp index 82eeda57..f8decb78 100644 --- a/osd_send.cpp +++ b/osd_send.cpp @@ -40,6 +40,12 @@ bool osd_t::try_send(osd_client_t & cl) // Measure execution latency timespec tv_end = cl.write_op->tv_send; op_stat_count[0][cl.write_op->req.hdr.opcode]++; + if (!op_stat_count[0][cl.write_op->req.hdr.opcode]) + { + op_stat_count[0][cl.write_op->req.hdr.opcode]++; + op_stat_sum[0][cl.write_op->req.hdr.opcode] = 0; + op_stat_bytes[0][cl.write_op->req.hdr.opcode] = 0; + } op_stat_sum[0][cl.write_op->req.hdr.opcode] += ( (tv_end.tv_sec - cl.write_op->tv_begin.tv_sec)*1000000 + (tv_end.tv_nsec - cl.write_op->tv_begin.tv_nsec)/1000