xref: /onnv-gate/usr/src/cmd/filebench/common/flowop.h (revision 6084:d5f45b4dae7e)
15184Sek110237 /*
25184Sek110237  * CDDL HEADER START
35184Sek110237  *
45184Sek110237  * The contents of this file are subject to the terms of the
55184Sek110237  * Common Development and Distribution License (the "License").
65184Sek110237  * You may not use this file except in compliance with the License.
75184Sek110237  *
85184Sek110237  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95184Sek110237  * or http://www.opensolaris.org/os/licensing.
105184Sek110237  * See the License for the specific language governing permissions
115184Sek110237  * and limitations under the License.
125184Sek110237  *
135184Sek110237  * When distributing Covered Code, include this CDDL HEADER in each
145184Sek110237  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155184Sek110237  * If applicable, add the following below this CDDL HEADER, with the
165184Sek110237  * fields enclosed by brackets "[]" replaced with your own identifying
175184Sek110237  * information: Portions Copyright [yyyy] [name of copyright owner]
185184Sek110237  *
195184Sek110237  * CDDL HEADER END
205184Sek110237  */
215184Sek110237 /*
22*6084Saw148015  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
235184Sek110237  * Use is subject to license terms.
245184Sek110237  */
255184Sek110237 
265184Sek110237 #ifndef	_FB_FLOWOP_H
275184Sek110237 #define	_FB_FLOWOP_H
285184Sek110237 
295184Sek110237 
305184Sek110237 #pragma ident	"%Z%%M%	%I%	%E% SMI"
315184Sek110237 
325184Sek110237 #include "config.h"
335184Sek110237 
345184Sek110237 #include <stdio.h>
355184Sek110237 #include <stdlib.h>
365184Sek110237 #include <unistd.h>
375184Sek110237 #include <sys/stat.h>
385184Sek110237 #include <sys/types.h>
395184Sek110237 #include <sys/param.h>
405184Sek110237 #include <sys/resource.h>
415184Sek110237 #include <pthread.h>
425184Sek110237 #ifndef HAVE_SYSV_SEM
435184Sek110237 #include <semaphore.h>
445184Sek110237 #endif
455184Sek110237 #include "stats.h"
465184Sek110237 #include "threadflow.h"
475184Sek110237 #include "vars.h"
485184Sek110237 #include "fileset.h"
495184Sek110237 #include "filebench.h"
505184Sek110237 
515184Sek110237 #ifdef	__cplusplus
525184Sek110237 extern "C" {
535184Sek110237 #endif
545184Sek110237 
555184Sek110237 typedef struct flowop {
565184Sek110237 	char		fo_name[128];	/* Name */
575184Sek110237 	int		fo_instance;	/* Instance number */
585184Sek110237 	struct flowop	*fo_next;	/* Next in global list */
595184Sek110237 	struct flowop	*fo_threadnext;	/* Next in thread's list */
605184Sek110237 	struct flowop	*fo_resultnext;	/* List of flowops in result */
615184Sek110237 	struct threadflow *fo_thread;	/* Backpointer to thread */
625184Sek110237 	int		(*fo_func)();	/* Method */
635184Sek110237 	int		(*fo_init)();	/* Init Method */
645184Sek110237 	void		(*fo_destruct)(); /* Destructor Method */
655184Sek110237 	int		fo_type;	/* Type */
665184Sek110237 	int		fo_attrs;	/* Flow op attribute */
675184Sek110237 	fileset_t	*fo_fileset;	/* Fileset for op */
685184Sek110237 	int		fo_fd;		/* File descriptor */
695184Sek110237 	int		fo_fdnumber;	/* User specified file descriptor */
705184Sek110237 	int		fo_srcfdnumber;	/* User specified src file descriptor */
715184Sek110237 	var_integer_t	fo_iosize;	/* Size of operation */
725184Sek110237 	var_integer_t	fo_wss;		/* Flow op working set size */
735184Sek110237 	char		fo_targetname[128]; /* Target, for wakeup etc... */
745184Sek110237 	struct flowop	*fo_targets;	/* List of targets matching name */
755184Sek110237 	struct flowop	*fo_targetnext;	/* List of targets matching name */
765184Sek110237 	var_integer_t	fo_iters;	/* Number of iterations of op */
775184Sek110237 	var_integer_t	fo_value;	/* Attr */
785184Sek110237 	var_integer_t	fo_sequential;	/* Attr */
795184Sek110237 	var_integer_t	fo_random;	/* Attr */
805184Sek110237 	var_integer_t	fo_stride;	/* Attr */
815184Sek110237 	var_integer_t	fo_backwards;	/* Attr */
825184Sek110237 	var_integer_t	fo_dsync;	/* Attr */
835184Sek110237 	var_integer_t	fo_blocking;	/* Attr */
845184Sek110237 	var_integer_t	fo_directio;	/* Attr */
855184Sek110237 	var_integer_t	fo_rotatefd;	/* Attr */
865184Sek110237 	flowstat_t	fo_stats;	/* Flow statistics */
875184Sek110237 	pthread_cond_t	fo_cv;		/* Block/wakeup cv */
885184Sek110237 	pthread_mutex_t	fo_lock;	/* Mutex around flowop */
895184Sek110237 	char		*fo_buf;	/* Per-flowop buffer */
905673Saw148015 	uint64_t	fo_buf_size;	/* current size of buffer */
915184Sek110237 #ifdef HAVE_SYSV_SEM
925184Sek110237 	int		fo_semid_lw;	/* sem id */
935184Sek110237 	int		fo_semid_hw;	/* sem id for highwater block */
945184Sek110237 #else
955184Sek110237 	sem_t		fo_sem;		/* sem_t for posix semaphores */
965184Sek110237 #endif /* HAVE_SYSV_SEM */
975184Sek110237 	var_integer_t	fo_highwater;	/* value of highwater paramter */
985184Sek110237 	void		*fo_idp;	/* id, for sems etc */
995184Sek110237 	hrtime_t	fo_timestamp;	/* for ratecontrol, etc... */
1005184Sek110237 	int		fo_initted;	/* Set to one if initialized */
1015184Sek110237 	int64_t		fo_tputbucket;	/* Throughput bucket, for limiter */
1025184Sek110237 	uint64_t	fo_tputlast;	/* Throughput count, for delta's */
1035184Sek110237 
1045184Sek110237 } flowop_t;
1055184Sek110237 
1065184Sek110237 /* Flow Op Attrs */
1075184Sek110237 #define	FLOW_ATTR_SEQUENTIAL	0x1
1085184Sek110237 #define	FLOW_ATTR_RANDOM	0x2
1095184Sek110237 #define	FLOW_ATTR_STRIDE	0x4
1105184Sek110237 #define	FLOW_ATTR_BACKWARDS	0x8
1115184Sek110237 #define	FLOW_ATTR_DSYNC		0x10
1125184Sek110237 #define	FLOW_ATTR_BLOCKING	0x20
1135184Sek110237 #define	FLOW_ATTR_DIRECTIO	0x40
1145184Sek110237 #define	FLOW_ATTR_READ		0x80
1155184Sek110237 #define	FLOW_ATTR_WRITE		0x100
1165184Sek110237 
1175184Sek110237 #define	FLOW_MASTER -1	    /* Declaration of thread from script */
1185184Sek110237 #define	FLOW_DEFINITION 0   /* Prototype definition of flowop from library */
1195184Sek110237 
1205184Sek110237 #define	FLOW_TYPES	5
1215184Sek110237 #define	FLOW_TYPE_GLOBAL	0  /* Rolled up statistics */
1225184Sek110237 #define	FLOW_TYPE_IO		1  /* Op is an I/O, reflected in iops and lat */
1235184Sek110237 #define	FLOW_TYPE_AIO		2  /* Op is an async I/O, reflected in iops */
1245184Sek110237 #define	FLOW_TYPE_SYNC		3  /* Op is a sync event */
1255184Sek110237 #define	FLOW_TYPE_OTHER		4  /* Op is a something else */
1265184Sek110237 
1275184Sek110237 extern flowstat_t controlstats;
1285184Sek110237 
1295184Sek110237 void flowop_init(void);
1305184Sek110237 flowop_t *flowop_define(threadflow_t *, char *name, flowop_t *inherit,
1315184Sek110237     int instance, int type);
1325184Sek110237 flowop_t *flowop_find(char *name);
1335184Sek110237 flowop_t *flowop_find_one(char *name, int instance);
1345184Sek110237 void flowoplib_usage(void);
1355184Sek110237 void flowoplib_init(void);
1365184Sek110237 void flowop_delete_all(flowop_t **threadlist);
1375673Saw148015 void flowop_endop(threadflow_t *threadflow, flowop_t *flowop, int64_t bytes);
1385184Sek110237 void flowop_beginop(threadflow_t *threadflow, flowop_t *flowop);
139*6084Saw148015 void flowop_destruct_all_flows(threadflow_t *threadflow);
1405184Sek110237 
1415184Sek110237 #ifdef	__cplusplus
1425184Sek110237 }
1435184Sek110237 #endif
1445184Sek110237 
1455184Sek110237 #endif	/* _FB_FLOWOP_H */
146