1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. gethrtime(void)15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _FB_FILESET_H 27 #define _FB_FILESET_H 28 29 #include "filebench.h" 30 31 #define FILE_ALLOC_BLOCK (off64_t)(1024 * 1024) 32 33 #define FSE_MAXTID 16384 34 35 #define FSE_MAXPATHLEN 16 36 #define FSE_TYPE_FILE 0x00 37 #define FSE_TYPE_DIR 0x01 38 #define FSE_TYPE_LEAFDIR 0x02 39 #define FSE_TYPE_MASK 0x03 40 #define FSE_FREE 0x04 41 #define FSE_EXISTS 0x08 42 #define FSE_BUSY 0x10 43 #define FSE_REUSING 0x20 44 #define FSE_THRD_WAITNG 0x40 45 46 typedef struct filesetentry { 47 struct filesetentry *fse_next; /* master list of entries */ 48 struct filesetentry *fse_parent; /* link to directory */ 49 avl_node_t fse_link; /* links in avl btree, prot. */ 50 /* by fs_pick_lock */ 51 uint_t fse_index; /* file order number */ 52 struct filesetentry *fse_nextoftype; /* List of specific fse */ 53 struct fileset *fse_fileset; /* Parent fileset */ 54 char *fse_path; 55 int fse_depth; 56 off64_t fse_size; 57 int fse_open_cnt; /* protected by fs_pick_lock */ 58 int fse_flags; /* protected by fs_pick_lock */ 59 } filesetentry_t; 60 61 #define FSE_OFFSETOF(f) ((size_t)(&(((filesetentry_t *)0)->f))) 62 63 /* type of fileset entry to obtain */ 64 #define FILESET_PICKFILE 0x00 /* Pick a file from the set */ 65 #define FILESET_PICKDIR 0x01 /* Pick a directory */ 66 #define FILESET_PICKLEAFDIR 0x02 /* Pick a leaf directory */ 67 #define FILESET_PICKMASK 0x03 /* Pick type mask */ 68 /* other pick flags */ 69 #define FILESET_PICKUNIQUE 0x04 /* Pick a unique file or leafdir from the */ 70 /* fileset until empty */ 71 #define FILESET_PICKEXISTS 0x10 /* Pick an existing file */ 72 #define FILESET_PICKNOEXIST 0x20 /* Pick a file that doesn't exist */ 73 #define FILESET_PICKBYINDEX 0x40 /* use supplied index number to select file */ 74 #define FILESET_PICKFREE FILESET_PICKUNIQUE 75 76 /* fileset attributes */ 77 #define FILESET_IS_RAW_DEV 0x01 /* fileset is a raw device */ 78 #define FILESET_IS_FILE 0x02 /* Fileset is emulating a single file */ 79 80 typedef struct fileset { 81 struct fileset *fs_next; /* Next in list */ 82 avd_t fs_name; /* Name */ 83 avd_t fs_path; /* Pathname prefix in fileset */ 84 avd_t fs_entries; /* Number of entries attr */ 85 /* (possibly random) */ 86 fbint_t fs_constentries; /* Constant version of enties attr */ 87 avd_t fs_leafdirs; /* Number of leaf directories attr */ 88 /* (possibly random) */ 89 fbint_t fs_constleafdirs; /* Constant version of leafdirs */ 90 /* attr */ 91 avd_t fs_preallocpercent; /* Prealloc size */ 92 int fs_attrs; /* Attributes */ 93 avd_t fs_dirwidth; /* Explicit or mean for distribution */ 94 avd_t fs_dirdepthrv; /* random variable for dir depth */ 95 avd_t fs_size; /* Explicit or mean for distribution */ 96 avd_t fs_dirgamma; /* Dirdepth Gamma distribution */ 97 /* (* 1000) defaults to 1500, set */ 98 /* to 0 for explicit depth */ 99 avd_t fs_create; /* Attr */ 100 avd_t fs_paralloc; /* Attr */ 101 avd_t fs_reuse; /* Attr */ 102 avd_t fs_readonly; /* Attr */ 103 avd_t fs_writeonly; /* Attr */ 104 avd_t fs_trust_tree; /* Attr */ 105 double fs_meandepth; /* Computed mean depth */ 106 double fs_meanwidth; /* Specified mean dir width */ 107 int fs_realfiles; /* Actual files */ 108 int fs_realleafdirs; /* Actual explicit leaf directories */ 109 off64_t fs_bytes; /* Total space consumed by files */ 110 111 int64_t fs_idle_files; /* number of files NOT busy */ 112 pthread_cond_t fs_idle_files_cv; /* idle files condition variable */ 113 114 int64_t fs_idle_dirs; /* number of dirs NOT busy */ 115 pthread_cond_t fs_idle_dirs_cv; /* idle dirs condition variable */ 116 117 int64_t fs_idle_leafdirs; /* number of dirs NOT busy */ 118 pthread_cond_t fs_idle_leafdirs_cv; /* idle dirs condition variable */ 119 120 pthread_mutex_t fs_pick_lock; /* per fileset "pick" function lock */ 121 pthread_cond_t fs_thrd_wait_cv; /* per fileset file busy wait cv */ 122 avl_tree_t fs_free_files; /* btree of free files */ 123 avl_tree_t fs_exist_files; /* btree of files on device */ 124 avl_tree_t fs_noex_files; /* btree of files NOT on device */ 125 avl_tree_t fs_dirs; /* btree of internal dirs */ 126 avl_tree_t fs_free_leaf_dirs; /* btree of free leaf dirs */ 127 avl_tree_t fs_exist_leaf_dirs; /* btree of leaf dirs on device */ 128 avl_tree_t fs_noex_leaf_dirs; /* btree of leaf dirs NOT */ 129 /* currently on device */ 130 filesetentry_t *fs_filelist; /* List of files */ 131 uint_t fs_file_exrotor[FSE_MAXTID]; /* next file to */ 132 /* select */ 133 uint_t fs_file_nerotor; /* next non existent file */ 134 /* to select for createfile */ 135 filesetentry_t *fs_dirlist; /* List of directories */ 136 uint_t fs_dirrotor; /* index of next directory to select */ 137 filesetentry_t *fs_leafdirlist; /* List of leaf directories */ 138 uint_t fs_leafdir_exrotor; /* Ptr to next existing leaf */ 139 /* directory to select */ 140 uint_t fs_leafdir_nerotor; /* Ptr to next non-existing */ 141 int *fs_filehistop; /* Ptr to access histogram */ 142 pthread_mutex_t fs_histo_lock; /* lock for incr of histo */ 143 } fileset_t; 144 145 int fileset_createsets(); 146 147 void fileset_delete_all_filesets(void); 148 int fileset_openfile(fb_fdesc_t *fd, fileset_t *fileset, 149 filesetentry_t *entry, int flag, int mode, int attrs); 150 fileset_t *fileset_define(avd_t name, avd_t path); 151 fileset_t *fileset_find(char *name); 152 filesetentry_t *fileset_pick(fileset_t *fileset, int flags, int tid, 153 int index); 154 char *fileset_resolvepath(filesetentry_t *entry); 155 int fileset_iter(int (*cmd)(fileset_t *fileset, int first)); 156 int fileset_print(fileset_t *fileset, int first); 157 void fileset_unbusy(filesetentry_t *entry, int update_exist, 158 int new_exist_val, int open_cnt_incr); 159 int fileset_dump_histo(fileset_t *fileset, int first); 160 void fileset_attach_all_histos(void); 161 162 #endif /* _FB_FILESET_H */ 163