summaryrefslogtreecommitdiff
path: root/btt/trace_issue.c
blob: d2b083245ee746623c0fff811061d64cd5d1ee34 (plain)
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
/*
 * 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"

static void __run_issue(struct io *im_iop, struct io *d_iop, struct io *c_iop)
{
	update_i2d(im_iop, tdelta(im_iop, d_iop));
	run_im(im_iop, d_iop, c_iop);
	dump_iop(d_iop, 0);
}

static void __run_unissue(struct io *im_iop, struct io *d_iop, 
			  struct io *c_iop)
{
	unupdate_i2d(im_iop, tdelta(im_iop, d_iop));
	run_unim(im_iop, d_iop, c_iop);
}

void run_issue(struct io *d_iop, __attribute__((__unused__))struct io *u_iop, 
							struct io *c_iop)
{
	bilink_for_each_down(__run_issue, d_iop, c_iop, 1);
	add_rmhd(d_iop);
}

void run_unissue(struct io *d_iop, 
		 __attribute__((__unused__))struct io *u_iop, 
		 struct io *c_iop)
{
	bilink_for_each_down(__run_unissue, d_iop, c_iop, 1);
	add_rmhd(d_iop);
}

int ready_issue(struct io *d_iop, struct io *c_iop)
{
	if (d_iop->bytes_left > 0) {
		LIST_HEAD(head);
		struct io *im_iop;
		struct list_head *p, *q;

		dip_foreach_list(d_iop, IOP_I, &head);
		dip_foreach_list(d_iop, IOP_M, &head);
		list_for_each_safe(p, q, &head) {
			im_iop = list_entry(p, struct io, f_head);
			LIST_DEL(&im_iop->f_head);

			ASSERT(d_iop->bytes_left >= im_iop->t.bytes);
			if (ready_im(im_iop, c_iop)) {
				bilink(im_iop, d_iop);
				dip_rem(im_iop);
				d_iop->bytes_left -= im_iop->t.bytes;
			}
		}
	}

	return d_iop->bytes_left == 0;
}

void trace_issue(struct io *d_iop)
{
	if (io_setup(d_iop, IOP_D)) {
		seeki_add(d_iop->dip->seek_handle, d_iop);
		bno_dump_add(d_iop->dip->bno_dump_handle, d_iop);
		iostat_issue(d_iop);
		d_iop->dip->n_ds++;
		if (!remapper_dev(d_iop->t.device))
			update_d_histo(d_iop->t.bytes);
	}
	else
		io_release(d_iop);

}