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 inline void __run_complete(struct io *c_iop)
29 if (remapper_dev(c_iop->t.device))
30 bilink_for_each_down(run_remap, c_iop, &rmhd, 1);
32 bilink_for_each_down(run_issue, c_iop, &rmhd, 1);
36 LIST_DEL(&c_iop->c_pending);
39 list_add_tail(&c_iop->f_head, &rmhd);
43 static int ready_complete_remapper(struct io *c_iop)
46 struct list_head *p, *q;
47 struct io *l_iop, *a_iop;
49 dip_foreach_list(c_iop, IOP_L, &head);
50 list_for_each_safe(p, q, &head) {
51 l_iop = list_entry(p, struct io, f_head);
52 LIST_DEL(&l_iop->f_head);
54 ASSERT(!list_empty(&l_iop->up_list));
55 a_iop = bilink_first_up(l_iop, NULL);
56 if (ready_remap(a_iop, c_iop)) {
59 c_iop->bytes_left -= a_iop->t.bytes;
63 return c_iop->bytes_left == 0;
66 int ready_complete(struct io *c_iop)
71 if (c_iop->bytes_left == 0)
74 if (remapper_dev(c_iop->t.device))
75 return ready_complete_remapper(c_iop);
77 if (!list_empty(&c_iop->down_list))
80 d_iop = dip_find_sec(c_iop->dip, IOP_D, BIT_START(c_iop));
84 if (c_iop->t.bytes != d_iop->t.bytes) {
86 "\nFATAL: Probable time anomaly detected\n");
88 "D @ %15.9lf missing C, later C @ %15.9lf\n",
89 BIT_TIME(d_iop->t.time),
90 BIT_TIME(c_iop->t.time));
94 if (!ready_issue(d_iop, c_iop))
97 c_iop->bytes_left = 0;
99 d2c = tdelta(d_iop, c_iop);
100 update_d2c(d_iop, d_iop->down_len, d2c);
101 latency_d2c(d_iop->dip, c_iop->t.time, d2c);
102 iostat_complete(d_iop, c_iop);
104 bilink(d_iop, c_iop);
109 void trace_complete(struct io *c_iop)
111 if (io_setup(c_iop, IOP_C)) {
113 update_cregion(&all_regions, c_iop->t.time);
114 update_cregion(&c_iop->dip->regions, c_iop->t.time);
116 update_cregion(&c_iop->pip->regions, c_iop->t.time);
118 list_add_tail(&c_iop->c_pending, &pending_cs);
119 switch (ready_complete(c_iop)) {
121 __run_complete(c_iop);
127 LIST_DEL(&c_iop->c_pending);
137 void retry_complete(struct io *c_iop, __u64 now)
139 double tc = BIT_TIME(c_iop->t.time);
141 switch (ready_complete(c_iop)) {
144 fprintf(stderr, "Retried %15.9lf success!\n", tc);
146 __run_complete(c_iop);
149 if (now == 0 || ((BIT_TIME(now) - tc) < 1.0))
151 if (!list_empty(&c_iop->down_list))
155 LIST_DEL(&c_iop->c_pending);