Fixed incorrect sizeof instead of strlen in btt/rstats.c
[blktrace.git] / btt / trace_issue.c
CommitLineData
095181f2
JA
1/*
2 * blktrace output analysis: generate a timeline & gather statistics
3 *
4 * Copyright (C) 2006 Alan D. Brunelle <Alan.Brunelle@hp.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21#include "globals.h"
22
4c48f14e 23static void handle_issue(struct io *d_iop)
095181f2 24{
4c48f14e
AB
25 LIST_HEAD(head);
26 struct list_head *p, *q;
27
50f73899
AB
28 if (d_iop->dip->n_act_q != 0)
29 d_iop->dip->n_act_q--;
30
4c48f14e
AB
31 seeki_add(d_iop->dip->seek_handle, d_iop);
32 bno_dump_add(d_iop->dip->bno_dump_handle, d_iop);
33 iostat_issue(d_iop);
34 d_iop->dip->n_ds++;
35 if (!remapper_dev(d_iop->t.device))
36 update_d_histo(d_iop->t.bytes);
4ae2c3c6 37 aqd_issue(d_iop->dip->aqd_handle, BIT_TIME(d_iop->t.time));
4c48f14e
AB
38
39 dip_foreach_list(d_iop, IOP_Q, &head);
40 list_for_each_safe(p, q, &head) {
41 struct io *q_iop = list_entry(p, struct io, f_head);
8b10aae0 42
ae6d30f4
AB
43 if (q_iop->i_time != (__u64)-1)
44 update_i2d(q_iop, tdelta(q_iop->i_time, d_iop->t.time));
45 else if (q_iop->m_time != (__u64)-1)
46 update_m2d(q_iop, tdelta(q_iop->m_time, d_iop->t.time));
47
4c48f14e 48 d_iop->bytes_left -= q_iop->t.bytes;
8b10aae0 49 list_del(&q_iop->f_head);
4c48f14e
AB
50
51 q_iop->d_time = d_iop->t.time;
52 q_iop->d_sec = d_iop->t.sector;
53 q_iop->d_nsec = t_sec(&d_iop->t);
951ea56c
AB
54
55 if (output_all_data)
8b10aae0 56 q2d_histo_add(q_iop->dip->q2d_priv,
951ea56c 57 d_iop->t.time - q_iop->t.time);
e47ada10
AB
58 latency_q2d(q_iop->dip, d_iop->t.time,
59 d_iop->t.time - q_iop->t.time);
095181f2 60 }
095181f2
JA
61}
62
d76c5b81 63void trace_issue(struct io *d_iop)
095181f2 64{
354db430
AB
65 if (d_iop->t.bytes == 0)
66 return;
67
4c48f14e
AB
68 if (io_setup(d_iop, IOP_D))
69 handle_issue(d_iop);
354db430 70
4c48f14e 71 io_release(d_iop);
095181f2 72
095181f2 73}