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