2 * blktrace output analysis: generate a timeline & gather statistics
4 * Copyright (C) 2006 Alan D. Brunelle <Alan.Brunelle@hp.com>
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.
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.
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
23 LIST_HEAD(pending_cs);
25 static void gen_c_list(struct io *c_iop, struct list_head *c_head)
30 __list_for_each(p, &pending_cs) {
31 iop = list_entry(p, struct io, c_pending);
32 if (iop->t.device == c_iop->t.device)
34 if (dip_find_sec(iop->dip, IOP_D, BIT_START(iop)) == NULL)
38 if (ready_complete(iop, c_iop))
39 list_add_tail(&iop->f_head, c_head);
44 static void run_comp(struct io *c_iop, struct io *top, struct list_head *rmhd)
46 struct io *d_iop = dip_find_sec(c_iop->dip, IOP_D, BIT_START(c_iop));
50 __u64 d2c = tdelta(d_iop, c_iop);
52 update_d2c(d_iop, d2c);
53 latency_d2c(d_iop->dip, c_iop->t.time, d2c);
54 iostat_complete(d_iop, c_iop);
57 run_issue(d_iop, top, rmhd);
58 __unlink(d_iop, c_iop);
63 struct list_head *p, *q;
65 gen_c_list(c_iop, &head);
66 list_for_each_safe(p, q, &head) {
67 iop = list_entry(p, struct io, f_head);
68 LIST_DEL(&iop->f_head);
72 run_comp(iop, top, rmhd);
77 dump_iop(per_io_ofp, c_iop, NULL, 0);
78 LIST_DEL(&c_iop->c_pending);
79 list_add_tail(&c_iop->f_head, rmhd);
82 static int ready_comp(struct io *c_iop,
83 __attribute__((__unused__)) struct io *top)
87 struct list_head *p, *q;
88 __u64 bl = c_iop->bytes_left;
90 gen_c_list(c_iop, &head);
91 list_for_each_safe(p, q, &head) {
92 iop = list_entry(p, struct io, f_head);
93 LIST_DEL(&iop->f_head);
96 if (ready_complete(iop, c_iop))
97 bl -= iop->bytes_left;
104 void trace_complete(struct io *c_iop)
106 if (!io_setup(c_iop, IOP_C)) {
111 list_add_tail(&c_iop->c_pending, &pending_cs);
112 if (ready_complete(c_iop, c_iop)) {
120 int retry_complete(struct io *c_iop)
122 if (!ready_complete(c_iop, c_iop))
130 int ready_complete(struct io *c_iop, struct io *top)
132 struct io *d_iop = dip_find_sec(c_iop->dip, IOP_D, BIT_START(c_iop));
135 ASSERT(d_iop->t.bytes == c_iop->bytes_left);
136 return ready_issue(d_iop, top);
139 return ready_comp(c_iop, top);
142 void run_complete(struct io *c_iop)
146 update_cregion(&all_regions, c_iop->t.time);
147 update_cregion(&c_iop->dip->regions, c_iop->t.time);
149 update_cregion(&c_iop->pip->regions, c_iop->t.time);
151 run_comp(c_iop, c_iop, &rmhd);
152 if (per_io_ofp) fprintf(per_io_ofp, "\n");