• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *   Copyright (c) International Business Machines Corp., 2001-2004
3  *
4  *   This program is free software;  you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 2 of the License, or
7  *   (at your option) any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
12  *   the GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program;  if not, write to the Free Software
16  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef _FFSB_H_
19 #define _FFSB_H_
20 
21 #include <sys/time.h>
22 #include <sys/resource.h>
23 #include <unistd.h>
24 #include <stdlib.h>
25 #include <stdio.h>
26 
27 #include "config.h"
28 
29 #include "ffsb_op.h"
30 #include "ffsb_tg.h"
31 #include "ffsb_fs.h"
32 
33 /*
34  * The main thread wakes up once in so many seconds to check elapsed
35  * time this is a tunable for that sleep interval in seconds
36  */
37 
38 #define FFSB_TG_WAIT_TIME (1)
39 
40 #define MARK printf("MARK FUNC: %s() @ %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
41 
42 struct results {
43 	struct rusage before;
44 	struct rusage after;
45 	double runtime;
46 	double cputime;
47 	double cpu_before;
48 	double cpu_after;
49 	double cpu_total;
50 };
51 
52 struct ffsb_tg;
53 struct ffsb_fs;
54 
55 typedef struct profile_config {
56 	struct config_options *global;
57 	struct container *fs_container;
58 	struct container *tg_container;
59 } profile_config_t;
60 
61 typedef struct ffsb_config {
62 	unsigned time;
63 
64 	unsigned num_filesys;
65 	unsigned num_threadgroups;
66 
67 	int num_totalthreads;		/* gets calculated after init() */
68 
69 	struct ffsb_tg *groups;
70 	struct ffsb_fs *filesystems;
71 
72 	struct profile_config *profile_conf;
73 	char *callout;			/* we will try and exec this */
74 
75 	struct results results;
76 } ffsb_config_t;
77 
78 void init_ffsb_config(ffsb_config_t *fc, unsigned num_fs, unsigned num_tg);
79 
80 /*
81  * this is kind of like a special case "constructor" which is only
82  * used by fs-aging code to build a fake config for the aging tg
83  */
84 void init_ffsb_config_1fs(ffsb_config_t *fc, struct ffsb_fs *fs,
85 			   struct ffsb_tg *tg);
86 
87 void destroy_ffsb_config(ffsb_config_t *fc);
88 
89 /* getters/setters, parser only should use setters */
90 
91 void fc_set_time(ffsb_config_t *fc, unsigned time);
92 
93 void fc_set_num_totalthreads(ffsb_config_t *fc, int num);
94 
95 /* num is zero-based */
96 /* get a particular threadgroup object */
97 struct ffsb_tg *fc_get_tg(ffsb_config_t *fc, unsigned num);
98 
99 /* get a particular filesystem object */
100 struct ffsb_fs *fc_get_fs(ffsb_config_t *fc, unsigned num);
101 
102 void fc_set_callout(ffsb_config_t *fc, char *callout);
103 char *fc_get_callout(ffsb_config_t *fc);
104 
105 #endif
106