FreeBSD/Linux Kernel Cross Reference
sys/sys/iostat.h
1 /* $NetBSD: iostat.h,v 1.6 2006/08/23 17:19:33 christos Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the NetBSD
22 * Foundation, Inc. and its contributors.
23 * 4. Neither the name of The NetBSD Foundation nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40 #ifndef _SYS_IOSTAT_H_
41 #define _SYS_IOSTAT_H_
42
43 /*
44 * Disk device structures.
45 */
46
47 #include <sys/time.h>
48 #include <sys/queue.h>
49 #include <sys/lock.h>
50
51 #define IOSTATNAMELEN 16
52
53 /* types of drives we can have */
54 #define IOSTAT_DISK 0
55 #define IOSTAT_TAPE 1
56 #define IOSTAT_NFS 2
57
58 /* The following structure is 64-bit alignment safe */
59 struct io_sysctl {
60 char name[IOSTATNAMELEN];
61 int32_t busy;
62 int32_t type;
63 u_int64_t xfer;
64 u_int64_t seek;
65 u_int64_t bytes;
66 u_int32_t attachtime_sec;
67 u_int32_t attachtime_usec;
68 u_int32_t timestamp_sec;
69 u_int32_t timestamp_usec;
70 u_int32_t time_sec;
71 u_int32_t time_usec;
72 /* New separate read/write stats */
73 u_int64_t rxfer;
74 u_int64_t rbytes;
75 u_int64_t wxfer;
76 u_int64_t wbytes;
77 };
78
79 /*
80 * Structure for keeping the in-kernel drive stats - these are linked
81 * together in drivelist.
82 */
83
84 struct io_stats {
85 char io_name[IOSTATNAMELEN]; /* device name */
86 void *io_parent; /* pointer to what we are attached to */
87 int io_type; /* type of device the state belong to */
88 int io_busy; /* busy counter */
89 u_int64_t io_rxfer; /* total number of read transfers */
90 u_int64_t io_wxfer; /* total number of write transfers */
91 u_int64_t io_seek; /* total independent seek operations */
92 u_int64_t io_rbytes; /* total bytes read */
93 u_int64_t io_wbytes; /* total bytes written */
94 struct timeval io_attachtime; /* time disk was attached */
95 struct timeval io_timestamp; /* timestamp of last unbusy */
96 struct timeval io_time; /* total time spent busy */
97 TAILQ_ENTRY(io_stats) io_link;
98 };
99
100 /*
101 * drivelist_head is defined here so that user-land has access to it.
102 */
103 TAILQ_HEAD(iostatlist_head, io_stats); /* the iostatlist is a TAILQ */
104
105 #ifdef _KERNEL
106 void iostat_busy(struct io_stats *);
107 void iostat_unbusy(struct io_stats *, long, int);
108 struct io_stats *iostat_find(const char *);
109 struct io_stats *iostat_alloc(int32_t, void *, const char *);
110 void iostat_free(struct io_stats *);
111 void iostat_seek(struct io_stats *);
112 #endif
113
114 #endif /* _SYS_IOSTAT_H_ */
Cache object: 79a370158339500fb89caabddeafe06e
|