xref: /onnv-gate/usr/src/cmd/filebench/common/flowop.h (revision 8615:fa52c2eca6c5)
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*8615SAndrew.W.Wilson@sun.com  * Copyright 2009 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 #include "config.h"
305184Sek110237 
315184Sek110237 #include <stdio.h>
325184Sek110237 #include <stdlib.h>
335184Sek110237 #include <unistd.h>
345184Sek110237 #include <sys/stat.h>
355184Sek110237 #include <sys/types.h>
365184Sek110237 #include <sys/param.h>
375184Sek110237 #include <sys/resource.h>
385184Sek110237 #include <pthread.h>
395184Sek110237 #ifndef HAVE_SYSV_SEM
405184Sek110237 #include <semaphore.h>
415184Sek110237 #endif
425184Sek110237 #include "stats.h"
435184Sek110237 #include "threadflow.h"
445184Sek110237 #include "vars.h"
455184Sek110237 #include "fileset.h"
465184Sek110237 #include "filebench.h"
47*8615SAndrew.W.Wilson@sun.com #include "fsplug.h"
485184Sek110237 
495184Sek110237 #ifdef	__cplusplus
505184Sek110237 extern "C" {
515184Sek110237 #endif
525184Sek110237 
535184Sek110237 typedef struct flowop {
545184Sek110237 	char		fo_name[128];	/* Name */
555184Sek110237 	int		fo_instance;	/* Instance number */
565184Sek110237 	struct flowop	*fo_next;	/* Next in global list */
576550Saw148015 	struct flowop	*fo_exec_next;	/* Next in thread's or compfo's list */
585184Sek110237 	struct flowop	*fo_resultnext;	/* List of flowops in result */
596550Saw148015 	struct flowop	*fo_comp_fops;	/* List of flowops in composite fo */
606550Saw148015 	var_t		*fo_lvar_list;	/* List of composite local vars */
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 */
676212Saw148015 	avd_t		fo_filename;	/* file/fileset name */
685184Sek110237 	fileset_t	*fo_fileset;	/* Fileset for op */
695184Sek110237 	int		fo_fd;		/* File descriptor */
705184Sek110237 	int		fo_fdnumber;	/* User specified file descriptor */
715184Sek110237 	int		fo_srcfdnumber;	/* User specified src file descriptor */
726212Saw148015 	fbint_t		fo_constvalue;	/* constant version of fo_value */
736212Saw148015 	fbint_t		fo_constwss;	/* constant version of fo_wss */
746212Saw148015 	avd_t		fo_iosize;	/* Size of operation */
756212Saw148015 	avd_t		fo_wss;		/* Flow op working set size */
765184Sek110237 	char		fo_targetname[128]; /* Target, for wakeup etc... */
775184Sek110237 	struct flowop	*fo_targets;	/* List of targets matching name */
785184Sek110237 	struct flowop	*fo_targetnext;	/* List of targets matching name */
796212Saw148015 	avd_t		fo_iters;	/* Number of iterations of op */
806212Saw148015 	avd_t		fo_value;	/* Attr */
816212Saw148015 	avd_t		fo_sequential;	/* Attr */
826212Saw148015 	avd_t		fo_random;	/* Attr */
836212Saw148015 	avd_t		fo_stride;	/* Attr */
846212Saw148015 	avd_t		fo_backwards;	/* Attr */
856212Saw148015 	avd_t		fo_dsync;	/* Attr */
866212Saw148015 	avd_t		fo_blocking;	/* Attr */
876212Saw148015 	avd_t		fo_directio;	/* Attr */
886212Saw148015 	avd_t		fo_rotatefd;	/* Attr */
898404SAndrew.W.Wilson@sun.com 	avd_t		fo_fileindex;	/* Attr */
905184Sek110237 	flowstat_t	fo_stats;	/* Flow statistics */
915184Sek110237 	pthread_cond_t	fo_cv;		/* Block/wakeup cv */
925184Sek110237 	pthread_mutex_t	fo_lock;	/* Mutex around flowop */
936212Saw148015 	void		*fo_private;	/* Flowop private scratch pad area */
945184Sek110237 	char		*fo_buf;	/* Per-flowop buffer */
955673Saw148015 	uint64_t	fo_buf_size;	/* current size of buffer */
965184Sek110237 #ifdef HAVE_SYSV_SEM
975184Sek110237 	int		fo_semid_lw;	/* sem id */
985184Sek110237 	int		fo_semid_hw;	/* sem id for highwater block */
995184Sek110237 #else
1005184Sek110237 	sem_t		fo_sem;		/* sem_t for posix semaphores */
1015184Sek110237 #endif /* HAVE_SYSV_SEM */
1026212Saw148015 	avd_t		fo_highwater;	/* value of highwater paramter */
1035184Sek110237 	void		*fo_idp;	/* id, for sems etc */
1045184Sek110237 	hrtime_t	fo_timestamp;	/* for ratecontrol, etc... */
1055184Sek110237 	int		fo_initted;	/* Set to one if initialized */
1065184Sek110237 	int64_t		fo_tputbucket;	/* Throughput bucket, for limiter */
1075184Sek110237 	uint64_t	fo_tputlast;	/* Throughput count, for delta's */
1085184Sek110237 
1095184Sek110237 } flowop_t;
1105184Sek110237 
1115184Sek110237 /* Flow Op Attrs */
1125184Sek110237 #define	FLOW_ATTR_SEQUENTIAL	0x1
1135184Sek110237 #define	FLOW_ATTR_RANDOM	0x2
1145184Sek110237 #define	FLOW_ATTR_STRIDE	0x4
1155184Sek110237 #define	FLOW_ATTR_BACKWARDS	0x8
1165184Sek110237 #define	FLOW_ATTR_DSYNC		0x10
1175184Sek110237 #define	FLOW_ATTR_BLOCKING	0x20
1185184Sek110237 #define	FLOW_ATTR_DIRECTIO	0x40
1195184Sek110237 #define	FLOW_ATTR_READ		0x80
1205184Sek110237 #define	FLOW_ATTR_WRITE		0x100
1215184Sek110237 
1226550Saw148015 /* Flowop Instance Numbers */
1236550Saw148015 			    /* Worker flowops have instance numbers > 0 */
1245184Sek110237 #define	FLOW_DEFINITION 0   /* Prototype definition of flowop from library */
1256550Saw148015 #define	FLOW_INNER_DEF -1   /* Constructed proto flowops within composite */
1266550Saw148015 #define	FLOW_MASTER -2	    /* Master flowop based on flowop declaration */
1276550Saw148015 			    /* supplied within a thread definition */
1285184Sek110237 
1296550Saw148015 /* Flowop type definitions */
1306550Saw148015 
1316550Saw148015 #define	FLOW_TYPES	6
1325184Sek110237 #define	FLOW_TYPE_GLOBAL	0  /* Rolled up statistics */
1335184Sek110237 #define	FLOW_TYPE_IO		1  /* Op is an I/O, reflected in iops and lat */
1345184Sek110237 #define	FLOW_TYPE_AIO		2  /* Op is an async I/O, reflected in iops */
1355184Sek110237 #define	FLOW_TYPE_SYNC		3  /* Op is a sync event */
1366550Saw148015 #define	FLOW_TYPE_COMPOSITE	4  /* Op is a composite flowop */
1376550Saw148015 #define	FLOW_TYPE_OTHER		5  /* Op is a something else */
1385184Sek110237 
139*8615SAndrew.W.Wilson@sun.com typedef struct flowop_proto {
140*8615SAndrew.W.Wilson@sun.com 	int	fl_type;
141*8615SAndrew.W.Wilson@sun.com 	int	fl_attrs;
142*8615SAndrew.W.Wilson@sun.com 	char	*fl_name;
143*8615SAndrew.W.Wilson@sun.com 	int	(*fl_init)();
144*8615SAndrew.W.Wilson@sun.com 	int	(*fl_func)();
145*8615SAndrew.W.Wilson@sun.com 	void	(*fl_destruct)();
146*8615SAndrew.W.Wilson@sun.com } flowop_proto_t;
147*8615SAndrew.W.Wilson@sun.com 
1485184Sek110237 extern flowstat_t controlstats;
1496212Saw148015 extern pthread_mutex_t controlstats_lock;
1505184Sek110237 
1515184Sek110237 void flowop_init(void);
152*8615SAndrew.W.Wilson@sun.com void flowop_plugin_flowinit(void);
1535184Sek110237 flowop_t *flowop_define(threadflow_t *, char *name, flowop_t *inherit,
1546550Saw148015     flowop_t **flowoplist_hdp, int instance, int type);
1555184Sek110237 flowop_t *flowop_find(char *name);
1565184Sek110237 flowop_t *flowop_find_one(char *name, int instance);
1576701Saw148015 flowop_t *flowop_find_from_list(char *name, flowop_t *list);
158*8615SAndrew.W.Wilson@sun.com int flowop_init_generic(flowop_t *flowop);
159*8615SAndrew.W.Wilson@sun.com void flowop_destruct_generic(flowop_t *flowop);
160*8615SAndrew.W.Wilson@sun.com void flowop_flow_init(flowop_proto_t *list, int nops);
1615184Sek110237 void flowoplib_usage(void);
162*8615SAndrew.W.Wilson@sun.com int flowoplib_iosetup(threadflow_t *threadflow, flowop_t *flowop,
163*8615SAndrew.W.Wilson@sun.com     fbint_t *wssp, caddr_t *iobufp, fb_fdesc_t **filedescp, fbint_t iosize);
1645184Sek110237 void flowop_delete_all(flowop_t **threadlist);
1655673Saw148015 void flowop_endop(threadflow_t *threadflow, flowop_t *flowop, int64_t bytes);
1665184Sek110237 void flowop_beginop(threadflow_t *threadflow, flowop_t *flowop);
1676084Saw148015 void flowop_destruct_all_flows(threadflow_t *threadflow);
1686550Saw148015 flowop_t *flowop_new_composite_define(char *name);
1696212Saw148015 void flowop_printall(void);
1705184Sek110237 
1715184Sek110237 #ifdef	__cplusplus
1725184Sek110237 }
1735184Sek110237 #endif
1745184Sek110237 
1755184Sek110237 #endif	/* _FB_FLOWOP_H */
176