liyujie
2025-08-28 786ff4f4ca2374bdd9177f2e24b503d43e7a3b93
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
/*
 * 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 inline void cvt_pdu_remap(struct blk_io_trace_remap *rp)
{
   rp->device_from = be32_to_cpu(rp->device_from);
   rp->device_to   = be32_to_cpu(rp->device_to);
   rp->sector_from = be64_to_cpu(rp->sector_from);
}
 
/*
 * q_iop == volume device
 * a_iop == underlying device
 */
void trace_remap(struct io *a_iop)
{
   struct io *q_iop;
   struct d_info *q_dip;
   struct blk_io_trace_remap *rp;
 
   if (ignore_remaps)
       goto out;
 
   rp = a_iop->pdu;
   cvt_pdu_remap(rp);
 
   if (!io_setup(a_iop, IOP_A))
       goto out;
 
   q_dip = __dip_find(rp->device_from);
   if (!q_dip)
       goto out;
 
   q_iop = dip_find_sec(q_dip, IOP_Q, rp->sector_from);
   if (q_iop)
       update_q2a(q_iop, tdelta(q_iop->t.time, a_iop->t.time));
 
out:
   io_release(a_iop);
}