1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
/*
* blktrace output analysis: generate a timeline & gather statistics
*
* Copyright (C) 2006 Alan D. Brunelle <Alan.Brunelle@hp.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "globals.h"
LIST_HEAD(pending_cs);
static void gen_c_list(struct io *c_iop, struct list_head *c_head)
{
struct io *iop;
struct list_head *p;
__list_for_each(p, &pending_cs) {
iop = list_entry(p, struct io, c_pending);
if (iop->t.device == c_iop->t.device)
continue;
if (dip_find_sec(iop->dip, IOP_D, BIT_START(iop)) == NULL)
continue;
__link(iop, c_iop);
if (ready_complete(iop, c_iop))
list_add_tail(&iop->f_head, c_head);
__unlink(iop, c_iop);
}
}
static void run_comp(struct io *c_iop, struct io *top, struct list_head *rmhd)
{
struct io *d_iop = dip_find_sec(c_iop->dip, IOP_D, BIT_START(c_iop));
update_blks(c_iop);
if (d_iop) {
__u64 d2c = tdelta(d_iop, c_iop);
update_d2c(d_iop, d2c);
latency_d2c(d_iop->dip, c_iop->t.time, d2c);
iostat_complete(d_iop, c_iop);
__link(d_iop, c_iop);
run_issue(d_iop, top, rmhd);
__unlink(d_iop, c_iop);
}
else {
LIST_HEAD(head);
struct io *iop;
struct list_head *p, *q;
gen_c_list(c_iop, &head);
list_for_each_safe(p, q, &head) {
iop = list_entry(p, struct io, f_head);
LIST_DEL(&iop->f_head);
dump_level++;
__link(iop, c_iop);
run_comp(iop, top, rmhd);
__unlink(iop, c_iop);
dump_level--;
}
}
dump_iop(per_io_ofp, c_iop, NULL, 0);
LIST_DEL(&c_iop->c_pending);
list_add_tail(&c_iop->f_head, rmhd);
}
static int ready_comp(struct io *c_iop,
__attribute__((__unused__)) struct io *top)
{
LIST_HEAD(head);
struct io *iop;
struct list_head *p, *q;
__u64 bl = c_iop->bytes_left;
gen_c_list(c_iop, &head);
list_for_each_safe(p, q, &head) {
iop = list_entry(p, struct io, f_head);
LIST_DEL(&iop->f_head);
__link(iop, c_iop);
if (ready_complete(iop, c_iop))
bl -= iop->bytes_left;
__unlink(iop, c_iop);
}
return bl == 0;
}
void trace_complete(struct io *c_iop)
{
if (!io_setup(c_iop, IOP_C)) {
io_release(c_iop);
return;
}
list_add_tail(&c_iop->c_pending, &pending_cs);
if (ready_complete(c_iop, c_iop)) {
dump_level = 0;
run_complete(c_iop);
}
else
add_retry(c_iop);
}
int retry_complete(struct io *c_iop)
{
if (!ready_complete(c_iop, c_iop))
return 0;
del_retry(c_iop);
run_complete(c_iop);
return 1;
}
int ready_complete(struct io *c_iop, struct io *top)
{
struct io *d_iop = dip_find_sec(c_iop->dip, IOP_D, BIT_START(c_iop));
if (d_iop) {
ASSERT(d_iop->t.bytes == c_iop->bytes_left);
return ready_issue(d_iop, top);
}
else
return ready_comp(c_iop, top);
}
void run_complete(struct io *c_iop)
{
LIST_HEAD(rmhd);
update_cregion(&all_regions, c_iop->t.time);
update_cregion(&c_iop->dip->regions, c_iop->t.time);
if (c_iop->pip)
update_cregion(&c_iop->pip->regions, c_iop->t.time);
run_comp(c_iop, c_iop, &rmhd);
if (per_io_ofp) fprintf(per_io_ofp, "\n");
release_iops(&rmhd);
}
|