-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathziolatency.d
More file actions
71 lines (60 loc) · 2.84 KB
/
ziolatency.d
File metadata and controls
71 lines (60 loc) · 2.84 KB
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
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option dynvarsize=40m
/* Description: Trace I/O latency on a per-vdev basis. Script will not be maintained for the foreseeable future. */
/* Author: Kirill.Davydychev@Nexenta.com */
/* Copyright 2012, Nexenta Systems, Inc. All rights reserved. */
dtrace:::BEGIN
{
trace("Tracing physical I/O latency... Ctrl-C to end.");
/* see /usr/include/sys/fs/zfs.h */
ziotype[0] = "null";
ziotype[1] = "read";
ziotype[2] = "write";
ziotype[3] = "free";
ziotype[4] = "claim";
ziotype[5] = "ioctl";
ziochild[0] = "vdev";
ziochild[1] = "gang";
ziochild[2] = "ddt";
ziochild[3] = "logical";
}
fbt::zio_vdev_io_start:entry
/args[0]->io_type != 0/
{
start_time[arg0] = timestamp;
}
fbt::zio_vdev_io_done:entry
/args[0]->io_type != 0 && start_time[arg0] > 0/ /* && args[0]->io_vd && args[0]->io_vd->vdev_path */
{
this->iotime = (timestamp - start_time[arg0])/1000;
this->zpool = stringof(args[0]->io_spa->spa_name);
this->iotype = ziotype[args[0]->io_type];
this->childtype = ziochild[args[0]->io_child_type];
this->path = args[0]->io_vd ?
args[0]->io_vd->vdev_path ?
stringof(args[0]->io_vd->vdev_path) :
"top_level_vdev" :
"pool";
this->vdev_id = args[0]->io_vd ?
args[0]->io_vd->vdev_id :
404; /* Not Found (pool) */
this->vdev_pa = args[0]->io_vd ?
args[0]->io_vd->vdev_parent ?
args[0]->io_vd->vdev_parent->vdev_id :
12455 : /* L2ARC has no parent - set to 12455 (L2ArcSSd) */
404; /* Not found */
/* XXX - Describe abnormal behaviors to watch out for */
@latency[this->zpool, this->childtype, this->vdev_pa, this->vdev_id, this->iotype, this->path] = quantize(this->iotime);
@avg_lat[this->zpool, this->childtype, this->vdev_pa, this->vdev_id, this->iotype, this->path] = avg(this->iotime);
@sum_lat[this->zpool, this->childtype, this->vdev_pa, this->vdev_id, this->iotype, this->path] = sum(this->iotime);
}
dtrace:::END
{
printa("ZPool: %12s IOChild: %7s ParentVdevID: %5d ThisVdevID: %3d IOType: %5s Disk: %s\t Latency distribution:%@d\n",@latency);
printa("ZPool: %12s IOChild: %7s ParentVdevID: %5d ThisVdevID: %3d IOType: %5s Disk: %s\t AvgLatency(us): %@d\n",@avg_lat);
printa("ZPool: %12s IOChild: %7s ParentVdevID: %5d ThisVdevID: %3d IOType: %5s Disk: %s\t TotLatency(us): %@d\n",@sum_lat);
trunc(@latency);
trunc(@avg_lat);
trunc(@sum_lat);
}