xref: /onnv-gate/usr/src/cmd/filebench/common/flowop.h (revision 5184:da60d2b4a9e2)
1*5184Sek110237 /*
2*5184Sek110237  * CDDL HEADER START
3*5184Sek110237  *
4*5184Sek110237  * The contents of this file are subject to the terms of the
5*5184Sek110237  * Common Development and Distribution License (the "License").
6*5184Sek110237  * You may not use this file except in compliance with the License.
7*5184Sek110237  *
8*5184Sek110237  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*5184Sek110237  * or http://www.opensolaris.org/os/licensing.
10*5184Sek110237  * See the License for the specific language governing permissions
11*5184Sek110237  * and limitations under the License.
12*5184Sek110237  *
13*5184Sek110237  * When distributing Covered Code, include this CDDL HEADER in each
14*5184Sek110237  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*5184Sek110237  * If applicable, add the following below this CDDL HEADER, with the
16*5184Sek110237  * fields enclosed by brackets "[]" replaced with your own identifying
17*5184Sek110237  * information: Portions Copyright [yyyy] [name of copyright owner]
18*5184Sek110237  *
19*5184Sek110237  * CDDL HEADER END
20*5184Sek110237  */
21*5184Sek110237 /*
22*5184Sek110237  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*5184Sek110237  * Use is subject to license terms.
24*5184Sek110237  */
25*5184Sek110237 
26*5184Sek110237 #ifndef	_FB_FLOWOP_H
27*5184Sek110237 #define	_FB_FLOWOP_H
28*5184Sek110237 
29*5184Sek110237 
30*5184Sek110237 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*5184Sek110237 
32*5184Sek110237 #include "config.h"
33*5184Sek110237 
34*5184Sek110237 #include <stdio.h>
35*5184Sek110237 #include <stdlib.h>
36*5184Sek110237 #include <unistd.h>
37*5184Sek110237 #include <sys/stat.h>
38*5184Sek110237 #include <sys/types.h>
39*5184Sek110237 #include <sys/param.h>
40*5184Sek110237 #include <sys/resource.h>
41*5184Sek110237 #include <pthread.h>
42*5184Sek110237 #ifndef HAVE_SYSV_SEM
43*5184Sek110237 #include <semaphore.h>
44*5184Sek110237 #endif
45*5184Sek110237 #include "stats.h"
46*5184Sek110237 #include "threadflow.h"
47*5184Sek110237 #include "vars.h"
48*5184Sek110237 #include "fileset.h"
49*5184Sek110237 #include "filebench.h"
50*5184Sek110237 
51*5184Sek110237 #ifdef	__cplusplus
52*5184Sek110237 extern "C" {
53*5184Sek110237 #endif
54*5184Sek110237 
55*5184Sek110237 typedef struct flowop {
56*5184Sek110237 	char		fo_name[128];	/* Name */
57*5184Sek110237 	int		fo_instance;	/* Instance number */
58*5184Sek110237 	struct flowop	*fo_next;	/* Next in global list */
59*5184Sek110237 	struct flowop	*fo_threadnext;	/* Next in thread's list */
60*5184Sek110237 	struct flowop	*fo_resultnext;	/* List of flowops in result */
61*5184Sek110237 	struct threadflow *fo_thread;	/* Backpointer to thread */
62*5184Sek110237 	int		(*fo_func)();	/* Method */
63*5184Sek110237 	int		(*fo_init)();	/* Init Method */
64*5184Sek110237 	void		(*fo_destruct)(); /* Destructor Method */
65*5184Sek110237 	int		fo_type;	/* Type */
66*5184Sek110237 	int		fo_attrs;	/* Flow op attribute */
67*5184Sek110237 	fileobj_t	*fo_file;	/* File for op */
68*5184Sek110237 	fileset_t	*fo_fileset;	/* Fileset for op */
69*5184Sek110237 	int		fo_fd;		/* File descriptor */
70*5184Sek110237 	int		fo_fdnumber;	/* User specified file descriptor */
71*5184Sek110237 	int		fo_srcfdnumber;	/* User specified src file descriptor */
72*5184Sek110237 	var_integer_t	fo_iosize;	/* Size of operation */
73*5184Sek110237 	var_integer_t	fo_wss;		/* Flow op working set size */
74*5184Sek110237 	char		fo_targetname[128]; /* Target, for wakeup etc... */
75*5184Sek110237 	struct flowop	*fo_targets;	/* List of targets matching name */
76*5184Sek110237 	struct flowop	*fo_targetnext;	/* List of targets matching name */
77*5184Sek110237 	var_integer_t	fo_iters;	/* Number of iterations of op */
78*5184Sek110237 	var_integer_t	fo_value;	/* Attr */
79*5184Sek110237 	var_integer_t	fo_sequential;	/* Attr */
80*5184Sek110237 	var_integer_t	fo_random;	/* Attr */
81*5184Sek110237 	var_integer_t	fo_stride;	/* Attr */
82*5184Sek110237 	var_integer_t	fo_backwards;	/* Attr */
83*5184Sek110237 	var_integer_t	fo_dsync;	/* Attr */
84*5184Sek110237 	var_integer_t	fo_blocking;	/* Attr */
85*5184Sek110237 	var_integer_t	fo_directio;	/* Attr */
86*5184Sek110237 	var_integer_t	fo_rotatefd;	/* Attr */
87*5184Sek110237 	flowstat_t	fo_stats;	/* Flow statistics */
88*5184Sek110237 	pthread_cond_t	fo_cv;		/* Block/wakeup cv */
89*5184Sek110237 	pthread_mutex_t	fo_lock;	/* Mutex around flowop */
90*5184Sek110237 	char		*fo_buf;	/* Per-flowop buffer */
91*5184Sek110237 #ifdef HAVE_SYSV_SEM
92*5184Sek110237 	int		fo_semid_lw;	/* sem id */
93*5184Sek110237 	int		fo_semid_hw;	/* sem id for highwater block */
94*5184Sek110237 #else
95*5184Sek110237 	sem_t		fo_sem;		/* sem_t for posix semaphores */
96*5184Sek110237 #endif /* HAVE_SYSV_SEM */
97*5184Sek110237 	var_integer_t	fo_highwater;	/* value of highwater paramter */
98*5184Sek110237 	void		*fo_idp;	/* id, for sems etc */
99*5184Sek110237 	hrtime_t	fo_timestamp;	/* for ratecontrol, etc... */
100*5184Sek110237 	int		fo_initted;	/* Set to one if initialized */
101*5184Sek110237 	int64_t		fo_tputbucket;	/* Throughput bucket, for limiter */
102*5184Sek110237 	uint64_t	fo_tputlast;	/* Throughput count, for delta's */
103*5184Sek110237 
104*5184Sek110237 } flowop_t;
105*5184Sek110237 
106*5184Sek110237 /* Flow Op Attrs */
107*5184Sek110237 #define	FLOW_ATTR_SEQUENTIAL	0x1
108*5184Sek110237 #define	FLOW_ATTR_RANDOM	0x2
109*5184Sek110237 #define	FLOW_ATTR_STRIDE	0x4
110*5184Sek110237 #define	FLOW_ATTR_BACKWARDS	0x8
111*5184Sek110237 #define	FLOW_ATTR_DSYNC		0x10
112*5184Sek110237 #define	FLOW_ATTR_BLOCKING	0x20
113*5184Sek110237 #define	FLOW_ATTR_DIRECTIO	0x40
114*5184Sek110237 #define	FLOW_ATTR_READ		0x80
115*5184Sek110237 #define	FLOW_ATTR_WRITE		0x100
116*5184Sek110237 
117*5184Sek110237 #define	FLOW_MASTER -1	    /* Declaration of thread from script */
118*5184Sek110237 #define	FLOW_DEFINITION 0   /* Prototype definition of flowop from library */
119*5184Sek110237 
120*5184Sek110237 #define	FLOW_TYPES	5
121*5184Sek110237 #define	FLOW_TYPE_GLOBAL	0  /* Rolled up statistics */
122*5184Sek110237 #define	FLOW_TYPE_IO		1  /* Op is an I/O, reflected in iops and lat */
123*5184Sek110237 #define	FLOW_TYPE_AIO		2  /* Op is an async I/O, reflected in iops */
124*5184Sek110237 #define	FLOW_TYPE_SYNC		3  /* Op is a sync event */
125*5184Sek110237 #define	FLOW_TYPE_OTHER		4  /* Op is a something else */
126*5184Sek110237 
127*5184Sek110237 extern flowstat_t controlstats;
128*5184Sek110237 
129*5184Sek110237 void flowop_init(void);
130*5184Sek110237 flowop_t *flowop_define(threadflow_t *, char *name, flowop_t *inherit,
131*5184Sek110237     int instance, int type);
132*5184Sek110237 flowop_t *flowop_find(char *name);
133*5184Sek110237 flowop_t *flowop_find_one(char *name, int instance);
134*5184Sek110237 void flowoplib_usage(void);
135*5184Sek110237 void flowoplib_init(void);
136*5184Sek110237 void flowop_delete_all(flowop_t **threadlist);
137*5184Sek110237 void flowop_endop(threadflow_t *threadflow, flowop_t *flowop);
138*5184Sek110237 void flowop_beginop(threadflow_t *threadflow, flowop_t *flowop);
139*5184Sek110237 
140*5184Sek110237 #ifdef	__cplusplus
141*5184Sek110237 }
142*5184Sek110237 #endif
143*5184Sek110237 
144*5184Sek110237 #endif	/* _FB_FLOWOP_H */
145