6 * Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
8 * Standard Performance Evaluation Corporation (SPEC)
9 * 6585 Merchant Place, Suite 100
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.
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.
20 * The source code is provided to the user or company under the license
21 * agreement for the SPEC Benchmark Suite for this product.
24 /*****************************************************************
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. *
33 *****************************************************************/
36 * @(#)sfs_c_def.h 2.1 97/10/23
38 * -------------------------- sfs_c_def.h -----------------------
40 * Literals and types for the sfs program.
43 * Wittle 24-Aug-92 - New file set access code.
44 * Bruce Keith 04-Dec-91 - Fix SVR4 definitions for NGROUPS.
45 * - Include param.h/limits.h as
46 * appropriate (BSD/SVR4).
47 * - Use bcopy, bzero, bcmp for BSD;
48 * memcpy, memset, memcmp for SYSV.
49 * Richard Bean 17-May-90 Created.
56 #if !defined(_XOPEN_SOURCE)
58 * Some non-XOPEN_compilent systems are missing these definitions
60 #if !defined(SVR4) /* Assume BSD */
61 #include <sys/param.h>
63 #endif /* !_XOPEN_SOURCE */
68 #include <sys/select.h>
73 #if (defined (SVR4) || defined (AIX))
74 #include <netinet/in.h>
79 #define SFS_MIN_RES 100 /* 100 usec resolution */
80 #define SFS_MAXNAMLEN 128 /* max test file name length */
81 #define SFS_MAXPATHLEN 1024 /* max test path name length */
82 #define HOSTNAME_LEN 63 /* length of client's hostname */
84 #include "sfs_c_nfs.h"
86 /* -------------------------- Constants ----------------------- */
88 #define SFS_VERSION_DATE "11 July 2001"
89 #define SFS_VERSION_NUM "3.0"
94 #define CHILD_TO_DEBUG 0 /* per child debugging uses child 0 */
96 #define DEBUG_NEW_CODE (Debug_level & 0x00000001) /* 1 */
97 #define DEBUG_PARENT_GENERAL (Debug_level & 0x00000002) /* 2 */
98 #define DEBUG_PARENT_SIGNAL (Debug_level & 0x00000004) /* 3 */
99 #define DEBUG_CHILD_ERROR (Debug_level & 0x00000008) /* 4 */
100 #define DEBUG_CHILD_SIGNAL (Debug_level & 0x00000010) /* 5 */
101 #define DEBUG_CHILD_XPOINT (Debug_level & 0x00000020) /* 6 */
102 #define DEBUG_CHILD_GENERAL ((Debug_level & 0x00000040) && \
103 (Child_num == CHILD_TO_DEBUG)) /* 7 */
104 #define DEBUG_CHILD_OPS ((Debug_level & 0x00000080) && \
105 (Child_num == CHILD_TO_DEBUG)) /* 8 */
106 #define DEBUG_CHILD_FILES ((Debug_level & 0x00000100) && \
107 (Child_num == CHILD_TO_DEBUG)) /* 9 */
108 #define DEBUG_CHILD_RPC ((Debug_level & 0x00000200) && \
109 (Child_num == CHILD_TO_DEBUG)) /* 10 */
110 #define DEBUG_CHILD_TIMING ((Debug_level & 0x00000400) && \
111 (Child_num == CHILD_TO_DEBUG)) /* 11 */
112 #define DEBUG_CHILD_SETUP ((Debug_level & 0x00000800) && \
113 (Child_num == CHILD_TO_DEBUG)) /* 12 */
114 #define DEBUG_CHILD_FIT ((Debug_level & 0x00001000) && \
115 (Child_num == CHILD_TO_DEBUG)) /* 13 */
116 #define DEBUG_CHILD_BIOD ((Debug_level & 0x00002000) && \
117 (Child_num == CHILD_TO_DEBUG)) /* 14 */
121 * General constants for benchmark
123 #define DEFAULT_LOAD 60 /* calls per sec */
124 #define DEFAULT_CALLS 5000 /* number of calls */
125 #define DEFAULT_NPROCS 4 /* number of children to run */
126 #define DEFAULT_RUNTIME (5 * 60) /* runtime in seconds */
127 #define DEFAULT_WARMUP (5 * 60) /* warmup time in seconds */
128 #define DEFAULT_ACCESS 10 /* % of file set accessed */
129 #define DEFAULT_APPEND 70 /* % of writes that append */
130 #define DEFAULT_DELTA_FSS 10 /* % change to file set size */
131 #define DEFAULT_KB_PER_BLOCK 8 /* block xfer size in KB */
132 #define DEFAULT_BYTES_PER_OP (10*1024*1024) /* bytes per unit load */
133 #define DEFAULT_NFILES 100 /* # of regular NON-IO files */
134 #define DEFAULT_FILES_PER_DIR 30 /* # of files per directories */
135 #define DEFAULT_NSYMLINKS 20 /* # of symlinks */
136 #define DEFAULT_FAILED_LOOKUP 35 /* # of failed lookups */
138 #define DEFAULT_WARM_RATE_CHECK 2 /* check progress each 2 secs */
139 #define DEFAULT_RUN_RATE_CHECK 10 /* check progress each 10 sec */
140 #define DEFAULT_MAX_BUFSIZE NFS_MAXDATA /* max buffer size for i/o */
142 #define DEFAULT_BIOD_MAX_WRITE 2 /* max outstanding biod write */
143 #define DEFAULT_BIOD_MAX_READ 2 /* max outstanding biod reads */
148 * For now we only read a fixed number of files from a directory. Ideally
149 * we would like to read a random number from 0-MAX but we will need a new
152 #define SFS_MAXDIRENTS 128
155 * If you change the default Chi_Sqr value,
156 * then also change the field label in the results print out.
158 #define DEFAULT_CHI_SQR_CI CHI_SQR_95 /* chi-sqr value to use */
159 #define CHI_SQR_90 2.71 /* chi-sqr value for 90% CI */
160 #define CHI_SQR_95 3.84 /* chi-sqr value for 95% CI */
161 #define CHI_SQR_975 5.02 /* chi-sqr value for 97.5% CI */
162 #define CHI_SQR_99 6.63 /* chi-sqr value for 99% CI */
163 #define CHI_SQR_995 7.88 /* chi-sqr value for 99.5% CI */
166 * NFS operation numbers
191 #define READDIRPLUS 23
192 #define NOPS (READDIRPLUS+1) /* number of NFS ops */
193 #define TOTAL NOPS /* slot for totals */
196 * Constants for i/o distribution table
198 #define IO_DIST_START 0
199 #define IO_DIST_READ 1
200 #define IO_DIST_WRITE 2
203 * Ratio of non_io_files that are initialized
204 * NOTE: initializing half the non-i/o files works ok with the
205 * default op mix. If the mix is changed affecting the
206 * ratio of creations to removes, there may not be enough
207 * empty slots for file creation (or there may not be
208 * enough created during initialization to handle a lot of
209 * removes that occur early in the test run), and this would
210 * cause do_op() to fail to find a file appropriate for the
211 * chosen op. This will result in the global variable
212 * Ops[op].no_calls being incremented (turn on child level
213 * debugging to check this count), and the do_op() local
214 * variable aborted_ops to be incremented and checked during
215 * runtime for too many failures.
217 #define RATIO_NON_IO_INIT 0.5
220 *---------------------------- TCP stuff ---------------------
223 #define TCPBUFSIZE 1024 * 32 + 200
225 /* -------------------------- Macros ----------------------- */
228 uint32_t sec; /* seconds */
229 uint32_t usec; /* and microseconds */
230 uint32_t esec; /* seconds since standard epoch */
233 #define SUBTIME(t1, t2) { \
234 if ((t1.sec < t2.sec) || \
235 ((t1.sec == t2.sec) && (t1.usec < t2.usec))) { \
236 t1.sec = t1.usec = 0 ; \
238 if (t1.usec < t2.usec) { \
239 t1.usec += 1000000; \
242 t1.usec -= t2.usec; \
247 #define ADDTIME(t1, t2) {if ((t1.usec += t2.usec) >= 1000000) {\
248 t1.sec += (t1.usec / 1000000); \
249 t1.usec %= 1000000; \
254 #define MINIMUM(a, b) ((a < b) ? (a) : (b))
255 #define MAXIMUM(a, b) ((a > b) ? (a) : (b))
257 #define MULTIME(t1, s) { \
260 if (t1.usec >= 1000000) {\
261 t1.sec += (t1.usec/1000000); \
262 t1.usec %= 1000000; \
265 #define DIVTIME(t1, s) { \
266 t1.usec += (t1.sec % s ) *1000000; \
270 #define LARGERTIME(t1, t2) \
271 ((t1.sec>t2.sec) || ((t1.sec==t2.sec) && (t1.usec>t2.usec)))
273 /* -------------------------- Types ----------------------- */
276 * SFS test phases. Values are well-ordered for use of "<" operations.
278 #define Mount_phase 1 /* test directories are being mounted */
279 #define Populate_phase 2 /* files being created in the test directories */
280 #define Warmup_phase 3 /* reach steady state (load is being generated) */
281 #define Testrun_phase 4 /* timed test run (load is being generated) */
282 #define Results_phase 5 /* results collection and reporting */
283 typedef int sfs_phase_type;
286 * Index constants for lookups into the RPC timer array.
294 * SFS results information structure
297 int good_calls; /* successful calls */
298 int bad_calls; /* failed (timed out) calls */
299 int timeout_calls; /* RFS timeout calls */
300 int fast_calls; /* calls that competed in 0 time */
301 struct ladtime time; /* cumulative execution time */
302 double msec2; /* cumulative squared time - msecs**2 */
306 * SFS information reported from child back to parent.
310 sfs_results_type results_buf[NOPS+1];
315 } sfs_results_report_type;
319 * SFS operation information structure
323 char * name; /* operation name */
324 int mix_pcnt; /* percentage of call target */
326 int (*funct)(); /* op routine */
328 int call_class; /* call class: client handle & timeo */
329 int target_calls; /* number of calls to make */
330 int no_calls; /* # of times a call couldn't be made */
331 double req_pcnt; /* cumulative request percentile */
332 int req_cnt; /* number of requests made */
333 int target_reqs; /* number of req to be made */
334 sfs_results_type results; /* test results */
339 * Flags used with randfh
341 #define RANDFH_TRUNC 0x01 /* pick a file to truncate */
342 #define RANDFH_APPEND 0x02 /* pick a file to append to */
345 * SFS file information structure
346 * The particular values assiged are used to perform mod operations.
348 #define Sfs_io_file 0 /* read, write ops only (0) */
349 #define Sfs_non_io_file 1 /* other regular file ops only (1) */
350 #define Sfs_symlink 2 /* symlink ops only (2) */
351 #define Sfs_dir 3 /* dir ops only (3) */
352 #define Sfs_regular 4 /* any regular file (0,1) */
353 #define Sfs_non_dir 5 /* any non-directory file (0,1,2) */
354 #define Sfs_any_file 6 /* any file, link, or dir (0,1,2,3) */
355 typedef int sfs_file_type;
357 #define Exists 1 /* op needs an object that already exists */
358 #define Nonexistent 2 /* op will create an object */
359 #define Empty_dir 3 /* op needs an empty directory */
360 typedef char sfs_state_type;
363 * One file (dir, or symlink) in the file set.
365 typedef struct sfs_fh_data {
367 fhandle_t f_fh2; /* the NFS V2 file handle */
368 nfs_fh3 f_fh3; /* the NFS V3 file handle */
371 fattr a_attributes2; /* its V2 attributes */
372 fattr3 a_attributes3; /* its V3 attributes */
374 char file_name[SFS_MAXNAMLEN]; /* path component*/
377 typedef struct sfs_fh_type {
378 struct sfs_fh_type *dir; /* Parent Directory */
379 struct sfs_fh_data *fh_data; /* Data area */
380 int size; /* its size */
381 int unique_num; /* unique part of filename */
382 int use_cnt; /* count of op to this file */
383 int xfer_cnt; /* count of KB xfered */
384 sfs_state_type state; /* existence state */
385 char working_set; /* is in the working set */
386 char initialize; /* should be initialized */
387 #define attributes2 fh_data->sfs_fattr_un.a_attributes2
388 #define attributes3 fh_data->sfs_fattr_un.a_attributes3
389 #define fh2 fh_data->sfs_fh_un.f_fh2
390 #define fh3 fh_data->sfs_fh_un.f_fh3
391 #define file_name fh_data->file_name
394 #define fh_size(fhptr) (nfs_version == NFS_VERSION ? \
395 (fhptr)->attributes2.size : \
396 (fhptr)->attributes3.size._p._l)
398 #define fh_uid(fhptr) (nfs_version == NFS_VERSION ? \
399 (uint32_t)((fhptr)->attributes2.uid) : \
400 (uint32_t)((fhptr)->attributes3.uid))
402 #define fh_gid(fhptr) (nfs_version == NFS_VERSION ? \
403 (uint32_t)((fhptr)->attributes2.gid) : \
404 (uint32_t)((fhptr)->attributes3.gid))
406 #define fh_mode(fhptr) (nfs_version == NFS_VERSION ? \
407 (uint32_t)((fhptr)->attributes2.mode) : \
408 (uint32_t)((fhptr)->attributes3.mode))
410 #define fh_isdir(fhptr) (nfs_version == NFS_VERSION ? \
411 ((fhptr)->attributes2.type == NFDIR) : \
412 ((fhptr)->attributes3.type == NF3DIR))
414 #define fh_isfile(fhptr) (nfs_version == NFS_VERSION ? \
415 ((fhptr)->attributes2.type == NFREG) : \
416 ((fhptr)->attributes3.type == NF3REG))
419 * One file (dir, or symlink) in the working file set.
422 int range; /* random access range for this file */
423 int index; /* points into actual file array */
427 sfs_work_fh_type *entries; /* array of working files */
428 int access_group_size; /* # files in a group */
429 int access_group_cnt; /* # groups in workset */
430 int max_range; /* access range of workset */
436 * SFS file size distribution structures
439 int pcnt; /* percentile */
440 int bufs; /* Block_size KB xfers */
441 int frags; /* boolean - is a frag present */
442 } sfs_io_op_dist_type;
445 sfs_io_op_dist_type *read; /* read size table */
446 sfs_io_op_dist_type *write; /* write size table */
447 int max_bufs; /* max # of Block_size xfers */
448 double avg_ops_per_read_req; /* avg read ops/req */
449 double avg_ops_per_write_req; /* avg write ops/req */
453 int pcnt; /* percentile */
454 int size; /* file size in KB */
455 } sfs_io_file_size_dist;
458 /* sfs child processes synchronization logfile */
459 #define CHILD_SYNC_LOG "/tmp/sfs_log"
460 #define SFS_PNT_PID "/tmp/sfs_pnt_pid"
461 #define SFS_PRM_PID "/tmp/sfs_prm_pid"
462 #define SFS_SYNCD_PID "/tmp/sfs_syncd_pid"
465 * Values for invalid runs
467 #define INVALID_UNKNOWN 1 /* Old value reserved as unknown */
468 #define INVALID_IODIST 2
469 #define INVALID_MIX 3
470 #define INVALID_RUNTIME 4
471 #define INVALID_ACCESS 5
472 #define INVALID_APPEND 6
474 #define INVALID_NDIRS 8
475 #define INVALID_FSS 9
476 #define INVALID_BIODREAD 10
477 #define INVALID_NSYMLINKS 11
478 #define INVALID_BIODWRITE 12
479 #define INVALID_WARMUP 13
480 #define INVALID_GOODCALLS 14
481 #define INVALID_FAILEDRPC 15
482 #define INVALID_NOTMIX 16
483 #define INVALID_MAX (INVALID_NOTMIX + 1)
486 * External variable declarations
488 extern int Access_percent;
489 extern int Append_percent;
490 extern int Base_fss_bytes;
491 extern int Biod_max_outstanding_reads;
492 extern int Biod_max_outstanding_writes;
493 extern int Bytes_per_block;
494 extern int Child_num;
495 extern int Client_num;
496 extern sfs_fh_type *Cur_file_ptr;
497 extern char Cur_filename[];
498 extern gid_t Cur_gid;
499 extern struct ladtime Cur_time;
500 extern uid_t Cur_uid;
501 extern sfs_phase_type Current_test_phase;
502 extern int Debug_level;
503 extern sfs_io_file_size_dist Default_file_size_dist[];
504 extern sfs_fh_type *Dirs;
505 extern uint32_t Dump_count;
506 extern int dump_create_existing_file;
507 extern int Dump_data;
508 extern uint32_t Dump_length;
509 extern uint32_t Dump_offset;
510 extern int dump_truncate_op;
511 extern sfs_fh_type Export_dir;
512 extern char Filespec[];
513 extern char Dirspec[];
514 extern char Symspec[];
515 extern int avg_bytes_per_file;
516 extern int files_per_megabyte;
517 extern int Fss_delta_percent;
518 extern int Interactive;
519 extern sfs_io_dist_type * Io_dist_ptr;
520 extern sfs_fh_type *Io_files;
521 extern int Kb_per_block;
522 extern char * sfs_Myname;
523 extern int Least_fss_bytes;
524 extern int Limit_fss_bytes;
525 extern int Cur_fss_bytes;
526 extern int Total_fss_bytes;
528 extern char Logname[];
529 extern int Most_fss_bytes;
530 extern int Msec_per_period;
531 extern CLIENT * NFS_client;
532 extern CLIENT * NFS_client_recv;
533 extern struct timeval *Nfs_timers;
534 extern struct timeval Nfs_udp_timers[];
535 extern struct timeval Nfs_tcp_timers[];
536 extern int nfs_version;
537 extern sfs_fh_type *Non_io_files;
539 extern int Num_dir_files;
540 extern int Num_failed_lookup;
541 extern int Num_io_files;
542 extern int Num_non_io_files;
543 extern int Num_symlinks;
544 extern int Num_symlink_files;
545 extern int Num_working_dirs;
546 extern int Num_working_io_files;
547 extern int Num_working_non_io_files;
548 extern int Num_working_symlinks;
549 extern sfs_op_type *Ops;
550 extern int Populate_only;
551 extern char * Prime_client;
552 extern uid_t Real_uid;
554 extern struct ladtime Starttime;
555 extern int start_run_phase;
556 extern sfs_fh_type *Symlinks;
559 extern int Files_per_dir;
560 extern int Tot_client_num_io_files;
561 extern int Tot_client_num_non_io_files;
562 extern int Tot_client_num_symlinks;
563 extern int Timed_run;
565 extern int Warmuptime;
566 extern char *invalid_str[];
567 extern char lad_hostname[];
571 * External function declarations
573 extern int biod_init(int, int);
574 extern void biod_term(void);
575 extern void biod_turn_on(void);
576 extern int check_access(struct stat *);
577 extern int check_fh_access(sfs_fh_type *);
578 extern void child(int, int, float, int, char **);
579 extern void generic_catcher(int);
580 extern int generic_kill(int, int);
581 extern void init_counters(void);
582 extern void init_fileinfo(void);
583 extern void init_mount_point(int, char *, CLIENT *);
584 extern void init_ops(void);
585 extern char * init_write_buffer(void);
586 extern CLIENT * lad_getmnt_hand(char *);
587 extern CLIENT * lad_clnt_create(int, struct hostent *, uint32_t,
588 uint32_t, int, struct timeval *);
589 extern char * lad_timestamp(void);
590 extern int set_debug_level(char *s);
591 extern void sfs_alarm(int);
592 extern void sfs_cleanup(int);
593 extern void sfs_elapsedtime(sfs_op_type *, struct ladtime *,
595 extern void sfs_gettime(struct ladtime *);
596 extern int32_t sfs_random(void);
597 extern void sfs_srandom(int);
598 extern int init_rand_range(int);
599 extern int rand_range(int);
600 extern void sfs_startup(int);
601 extern void sfs_stop(int);
602 extern void log_dump(struct ladtime *, struct ladtime *, int);
603 extern void parent(int, int, char *, char *);
604 extern void print_dump(int, int);
606 randfh(int, int, uint_t, sfs_state_type, sfs_file_type);
607 extern int msec_sleep(int);
608 extern void Validate_ops(int, char **);
610 /* Reliable RPC functions for initialization */
611 extern int lad_lookup(sfs_fh_type *, char *);
612 extern int lad_remove(sfs_fh_type *, char *);
613 extern int lad_rmdir(sfs_fh_type *, char *);
614 extern int lad_symlink(sfs_fh_type *, char *, char *);
615 extern int lad_mkdir(sfs_fh_type *, char *);
616 extern int lad_write(sfs_fh_type *, int32_t, int32_t);
617 extern int lad_create(sfs_fh_type *, char *);
618 extern int lad_truncate(sfs_fh_type *, int32_t);
620 /* RFS: moved the definition from sfs_c_bio.c to here because it is used in
621 * sfs_c_chd.c in the new code, information associated with outstanding requests
624 uint32_t xid; /* RPC transmission ID */
625 bool_t in_use; /* Indicates if the entry is in use */
626 int dep_tab_index; /* corresponding index in dep_tab */
627 unsigned int count; /* Count saved for Dump routines */
628 unsigned int offset; /* Offset saved for Dump routines */
629 struct ladtime start; /* Time RPC call was made */
630 struct ladtime stop; /* Time RPC reply was received */
631 struct ladtime timeout; /* Time RPC call will time out */
634 #endif /* sfs_def.h */