From 77f256cda4b2f076f5169fdf1bc815f629eea361 Mon Sep 17 00:00:00 2001 From: "Alan D. Brunelle" Date: Thu, 8 Nov 2007 08:34:44 -0500 Subject: [PATCH] Fixed REMAP to update Q2A & fixed #Q calculations --- btt/globals.h | 2 +- btt/output.c | 18 ++++++++++++++---- btt/trace_queue.c | 1 + btt/trace_remap.c | 34 ++++++++++++++++++++++++---------- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/btt/globals.h b/btt/globals.h index b4ef4e3..e1751e4 100644 --- a/btt/globals.h +++ b/btt/globals.h @@ -162,7 +162,7 @@ struct d_info { FILE *d2c_ofp, *q2c_ofp; struct avgs_info avgs; struct stats stats, all_stats; - __u64 last_q, n_ds; + __u64 last_q, n_qs, n_ds; __u32 device; int pre_culling; diff --git a/btt/output.c b/btt/output.c index fd9392a..21392d6 100644 --- a/btt/output.c +++ b/btt/output.c @@ -141,15 +141,25 @@ void __output_dip_merge_ratio(struct d_info *dip, void *arg) { double blks_avg; char scratch[15]; - double ratio, q2c_n = dip->avgs.q2c.n, d2c_n = dip->n_ds; + double ratio, q2c_n, d2c_n; + if (dip->n_qs == 0 || dip->n_ds == 0) + return; + else if (dip->n_qs < dip->n_ds) + dip->n_qs = dip->n_ds; + + q2c_n = dip->n_qs; + d2c_n = dip->n_ds; if (q2c_n > 0.0 && d2c_n > 0.0) { - ratio = q2c_n / d2c_n; + if (q2c_n < d2c_n) + ratio = 1.0; + else + ratio = q2c_n / d2c_n; blks_avg = (double)dip->avgs.blks.total / d2c_n; fprintf((FILE *)arg, "%10s | %8llu %8llu %7.1lf | %8llu %8llu %8llu %8llu\n", make_dev_hdr(scratch, 15, dip), - (unsigned long long)dip->avgs.q2c.n, + (unsigned long long)dip->n_qs, (unsigned long long)dip->n_ds, ratio, (unsigned long long)dip->avgs.blks.min, @@ -162,7 +172,7 @@ void __output_dip_merge_ratio(struct d_info *dip, void *arg) merge_data.blkmax = dip->avgs.blks.max; } - merge_data.nq += dip->avgs.q2c.n; + merge_data.nq += dip->n_qs; merge_data.nd += dip->n_ds; merge_data.total += dip->avgs.blks.total; if (dip->avgs.blks.min < merge_data.blkmin) diff --git a/btt/trace_queue.c b/btt/trace_queue.c index f882ad2..1d2afbe 100644 --- a/btt/trace_queue.c +++ b/btt/trace_queue.c @@ -32,6 +32,7 @@ static void handle_queue(struct io *q_iop) q_iop->i_time = q_iop->gm_time = q_iop->d_time = (__u64)-1; q_iop->is_getrq = -1; + q_iop->dip->n_qs++; } void trace_queue(struct io *q_iop) diff --git a/btt/trace_remap.c b/btt/trace_remap.c index 1e11ddc..22d340b 100644 --- a/btt/trace_remap.c +++ b/btt/trace_remap.c @@ -20,23 +20,37 @@ */ #include "globals.h" -static void handle_remap(struct io *a_iop) +static inline void cvt_pdu_remap(struct blk_io_trace_remap *rp) { - struct blk_io_trace_remap *rp = a_iop->pdu; - struct io *q_iop; - - q_iop = dip_find_sec(a_iop->dip, IOP_Q, be64_to_cpu(rp->sector)); - if (q_iop) - update_q2a(q_iop, tdelta(q_iop->t.time, a_iop->t.time)); + rp->device = be32_to_cpu(rp->device); + rp->device_from = be32_to_cpu(rp->device_from); + rp->sector = be64_to_cpu(rp->sector); } +/* + * q_iop == volume device + * a_iop == underlying device + */ void trace_remap(struct io *a_iop) { + struct io *q_iop; + struct d_info *q_dip; struct blk_io_trace_remap *rp = a_iop->pdu; - a_iop->t.device = be32_to_cpu(rp->device_from); - if (io_setup(a_iop, IOP_A)) - handle_remap(a_iop); + cvt_pdu_remap(rp); + + a_iop->t.device = rp->device_from; + if (!io_setup(a_iop, IOP_A)) + goto out; + + q_dip = __dip_find(rp->device); + if (!q_dip) + goto out; + + q_iop = dip_find_sec(q_dip, IOP_Q, rp->sector); + if (q_iop) + update_q2a(q_iop, tdelta(q_iop->t.time, a_iop->t.time)); +out: io_release(a_iop); } -- 2.25.1