xref: /onnv-gate/usr/src/cmd/filebench/common/fileset.h (revision 6212:d9dcad6dd79c)
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*6212Saw148015  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
235184Sek110237  * Use is subject to license terms.
245184Sek110237  */
255184Sek110237 
265184Sek110237 #ifndef _FB_FILESET_H
275184Sek110237 #define	_FB_FILESET_H
285184Sek110237 
295184Sek110237 #pragma ident	"%Z%%M%	%I%	%E% SMI"
305184Sek110237 
315184Sek110237 #include "config.h"
325184Sek110237 
335184Sek110237 #ifndef HAVE_OFF64_T
345184Sek110237 /*
355184Sek110237  * We are probably on linux.
365184Sek110237  * According to http://www.suse.de/~aj/linux_lfs.html, defining the
375184Sek110237  * above, automatically changes type of off_t to off64_t. so let
385184Sek110237  * us use only off_t as off64_t is not defined
395184Sek110237  */
405184Sek110237 #define	off64_t off_t
415184Sek110237 #endif /* HAVE_OFF64_T */
425184Sek110237 
435184Sek110237 
445184Sek110237 #include <stdio.h>
455184Sek110237 #include <stdlib.h>
465184Sek110237 #include <unistd.h>
475184Sek110237 #include <sys/stat.h>
485184Sek110237 #include <sys/types.h>
495184Sek110237 #include <sys/param.h>
505184Sek110237 #include <sys/resource.h>
515184Sek110237 #include <pthread.h>
525184Sek110237 
535673Saw148015 #include "vars.h"
545673Saw148015 #define	FILE_ALLOC_BLOCK (off64_t)(1024 * 1024)
555184Sek110237 
565184Sek110237 #ifdef	__cplusplus
575184Sek110237 extern "C" {
585184Sek110237 #endif
595184Sek110237 
605184Sek110237 #define	FSE_MAXTID 16384
615184Sek110237 
625184Sek110237 #define	FSE_MAXPATHLEN 16
635673Saw148015 #define	FSE_DIR		0x01
645673Saw148015 #define	FSE_FREE	0x02
655673Saw148015 #define	FSE_EXISTS	0x04
665673Saw148015 #define	FSE_BUSY	0x08
675673Saw148015 #define	FSE_REUSING	0x10
685184Sek110237 
695184Sek110237 typedef struct filesetentry {
705184Sek110237 	struct filesetentry	*fse_next;
715184Sek110237 	struct filesetentry	*fse_parent;
725184Sek110237 	struct filesetentry	*fse_filenext;	/* List of files */
735184Sek110237 	struct filesetentry	*fse_dirnext;	/* List of directories */
745184Sek110237 	struct fileset		*fse_fileset;	/* Parent fileset */
755184Sek110237 	pthread_mutex_t		fse_lock;
765184Sek110237 	char			*fse_path;
775184Sek110237 	int			fse_depth;
785184Sek110237 	off64_t			fse_size;
795184Sek110237 	int			fse_flags;
805184Sek110237 } filesetentry_t;
815184Sek110237 
825184Sek110237 #define	FILESET_PICKANY	    0x1 /* Pick any file from the set */
835184Sek110237 #define	FILESET_PICKUNIQUE  0x2 /* Pick a unique file from set until empty */
845184Sek110237 #define	FILESET_PICKRESET   0x4 /* Reset FILESET_PICKUNIQUE selection list */
855184Sek110237 #define	FILESET_PICKDIR	    0x8 /* Pick a directory */
865184Sek110237 #define	FILESET_PICKEXISTS  0x10 /* Pick an existing file */
875184Sek110237 #define	FILESET_PICKNOEXIST 0x20 /* Pick a file that doesn't exist */
885184Sek110237 
895673Saw148015 /* fileset attributes */
905673Saw148015 #define	FILESET_IS_RAW_DEV  0x01 /* fileset is a raw device */
915673Saw148015 #define	FILESET_IS_FILE	    0x02 /* Fileset is emulating a single file */
925673Saw148015 
935184Sek110237 typedef struct fileset {
945184Sek110237 	struct fileset	*fs_next;	/* Next in list */
95*6212Saw148015 	avd_t		fs_name;	/* Name */
96*6212Saw148015 	avd_t		fs_path;	/* Pathname prefix in fileset */
97*6212Saw148015 	avd_t		fs_entries;	/* Number of entries attr */
98*6212Saw148015 					/* (possibly random) */
99*6212Saw148015 	fbint_t		fs_constentries; /* Constant version of enties attr */
100*6212Saw148015 	avd_t		fs_preallocpercent; /* Prealloc size */
1015184Sek110237 	int		fs_attrs;	/* Attributes */
102*6212Saw148015 	avd_t		fs_dirwidth;	/* Explicit or mean for distribution */
103*6212Saw148015 	avd_t		fs_dirdepthrv;	/* random variable for dir depth */
104*6212Saw148015 	avd_t		fs_size;	/* Explicit or mean for distribution */
105*6212Saw148015 	avd_t		fs_dirgamma;	/* Dirdepth Gamma distribution */
106*6212Saw148015 					/* (* 1000) defaults to 1500, set */
107*6212Saw148015 					/* to 0 for explicit depth */
108*6212Saw148015 	avd_t		fs_sizegamma;	/* Filesize and dirwidth Gamma */
109*6212Saw148015 					/* distribution (* 1000), default */
110*6212Saw148015 					/* is 1500, set to 0 for explicit */
111*6212Saw148015 	avd_t		fs_create;	/* Attr */
112*6212Saw148015 	avd_t		fs_prealloc;	/* Attr */
113*6212Saw148015 	avd_t		fs_paralloc;	/* Attr */
114*6212Saw148015 	avd_t		fs_cached;	/* Attr */
115*6212Saw148015 	avd_t		fs_reuse;	/* Attr */
1165184Sek110237 	double		fs_meandepth;	/* Computed mean depth */
1175184Sek110237 	double		fs_meanwidth;	/* Specified mean dir width */
1185184Sek110237 	double		fs_meansize;	/* Specified mean file size */
1195184Sek110237 	int		fs_realfiles;	/* Actual files */
120*6212Saw148015 	off64_t		fs_bytes;	/* Total space consumed by files */
1215184Sek110237 	filesetentry_t	*fs_filelist;	/* List of files */
1225184Sek110237 	filesetentry_t	*fs_dirlist;	/* List of directories */
1235184Sek110237 	filesetentry_t	*fs_filefree;	/* Ptr to next free file */
1245184Sek110237 	filesetentry_t	*fs_dirfree;	/* Ptr to next free directory */
125*6212Saw148015 	filesetentry_t	*fs_filerotor[FSE_MAXTID];	/* next file to */
126*6212Saw148015 							/* select */
1275184Sek110237 	filesetentry_t	*fs_dirrotor;	/* Ptr to next directory to select */
1285184Sek110237 } fileset_t;
1295184Sek110237 
1305184Sek110237 int fileset_createset(fileset_t *);
1315184Sek110237 int fileset_openfile(fileset_t *fileset, filesetentry_t *entry,
1325184Sek110237     int flag, int mode, int attrs);
133*6212Saw148015 fileset_t *fileset_define(avd_t);
1345184Sek110237 fileset_t *fileset_find(char *name);
1355184Sek110237 filesetentry_t *fileset_pick(fileset_t *fileset, int flags, int tid);
1365184Sek110237 char *fileset_resolvepath(filesetentry_t *entry);
1375184Sek110237 void fileset_usage(void);
1385673Saw148015 void fileset_iter(int (*cmd)(fileset_t *fileset, int first));
1395673Saw148015 int fileset_print(fileset_t *fileset, int first);
1405673Saw148015 int fileset_checkraw(fileset_t *fileset);
1415673Saw148015 
1425184Sek110237 
1435184Sek110237 #ifdef	__cplusplus
1445184Sek110237 }
1455184Sek110237 #endif
1465184Sek110237 
1475184Sek110237 #endif	/* _FB_FILESET_H */
148