diff --git a/src/control/cmd/ddb/ddb_commands.go b/src/control/cmd/ddb/ddb_commands.go index bee8aeddc4d..aa8bb7f968a 100644 --- a/src/control/cmd/ddb/ddb_commands.go +++ b/src/control/cmd/ddb/ddb_commands.go @@ -434,7 +434,7 @@ the path must include the extent, otherwise, it must not.`, a.String("path", "Optional, VOS tree path of a container to aggregate.", grumble.Default("")) }, Flags: func(f *grumble.Flags) { - f.Uint64("t", "cmt_time", math.MaxUint64, "Max aggregfation committed time in seconds") + f.Uint64("t", "cmt_time", math.MaxUint64, "Max aggregation committed time in seconds") f.String("d", "cmt_date", "", "Max aggregation committed date (format '1970-01-01 00:00:00')") }, Run: func(c *grumble.Context) error { diff --git a/src/include/daos_srv/vos.h b/src/include/daos_srv/vos.h index 3eef3f4702d..f152a11f39a 100644 --- a/src/include/daos_srv/vos.h +++ b/src/include/daos_srv/vos.h @@ -1799,7 +1799,8 @@ bool vos_oi_exist(daos_handle_t coh, daos_unit_oid_t oid); /* Timing statistic of DTX entries */ -#define DTX_TIME_STAT_COUNT 3 +enum { DTX_TIME_STAT_MIN = 0, DTX_TIME_STAT_MAX, DTX_TIME_STAT_MEAN, DTX_TIME_STAT_COUNT }; + struct dtx_time_stat { daos_epoch_t dts_epoch[DTX_TIME_STAT_COUNT]; uint64_t dts_cmt_time[DTX_TIME_STAT_COUNT]; diff --git a/src/utils/ddb/ddb_commands.c b/src/utils/ddb/ddb_commands.c index 0e26686a24c..705c0eaabda 100644 --- a/src/utils/ddb/ddb_commands.c +++ b/src/utils/ddb/ddb_commands.c @@ -1506,35 +1506,48 @@ dtx_stat_cont_cb(daos_handle_t ih, vos_iter_entry_t *entry, vos_iter_type_t type if (args->opt->details) { if (args->aggr_epoch < args_tmp.aggr_epoch) args->aggr_epoch = args_tmp.aggr_epoch; - if (args->time_stat.dts_cmt_time[0] > args_tmp.time_stat.dts_cmt_time[0]) - args->time_stat.dts_cmt_time[0] = args_tmp.time_stat.dts_cmt_time[0]; - if (args->time_stat.dts_cmt_time[1] < args_tmp.time_stat.dts_cmt_time[1]) - args->time_stat.dts_cmt_time[1] = args_tmp.time_stat.dts_cmt_time[1]; - if (args->time_stat.dts_cmt_time[2] == 0) - args->time_stat.dts_cmt_time[2] = args_tmp.time_stat.dts_cmt_time[2]; + if (args->time_stat.dts_cmt_time[DTX_TIME_STAT_MIN] > + args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MIN]) + args->time_stat.dts_cmt_time[DTX_TIME_STAT_MIN] = + args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MIN]; + if (args->time_stat.dts_cmt_time[DTX_TIME_STAT_MAX] < + args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MAX]) + args->time_stat.dts_cmt_time[DTX_TIME_STAT_MAX] = + args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MAX]; + if (args->time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] == 0) + args->time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] = + args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN]; else { long double tmp_mean; - tmp_mean = args->time_stat.dts_cmt_time[2] * (long double)args->cmt_cnt; - tmp_mean += (long double)args_tmp.time_stat.dts_cmt_time[2] * - (long double)args_tmp.cmt_cnt; + tmp_mean = args->time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] * + (long double)args->cmt_cnt; + tmp_mean += + (long double)args_tmp.time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] * + (long double)args_tmp.cmt_cnt; tmp_mean /= (long double)(args->cmt_cnt + args_tmp.cmt_cnt); - args->time_stat.dts_cmt_time[2] = tmp_mean; + args->time_stat.dts_cmt_time[DTX_TIME_STAT_MEAN] = tmp_mean; } - if (args->time_stat.dts_epoch[0] > args_tmp.time_stat.dts_epoch[0]) - args->time_stat.dts_epoch[0] = args_tmp.time_stat.dts_epoch[0]; - if (args->time_stat.dts_epoch[1] < args_tmp.time_stat.dts_epoch[1]) - args->time_stat.dts_epoch[1] = args_tmp.time_stat.dts_epoch[1]; - if (args->time_stat.dts_epoch[2] == 0) - args->time_stat.dts_epoch[2] = args_tmp.time_stat.dts_epoch[2]; + if (args->time_stat.dts_epoch[DTX_TIME_STAT_MIN] > + args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MIN]) + args->time_stat.dts_epoch[DTX_TIME_STAT_MIN] = + args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MIN]; + if (args->time_stat.dts_epoch[DTX_TIME_STAT_MAX] < + args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MAX]) + args->time_stat.dts_epoch[DTX_TIME_STAT_MAX] = + args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MAX]; + if (args->time_stat.dts_epoch[DTX_TIME_STAT_MEAN] == 0) + args->time_stat.dts_epoch[DTX_TIME_STAT_MEAN] = + args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MEAN]; else { long double tmp_mean; - tmp_mean = args->time_stat.dts_epoch[2] * (long double)args->cmt_cnt; - tmp_mean += (long double)args_tmp.time_stat.dts_epoch[2] * + tmp_mean = args->time_stat.dts_epoch[DTX_TIME_STAT_MEAN] * + (long double)args->cmt_cnt; + tmp_mean += (long double)args_tmp.time_stat.dts_epoch[DTX_TIME_STAT_MEAN] * (long double)args_tmp.cmt_cnt; tmp_mean /= (long double)(args->cmt_cnt + args_tmp.cmt_cnt); - args->time_stat.dts_epoch[2] = tmp_mean; + args->time_stat.dts_epoch[DTX_TIME_STAT_MEAN] = tmp_mean; } } @@ -1592,8 +1605,8 @@ ddb_run_dtx_stat(struct ddb_ctx *ctx, struct dtx_stat_options *opt) } args.cmt_cnt = 0; - args.time_stat.dts_cmt_time[0] = UINT64_MAX; - args.time_stat.dts_epoch[0] = DAOS_EPOCH_MAX; + args.time_stat.dts_cmt_time[DTX_TIME_STAT_MIN] = UINT64_MAX; + args.time_stat.dts_epoch[DTX_TIME_STAT_MIN] = DAOS_EPOCH_MAX; param.ip_hdl = ctx->dc_poh; param.ip_epr.epr_hi = DAOS_EPOCH_MAX; do { diff --git a/src/vos/vos_dtx.c b/src/vos/vos_dtx.c index 86005bca3bc..c64adc12bb0 100644 --- a/src/vos/vos_dtx.c +++ b/src/vos/vos_dtx.c @@ -4070,10 +4070,12 @@ vos_dtx_local_end(struct dtx_handle *dth, int result) return result; } +enum { DTS_EPOCH_ACC = 0, DTS_CMT_TIME_ACC, DTS_ACC_COUNT }; + struct dtx_time_stat_priv { struct dtx_time_stat dts_pub; /* DAOS-17322: Use of floating point to avoid integer overflow issue */ - long double dts_mean[2]; + long double dts_mean[DTS_ACC_COUNT]; }; int @@ -4099,8 +4101,8 @@ vos_dtx_get_cmt_stat(daos_handle_t coh, uint64_t *cmt_cnt, struct dtx_time_stat cmt_cnt_tmp = 0; umm = vos_cont2umm(cont); dbd = umem_off2ptr(umm, cont->vc_cont_df->cd_dtx_committed_head); - dts_tmp.dts_pub.dts_epoch[0] = DAOS_EPOCH_MAX; - dts_tmp.dts_pub.dts_cmt_time[0] = UINT64_MAX; + dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MIN] = DAOS_EPOCH_MAX; + dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MIN] = UINT64_MAX; while (dbd != NULL) { if (dbd->dbd_magic != DTX_CMT_BLOB_MAGIC) { D_ERROR("Committed DTX blob with bad magic: container=" DF_UUID @@ -4119,17 +4121,25 @@ vos_dtx_get_cmt_stat(daos_handle_t coh, uint64_t *cmt_cnt, struct dtx_time_stat dce_df = &dbd->dbd_committed_data[i]; - if (dts_tmp.dts_pub.dts_epoch[0] > dce_df->dce_epoch) - dts_tmp.dts_pub.dts_epoch[0] = dce_df->dce_epoch; - if (dts_tmp.dts_pub.dts_epoch[1] < dce_df->dce_epoch) - dts_tmp.dts_pub.dts_epoch[1] = dce_df->dce_epoch; - dts_tmp.dts_mean[0] += dce_df->dce_epoch; - - if (dts_tmp.dts_pub.dts_cmt_time[0] > dce_df->dce_cmt_time) - dts_tmp.dts_pub.dts_cmt_time[0] = dce_df->dce_cmt_time; - if (dts_tmp.dts_pub.dts_cmt_time[1] < dce_df->dce_cmt_time) - dts_tmp.dts_pub.dts_cmt_time[1] = dce_df->dce_cmt_time; - dts_tmp.dts_mean[1] += dce_df->dce_cmt_time; + if (dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MIN] > + dce_df->dce_epoch) + dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MIN] = + dce_df->dce_epoch; + if (dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MAX] < + dce_df->dce_epoch) + dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MAX] = + dce_df->dce_epoch; + dts_tmp.dts_mean[DTS_EPOCH_ACC] += dce_df->dce_epoch; + + if (dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MIN] > + dce_df->dce_cmt_time) + dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MIN] = + dce_df->dce_cmt_time; + if (dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MAX] < + dce_df->dce_cmt_time) + dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MAX] = + dce_df->dce_cmt_time; + dts_tmp.dts_mean[DTS_CMT_TIME_ACC] += dce_df->dce_cmt_time; } } @@ -4140,11 +4150,13 @@ vos_dtx_get_cmt_stat(daos_handle_t coh, uint64_t *cmt_cnt, struct dtx_time_stat if (dts != NULL) { if (cmt_cnt_tmp != 0) { - dts_tmp.dts_mean[0] /= (long double)cmt_cnt_tmp; - dts_tmp.dts_pub.dts_epoch[2] = (daos_epoch_t)dts_tmp.dts_mean[0]; + dts_tmp.dts_mean[DTS_EPOCH_ACC] /= (long double)cmt_cnt_tmp; + dts_tmp.dts_pub.dts_epoch[DTX_TIME_STAT_MEAN] = + (daos_epoch_t)dts_tmp.dts_mean[DTS_EPOCH_ACC]; - dts_tmp.dts_mean[1] /= (long double)cmt_cnt_tmp; - dts_tmp.dts_pub.dts_cmt_time[2] = (uint64_t)dts_tmp.dts_mean[1]; + dts_tmp.dts_mean[DTS_CMT_TIME_ACC] /= (long double)cmt_cnt_tmp; + dts_tmp.dts_pub.dts_cmt_time[DTX_TIME_STAT_MEAN] = + (uint64_t)dts_tmp.dts_mean[DTS_CMT_TIME_ACC]; } memcpy(dts, &dts_tmp, sizeof(struct dtx_time_stat));