Home | History | Annotate | Download | only in common
      1  5184  ek110237 /*
      2  5184  ek110237  * CDDL HEADER START
      3  5184  ek110237  *
      4  5184  ek110237  * The contents of this file are subject to the terms of the
      5  5184  ek110237  * Common Development and Distribution License (the "License").
      6  5184  ek110237  * You may not use this file except in compliance with the License.
      7  5184  ek110237  *
      8  5184  ek110237  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  5184  ek110237  * or http://www.opensolaris.org/os/licensing.
     10  5184  ek110237  * See the License for the specific language governing permissions
     11  5184  ek110237  * and limitations under the License.
     12  5184  ek110237  *
     13  5184  ek110237  * When distributing Covered Code, include this CDDL HEADER in each
     14  5184  ek110237  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  5184  ek110237  * If applicable, add the following below this CDDL HEADER, with the
     16  5184  ek110237  * fields enclosed by brackets "[]" replaced with your own identifying
     17  5184  ek110237  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  5184  ek110237  *
     19  5184  ek110237  * CDDL HEADER END
     20  5184  ek110237  */
     21  5184  ek110237 /*
     22  8615    Andrew  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     23  5184  ek110237  * Use is subject to license terms.
     24  5184  ek110237  */
     25  5184  ek110237 
     26  5184  ek110237 #ifndef	_FB_FLOWOP_H
     27  5184  ek110237 #define	_FB_FLOWOP_H
     28  5184  ek110237 
     29  5184  ek110237 #include "config.h"
     30  5184  ek110237 
     31  5184  ek110237 #include <stdio.h>
     32  5184  ek110237 #include <stdlib.h>
     33  5184  ek110237 #include <unistd.h>
     34  5184  ek110237 #include <sys/stat.h>
     35  5184  ek110237 #include <sys/types.h>
     36  5184  ek110237 #include <sys/param.h>
     37  5184  ek110237 #include <sys/resource.h>
     38  5184  ek110237 #include <pthread.h>
     39  5184  ek110237 #ifndef HAVE_SYSV_SEM
     40  5184  ek110237 #include <semaphore.h>
     41  5184  ek110237 #endif
     42  5184  ek110237 #include "stats.h"
     43  5184  ek110237 #include "threadflow.h"
     44  5184  ek110237 #include "vars.h"
     45  5184  ek110237 #include "fileset.h"
     46  5184  ek110237 #include "filebench.h"
     47  8615    Andrew #include "fsplug.h"
     48  5184  ek110237 
     49  5184  ek110237 #ifdef	__cplusplus
     50  5184  ek110237 extern "C" {
     51  5184  ek110237 #endif
     52  5184  ek110237 
     53  5184  ek110237 typedef struct flowop {
     54  5184  ek110237 	char		fo_name[128];	/* Name */
     55  5184  ek110237 	int		fo_instance;	/* Instance number */
     56  5184  ek110237 	struct flowop	*fo_next;	/* Next in global list */
     57  6550  aw148015 	struct flowop	*fo_exec_next;	/* Next in thread's or compfo's list */
     58  5184  ek110237 	struct flowop	*fo_resultnext;	/* List of flowops in result */
     59  6550  aw148015 	struct flowop	*fo_comp_fops;	/* List of flowops in composite fo */
     60  6550  aw148015 	var_t		*fo_lvar_list;	/* List of composite local vars */
     61  5184  ek110237 	struct threadflow *fo_thread;	/* Backpointer to thread */
     62  5184  ek110237 	int		(*fo_func)();	/* Method */
     63  5184  ek110237 	int		(*fo_init)();	/* Init Method */
     64  5184  ek110237 	void		(*fo_destruct)(); /* Destructor Method */
     65  5184  ek110237 	int		fo_type;	/* Type */
     66  5184  ek110237 	int		fo_attrs;	/* Flow op attribute */
     67  6212  aw148015 	avd_t		fo_filename;	/* file/fileset name */
     68  5184  ek110237 	fileset_t	*fo_fileset;	/* Fileset for op */
     69  5184  ek110237 	int		fo_fd;		/* File descriptor */
     70  5184  ek110237 	int		fo_fdnumber;	/* User specified file descriptor */
     71  5184  ek110237 	int		fo_srcfdnumber;	/* User specified src file descriptor */
     72  6212  aw148015 	fbint_t		fo_constvalue;	/* constant version of fo_value */
     73  6212  aw148015 	fbint_t		fo_constwss;	/* constant version of fo_wss */
     74  6212  aw148015 	avd_t		fo_iosize;	/* Size of operation */
     75  6212  aw148015 	avd_t		fo_wss;		/* Flow op working set size */
     76  5184  ek110237 	char		fo_targetname[128]; /* Target, for wakeup etc... */
     77  5184  ek110237 	struct flowop	*fo_targets;	/* List of targets matching name */
     78  5184  ek110237 	struct flowop	*fo_targetnext;	/* List of targets matching name */
     79  6212  aw148015 	avd_t		fo_iters;	/* Number of iterations of op */
     80  6212  aw148015 	avd_t		fo_value;	/* Attr */
     81  6212  aw148015 	avd_t		fo_sequential;	/* Attr */
     82  6212  aw148015 	avd_t		fo_random;	/* Attr */
     83  6212  aw148015 	avd_t		fo_stride;	/* Attr */
     84  6212  aw148015 	avd_t		fo_backwards;	/* Attr */
     85  6212  aw148015 	avd_t		fo_dsync;	/* Attr */
     86  6212  aw148015 	avd_t		fo_blocking;	/* Attr */
     87  6212  aw148015 	avd_t		fo_directio;	/* Attr */
     88  6212  aw148015 	avd_t		fo_rotatefd;	/* Attr */
     89  8404    Andrew 	avd_t		fo_fileindex;	/* Attr */
     90  5184  ek110237 	flowstat_t	fo_stats;	/* Flow statistics */
     91  5184  ek110237 	pthread_cond_t	fo_cv;		/* Block/wakeup cv */
     92  5184  ek110237 	pthread_mutex_t	fo_lock;	/* Mutex around flowop */
     93  6212  aw148015 	void		*fo_private;	/* Flowop private scratch pad area */
     94  5184  ek110237 	char		*fo_buf;	/* Per-flowop buffer */
     95  5673  aw148015 	uint64_t	fo_buf_size;	/* current size of buffer */
     96  5184  ek110237 #ifdef HAVE_SYSV_SEM
     97  5184  ek110237 	int		fo_semid_lw;	/* sem id */
     98  5184  ek110237 	int		fo_semid_hw;	/* sem id for highwater block */
     99  5184  ek110237 #else
    100  5184  ek110237 	sem_t		fo_sem;		/* sem_t for posix semaphores */
    101  5184  ek110237 #endif /* HAVE_SYSV_SEM */
    102  6212  aw148015 	avd_t		fo_highwater;	/* value of highwater paramter */
    103  5184  ek110237 	void		*fo_idp;	/* id, for sems etc */
    104  5184  ek110237 	hrtime_t	fo_timestamp;	/* for ratecontrol, etc... */
    105  5184  ek110237 	int		fo_initted;	/* Set to one if initialized */
    106  5184  ek110237 	int64_t		fo_tputbucket;	/* Throughput bucket, for limiter */
    107  5184  ek110237 	uint64_t	fo_tputlast;	/* Throughput count, for delta's */
    108  5184  ek110237 
    109  5184  ek110237 } flowop_t;
    110  5184  ek110237 
    111  5184  ek110237 /* Flow Op Attrs */
    112  5184  ek110237 #define	FLOW_ATTR_SEQUENTIAL	0x1
    113  5184  ek110237 #define	FLOW_ATTR_RANDOM	0x2
    114  5184  ek110237 #define	FLOW_ATTR_STRIDE	0x4
    115  5184  ek110237 #define	FLOW_ATTR_BACKWARDS	0x8
    116  5184  ek110237 #define	FLOW_ATTR_DSYNC		0x10
    117  5184  ek110237 #define	FLOW_ATTR_BLOCKING	0x20
    118  5184  ek110237 #define	FLOW_ATTR_DIRECTIO	0x40
    119  5184  ek110237 #define	FLOW_ATTR_READ		0x80
    120  5184  ek110237 #define	FLOW_ATTR_WRITE		0x100
    121  5184  ek110237 
    122  6550  aw148015 /* Flowop Instance Numbers */
    123  6550  aw148015 			    /* Worker flowops have instance numbers > 0 */
    124  5184  ek110237 #define	FLOW_DEFINITION 0   /* Prototype definition of flowop from library */
    125  6550  aw148015 #define	FLOW_INNER_DEF -1   /* Constructed proto flowops within composite */
    126  6550  aw148015 #define	FLOW_MASTER -2	    /* Master flowop based on flowop declaration */
    127  6550  aw148015 			    /* supplied within a thread definition */
    128  5184  ek110237 
    129  6550  aw148015 /* Flowop type definitions */
    130  6550  aw148015 
    131  6550  aw148015 #define	FLOW_TYPES	6
    132  5184  ek110237 #define	FLOW_TYPE_GLOBAL	0  /* Rolled up statistics */
    133  5184  ek110237 #define	FLOW_TYPE_IO		1  /* Op is an I/O, reflected in iops and lat */
    134  5184  ek110237 #define	FLOW_TYPE_AIO		2  /* Op is an async I/O, reflected in iops */
    135  5184  ek110237 #define	FLOW_TYPE_SYNC		3  /* Op is a sync event */
    136  6550  aw148015 #define	FLOW_TYPE_COMPOSITE	4  /* Op is a composite flowop */
    137  6550  aw148015 #define	FLOW_TYPE_OTHER		5  /* Op is a something else */
    138  5184  ek110237 
    139  8615    Andrew typedef struct flowop_proto {
    140  8615    Andrew 	int	fl_type;
    141  8615    Andrew 	int	fl_attrs;
    142  8615    Andrew 	char	*fl_name;
    143  8615    Andrew 	int	(*fl_init)();
    144  8615    Andrew 	int	(*fl_func)();
    145  8615    Andrew 	void	(*fl_destruct)();
    146  8615    Andrew } flowop_proto_t;
    147  8615    Andrew 
    148  5184  ek110237 extern flowstat_t controlstats;
    149  6212  aw148015 extern pthread_mutex_t controlstats_lock;
    150  5184  ek110237 
    151  5184  ek110237 void flowop_init(void);
    152  8615    Andrew void flowop_plugin_flowinit(void);
    153  5184  ek110237 flowop_t *flowop_define(threadflow_t *, char *name, flowop_t *inherit,
    154  6550  aw148015     flowop_t **flowoplist_hdp, int instance, int type);
    155  5184  ek110237 flowop_t *flowop_find(char *name);
    156  5184  ek110237 flowop_t *flowop_find_one(char *name, int instance);
    157  6701  aw148015 flowop_t *flowop_find_from_list(char *name, flowop_t *list);
    158  8615    Andrew int flowop_init_generic(flowop_t *flowop);
    159  8615    Andrew void flowop_destruct_generic(flowop_t *flowop);
    160  8615    Andrew void flowop_flow_init(flowop_proto_t *list, int nops);
    161  5184  ek110237 void flowoplib_usage(void);
    162  8615    Andrew int flowoplib_iosetup(threadflow_t *threadflow, flowop_t *flowop,
    163  8615    Andrew     fbint_t *wssp, caddr_t *iobufp, fb_fdesc_t **filedescp, fbint_t iosize);
    164  5184  ek110237 void flowop_delete_all(flowop_t **threadlist);
    165  5673  aw148015 void flowop_endop(threadflow_t *threadflow, flowop_t *flowop, int64_t bytes);
    166  5184  ek110237 void flowop_beginop(threadflow_t *threadflow, flowop_t *flowop);
    167  6084  aw148015 void flowop_destruct_all_flows(threadflow_t *threadflow);
    168  6550  aw148015 flowop_t *flowop_new_composite_define(char *name);
    169  6212  aw148015 void flowop_printall(void);
    170  5184  ek110237 
    171  5184  ek110237 #ifdef	__cplusplus
    172  5184  ek110237 }
    173  5184  ek110237 #endif
    174  5184  ek110237 
    175  5184  ek110237 #endif	/* _FB_FLOWOP_H */
    176