1*1a3d31e3SAndroid Build Coastguard Worker /*
2*1a3d31e3SAndroid Build Coastguard Worker * blktrace output analysis: generate a timeline & gather statistics
3*1a3d31e3SAndroid Build Coastguard Worker *
4*1a3d31e3SAndroid Build Coastguard Worker * Copyright (C) 2006 Alan D. Brunelle <[email protected]>
5*1a3d31e3SAndroid Build Coastguard Worker *
6*1a3d31e3SAndroid Build Coastguard Worker * This program is free software; you can redistribute it and/or modify
7*1a3d31e3SAndroid Build Coastguard Worker * it under the terms of the GNU General Public License as published by
8*1a3d31e3SAndroid Build Coastguard Worker * the Free Software Foundation; either version 2 of the License, or
9*1a3d31e3SAndroid Build Coastguard Worker * (at your option) any later version.
10*1a3d31e3SAndroid Build Coastguard Worker *
11*1a3d31e3SAndroid Build Coastguard Worker * This program is distributed in the hope that it will be useful,
12*1a3d31e3SAndroid Build Coastguard Worker * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*1a3d31e3SAndroid Build Coastguard Worker * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*1a3d31e3SAndroid Build Coastguard Worker * GNU General Public License for more details.
15*1a3d31e3SAndroid Build Coastguard Worker *
16*1a3d31e3SAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License
17*1a3d31e3SAndroid Build Coastguard Worker * along with this program; if not, write to the Free Software
18*1a3d31e3SAndroid Build Coastguard Worker * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*1a3d31e3SAndroid Build Coastguard Worker *
20*1a3d31e3SAndroid Build Coastguard Worker */
21*1a3d31e3SAndroid Build Coastguard Worker #include "globals.h"
22*1a3d31e3SAndroid Build Coastguard Worker
cvt_pdu_remap(struct blk_io_trace_remap * rp)23*1a3d31e3SAndroid Build Coastguard Worker static inline void cvt_pdu_remap(struct blk_io_trace_remap *rp)
24*1a3d31e3SAndroid Build Coastguard Worker {
25*1a3d31e3SAndroid Build Coastguard Worker rp->device_from = be32_to_cpu(rp->device_from);
26*1a3d31e3SAndroid Build Coastguard Worker rp->device_to = be32_to_cpu(rp->device_to);
27*1a3d31e3SAndroid Build Coastguard Worker rp->sector_from = be64_to_cpu(rp->sector_from);
28*1a3d31e3SAndroid Build Coastguard Worker }
29*1a3d31e3SAndroid Build Coastguard Worker
30*1a3d31e3SAndroid Build Coastguard Worker /*
31*1a3d31e3SAndroid Build Coastguard Worker * q_iop == volume device
32*1a3d31e3SAndroid Build Coastguard Worker * a_iop == underlying device
33*1a3d31e3SAndroid Build Coastguard Worker */
trace_remap(struct io * a_iop)34*1a3d31e3SAndroid Build Coastguard Worker void trace_remap(struct io *a_iop)
35*1a3d31e3SAndroid Build Coastguard Worker {
36*1a3d31e3SAndroid Build Coastguard Worker struct io *q_iop;
37*1a3d31e3SAndroid Build Coastguard Worker struct d_info *q_dip;
38*1a3d31e3SAndroid Build Coastguard Worker struct blk_io_trace_remap *rp;
39*1a3d31e3SAndroid Build Coastguard Worker
40*1a3d31e3SAndroid Build Coastguard Worker if (ignore_remaps)
41*1a3d31e3SAndroid Build Coastguard Worker goto out;
42*1a3d31e3SAndroid Build Coastguard Worker
43*1a3d31e3SAndroid Build Coastguard Worker rp = a_iop->pdu;
44*1a3d31e3SAndroid Build Coastguard Worker cvt_pdu_remap(rp);
45*1a3d31e3SAndroid Build Coastguard Worker
46*1a3d31e3SAndroid Build Coastguard Worker if (!io_setup(a_iop, IOP_A))
47*1a3d31e3SAndroid Build Coastguard Worker goto out;
48*1a3d31e3SAndroid Build Coastguard Worker
49*1a3d31e3SAndroid Build Coastguard Worker q_dip = __dip_find(rp->device_from);
50*1a3d31e3SAndroid Build Coastguard Worker if (!q_dip)
51*1a3d31e3SAndroid Build Coastguard Worker goto out;
52*1a3d31e3SAndroid Build Coastguard Worker
53*1a3d31e3SAndroid Build Coastguard Worker q_iop = dip_find_sec(q_dip, IOP_Q, rp->sector_from);
54*1a3d31e3SAndroid Build Coastguard Worker if (q_iop)
55*1a3d31e3SAndroid Build Coastguard Worker update_q2a(q_iop, tdelta(q_iop->t.time, a_iop->t.time));
56*1a3d31e3SAndroid Build Coastguard Worker
57*1a3d31e3SAndroid Build Coastguard Worker out:
58*1a3d31e3SAndroid Build Coastguard Worker io_release(a_iop);
59*1a3d31e3SAndroid Build Coastguard Worker }
60