Add proper per-file copyright notices/licenses and top-level license.
[bluesky.git] / TBBT / trace_play / sfs_c_dat.c
1 #ifndef lint
2 static char sfs_c_datSid[] = "@(#)sfs_c_dat.c   2.1     97/10/23";
3 #endif
4
5 /*
6  *   Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
7  *      All rights reserved.
8  *              Standard Performance Evaluation Corporation (SPEC)
9  *              6585 Merchant Place, Suite 100
10  *              Warrenton, VA 20187
11  *
12  *      This product contains benchmarks acquired from several sources who
13  *      understand and agree with SPEC's goal of creating fair and objective
14  *      benchmarks to measure computer performance.
15  *
16  *      This copyright notice is placed here only to protect SPEC in the
17  *      event the source is misused in any manner that is contrary to the
18  *      spirit, the goals and the intent of SPEC.
19  *
20  *      The source code is provided to the user or company under the license
21  *      agreement for the SPEC Benchmark Suite for this product.
22  */
23
24 /*****************************************************************
25  *                                                               *
26  *      Copyright 1991,1992  Legato Systems, Inc.                *
27  *      Copyright 1991,1992  Auspex Systems, Inc.                *
28  *      Copyright 1991,1992  Data General Corporation            *
29  *      Copyright 1991,1992  Digital Equipment Corporation       *
30  *      Copyright 1991,1992  Interphase Corporation              *
31  *      Copyright 1991,1992  Sun Microsystems, Inc.              *
32  *                                                               *
33  *****************************************************************/
34
35 /*
36  *
37  * ------------------------- sfs_c_dat.c --------------------------
38  *
39  *      Space declarations for sfs.
40  *
41  *.Revision_History
42  *      11-Jul-94       ChakChung Ng    Add codes for NFS/v3
43  *      24-Aug-92       Wittle          New file set access.
44  *      05-Jan-92       Pawlowski       Added hooks for raw data dump.
45  *      04-Dec-91       Bruce Keith     Include string.h for SYSV/SVR4.
46  *      17-May-90       Richard Bean    Created.
47  */
48
49
50 /*
51  * -------------------------  Include Files  -------------------------
52  */
53
54 /*
55  * ANSI C headers
56  */
57 #include <stdio.h>
58 #include <stdlib.h>
59 #include <string.h>
60 #include <errno.h>
61  
62 #include <sys/types.h>
63 #include <sys/stat.h> 
64
65 #include <unistd.h>
66
67 #include "sfs_c_def.h"
68 #include "sfs_m_def.h"
69
70
71 /*
72  * -------------------------  NFS Operations  -------------------------
73  */
74
75 /*
76  * RPC timeout values by call type.
77  * Index'ed by #defines in sfs_def.h.
78  */
79 struct timeval *Nfs_timers;
80
81 struct timeval Nfs_udp_timers[] = {
82
83         /* secs  usecs */
84         {  10,    0 },          /* All commands during initialization phase */
85         {   1,    0 },          /* Lookup during warmup and test run phases */
86         {   2,    0 },          /* Read during warmup and test run phases */
87         {   3,    0 },          /* Write during warmup and test run phases */
88 };
89
90 /*
91  * TCP is a "reliable" protocol so timeouts should never occur.  Set
92  * the values to be large enough to ensure all servers will respond
93  * but not too large so a broken implementation will still complete.
94  */
95 struct timeval Nfs_tcp_timers[] = {
96
97         /* secs  usecs */
98         {  60,    0 },          /* All commands during initialization phase */
99         {  60,    0 },          /* Lookup during warmup and test run phases */
100         {  60,    0 },          /* Read during warmup and test run phases */
101         {  60,    0 },          /* Write during warmup and test run phases */
102 };
103
104 /*
105  * -----------------------  Transfer Size Distribution  -----------------------
106  *
107  * Over-the-wire transfer sizes are divided into 2 cases: read and write.
108  * For each case, a percentile rank determines the basic size unit of the
109  * transfer which is multiplied by a count to give the total size for the
110  * percentile.
111  *
112  * The block transfer size distribution is specified by a table of values.
113  * The first column gives the percent of operations that will be a
114  * specific block transfer size.  The second column gives the number of
115  * blocks units that will be transferred.  Normally the block unit size
116  * is 8KB.  The third column is a boolean specifying whether a trailing
117  * fragment block should be transferred.  The fragment size for each transfer
118  * is a random multiple of 1 KB, up to the block size - 1 KB.  Two tables
119  * are needed, one for read operation and one for write operations.  The
120  * following table gives the default distributions.
121  *
122  *      Read  - Default Block Transfer Size Distribution Table
123  * percent   block count   fragment     resulting transfer (8KB block size)
124  * -------   -----------   --------     -----------------------------------
125  *    0        0             0           0%    1 -   7 KB
126  *   85        1             0          85%    9 -  15 KB
127  *    8        2             1           8%   17 -  23 KB
128  *    4        4             1           4%   33 -  39 KB
129  *    2        8             1           2%   65 -  71 KB
130  *    1       16             1           1%  129 - 135 KB
131  *
132  *      Write  - Default Block Transfer Size Distribution Table
133  * percent   block count   fragment     resulting transfer (8KB block size)
134  * -------   -----------   --------     -----------------------------------
135  *   49        0             1          49%    1 -   7 KB
136  *   36        1             1          36%    9 -  15 KB
137  *    8        2             1           8%   17 -  23 KB
138  *    4        4             1           4%   33 -  39 KB
139  *    2        8             1           2%   65 -  71 KB
140  *    1       16             1           1%  129 - 135 KB
141  *
142  * The user may specify a a different distribution by using the '-b' option.
143  * The format for the block size distribution file consists of the first
144  * three columns given above: percent, block count, and fragment.  Read
145  * and write distribution tables are identified by the keywords "Read" and
146  * "Write".  An example input file, using the default values, is given below:
147  *
148  *              Read
149  *               0  0  0
150  *              85  1  0
151  *               8  2  1
152  *               4  4  1
153  *               2  8  1
154  *               1 16  1
155  *              Write
156  *              49  0  1
157  *              36  1  1
158  *               8  2  1
159  *               4  4  1
160  *               2  8  1
161  *               1 16  1
162  *
163  * A second parameter controlled by the block transfer size distribution table
164  * is the network transport packet size.  The distribution tables define the
165  * relative proportion of full blocks packets to fragment packets.  For
166  * instance, the default tables have been constructed to produce a specific
167  * distribution of ethernet packet sizes for i/o operations by controlling
168  * the amount of data in each packet.  The write packets produced consist
169  * of 50% 8-KB packets, and 50% 1-7 KB packets.  The read packets consist
170  * of 85% 8-KB packets, and 15% 1-7 KB packets.  These figures are
171  * determined by multiplying the percentage for the type of transfer by
172  * the number of blocks and fragments generated, and adding the totals.
173  * These conmputations are performed below for the default block size
174  * distribution tables:
175  *
176  *              Read            blocks          fragments
177  *               0  0  0          0               0
178  *              85  1  0         85               0
179  *               8  2  1         16               8
180  *               4  4  1         16               4
181  *               2  8  1         16               2
182  *               1 16  1         16               1
183  *                              ---             ---
184  *                              149 (90%)        15 (10%)
185  *
186  *              Write
187  *              49  0  1          0              49
188  *              36  1  1         36              36
189  *               8  2  1         16               8
190  *               4  4  1         16               4
191  *               2  8  1         16               2
192  *               1 16  1         16               1
193  *                              ---             ---
194  *                              100 (50%)       100 (50%)
195  *
196  *
197  */
198 static sfs_io_op_dist_type Default_read_size_dist[] = {
199         /* percentile   8KB xfers       fragments                       */
200         {        0,      0,             0 },    /*   0%    1 -   7 KB   */
201         {       85,      1,             0 },    /*  85%    8       KB   */
202         {       93,      2,             1 },    /*   8%   17 -  23 KB   */
203         {       97,      4,             1 },    /*   4%   33 -  39 KB   */
204         {       99,      8,             1 },    /*   2%   65 -  71 KB   */
205         {      100,     16,             1 },    /*   1%  129 - 135 KB   */
206 };
207
208 static sfs_io_op_dist_type Default_write_size_dist[] = {
209         /* percentile   8KB xfers       fragments                       */
210         {       49,      0,             1 },    /*  49%    1 -   7 KB   */
211         {       85,      1,             1 },    /*  36%    9 -  15 KB   */
212         {       93,      2,             1 },    /*   8%   17 -  23 KB   */
213         {       97,      4,             1 },    /*   4%   33 -  39 KB   */
214         {       99,      8,             1 },    /*   2%   65 -  71 KB   */
215         {      100,     16,             1 },    /*   1%  129 - 135 KB   */
216 };
217
218 static sfs_io_dist_type Default_io_dist = {
219         Default_read_size_dist,         /* read size distribution */
220         Default_write_size_dist,        /* write size distribution */
221         17,                             /* max file size in Block_size units */
222         1.64,                           /* average read ops / request */
223         2                               /* average write ops / request */
224 };
225
226 sfs_io_file_size_dist Default_file_size_dist[] = {
227         /* percentage   KB size */
228         {        33,      1},                   /* 33% */
229         {        54,      2},                   /* 21% */
230         {        67,      4},                   /* 13% */
231         {        77,      8},                   /* 10% */
232         {        85,     16},                   /*  8% */
233         {        90,     32},                   /*  5% */
234         {        94,     64},                   /*  4% */
235         {        97,    128},                   /*  3% */
236         {        99,    256},                   /*  2% */
237         {       100,   1024},                   /*  1% */
238         {         0,      0}
239 };
240
241 /*
242  * -------------------------  Remote File Information  -------------------------
243  */
244 int  Num_io_file_sizes;                 /* # of different size of files */
245 int  Num_io_files;                      /* # of files used for i/o */
246 int  Num_non_io_files;                  /* # of non-i/o regular files */
247 int  Num_dirs;                          /* # of pre-created directories */
248 int  Num_dir_files;                     /* # of directories */
249 int  Num_symlinks;                      /* # of pre-created symlinks */
250 int  Num_symlink_files;                 /* # of symlinks  */
251
252 int  Num_working_io_files;              /* # of i/o files in working set */
253 int  Num_working_non_io_files;          /* # of non i/o files in working set */
254 int  Num_working_dirs;                  /* # of dirs in working set */
255 int  Num_working_symlinks;              /* # of symlinks in working set */
256 int  files_per_megabyte;                /* # of files created of each MB */
257
258
259 sfs_io_dist_type *Io_dist_ptr=   /* block transfer distribution info */
260                         &Default_io_dist;
261
262 sfs_fh_type             *Io_files;      /* list of i/o files  */
263 sfs_fh_type             *Non_io_files;  /* list of non-i/o files */
264 sfs_fh_type             *Dirs;          /* list of directories */
265 sfs_fh_type             *Symlinks;      /* list of symlinks */
266
267 sfs_fh_type     *Cur_file_ptr;          /* current file */
268 char    Cur_filename[SFS_MAXNAMLEN];    /* current dir entry name */
269 char    Filespec[SFS_MAXNAMLEN] /* sprintf spec for file names */
270                      = "file_en.%05d";
271 char    Dirspec[SFS_MAXNAMLEN]  /* sprintf spec for directory names */
272                      = "dir_ent.%05d";
273 char    Symspec[SFS_MAXNAMLEN]  /* sprintf spec for symlink names */
274                      = "symlink.%05d";
275
276 /*
277  * -------------------------  Run Parameters -------------------------
278  */
279
280 int     nfs_version;
281 sfs_phase_type  Current_test_phase;     /* current phase of the test */
282
283 sfs_fh_type     Export_dir;                     /* filehandle for exported fs */
284 CLIENT *        NFS_client;                     /* RPC client handle */
285 CLIENT *        NFS_client_recv;        /* RPC client handle used for recv_thread */
286
287 bool_t  Timed_run = TRUE;                       /* Timed run or call target ? */
288 int     Runtime = DEFAULT_RUNTIME;              /* seconds in benchmark run */
289 int     Warmuptime = DEFAULT_WARMUP;            /* seconds to warmup */
290 int     Access_percent = DEFAULT_ACCESS;        /* % of file set to access */
291 int     Append_percent = DEFAULT_APPEND;        /* % of writes that append */
292 int     Fss_delta_percent = DEFAULT_DELTA_FSS;  /* allowed change to file set */
293 int     Kb_per_block = DEFAULT_KB_PER_BLOCK;    /* i/o pkt block sz in KB */
294 int     Bytes_per_block = DEFAULT_KB_PER_BLOCK * 1024;/* i/o pkt sz in bytes */
295 int     Num_failed_lookup = DEFAULT_FAILED_LOOKUP; /* percent failed lookups */
296 int     Testop = -1;                            /* test mode operation number */
297 int     Interactive = 0;                        /* test synchronized by user*/
298 int     Populate_only = 0;                      /* populate test dirs & quit */
299 int     Debug_level = 0xFFFF;                   /* debugging switch */
300
301
302 /*
303  * ---------------------  Biod Simulation Variables ---------------------
304  */
305
306 int     Biod_max_outstanding_writes = DEFAULT_BIOD_MAX_WRITE;
307 int     Biod_max_outstanding_reads = DEFAULT_BIOD_MAX_READ;
308
309
310 /*
311  * -------------------  File Set Size Control -------------------------
312  */
313
314 int     avg_bytes_per_file = 136*1024;  /* calculated average file size */
315 int     Base_fss_bytes = 0;             /* base file set size in bytes */
316 int     Most_fss_bytes = 0;             /* most bytes ever in file set */
317 int     Least_fss_bytes = 0;            /* least bytes ever in file set */
318 int     Limit_fss_bytes = 0;            /* target upper limit on fileset size */
319 int     Cur_fss_bytes = 0;              /* bytes currently in file set */
320 int     Total_fss_bytes = 0;            /* Total bytes created */
321
322
323 /*
324  * -------------  Per Child Load Generation Rate Variables  -----------
325  */
326
327 int     Msec_per_period;        /* total msec during the current run period */
328
329
330 /*
331  * -------------------------  Miscellaneous  -------------------------
332  */
333
334 struct ladtime  Cur_time;               /* current time of day */
335 struct ladtime  Starttime;              /* start of test */
336 int             start_run_phase = 0; 
337
338 char    lad_hostname[HOSTNAME_LEN];
339 /* sfs_c_dat.c */