• 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_FS_H_
19 #define _FFSB_FS_H_
20 
21 #include "filelist.h"
22 #include "ffsb_op.h"
23 #include "ffsb_tg.h"
24 #include "ffsb_stats.h"
25 
26 /* These are the base names for the different file types on a
27  * filesystem.
28 */
29 #define FILES_BASE "data"
30 #define META_BASE  "meta"
31 #define AGE_BASE   "fill"
32 
33 struct ffsb_tg;
34 
35 typedef struct size_weight {
36 	uint64_t size;
37 	int weight;
38 } size_weight_t;
39 
40 /* A filesystem object
41  * --
42  * represents a filesystem on disk, and maintains access to the different
43  * directories within it.  Currently there are two directories created in
44  * each filesystem: data and meta
45  * "data" contains the aging files and the working set files
46  * "meta" only contains directories for use in the metadata operation
47  *
48  * Aging
49  * This object contains methods for aging the filesystem if needed
50  * a properly set up threadgroup is supplied by the parser which is run
51  * until the filesystem reaches the desired utilization
52  *
53  * Operations
54  * The semantics of a ffsb operation are always such that they occur on
55  * a filesystem, so the filesystem also hold operation specific data as
56  * an opaque type
57  * One example of how this is useful is the aging process, where a different
58  * set of files is operated upon than in the regular benchmark and the
59  * op_data is pointing to the "fill" set rather than the "files" set
60  */
61 
62 typedef struct ffsb_fs {
63 	char *basedir;
64 
65 	struct benchfiles files;
66 	struct benchfiles meta;
67 	struct benchfiles fill;
68 
69 	int flags;
70 #define FFSB_FS_DIRECTIO   (1 << 0)
71 #define FFSB_FS_ALIGNIO4K  (1 << 1)
72 #define FFSB_FS_LIBCIO     (1 << 2)
73 #define FFSB_FS_REUSE_FS   (1 << 3)
74 
75 	/* These pararmeters pertain to files in the files and fill
76 	 * dirs.  Meta dir only contains directories, starting with 0.
77 	 */
78 	uint32_t num_dirs;
79 	uint32_t num_start_files;
80 	uint64_t minfilesize, maxfilesize;
81 	double init_fsutil;
82 	uint64_t init_size;
83 
84 	/* These two parameters specify the blocksize to use for
85 	 * writes when creating and aging the fs.
86 	 */
87 	uint32_t create_blocksize, age_blocksize;
88 #define FFSB_FS_DEFAULT_CREATE_BLOCKSIZE 4096
89 #define FFSB_FS_DEFAULT_AGE_BLOCKSIZE    4096
90 
91 	double start_fsutil;
92 
93 	/* Aging data/parameters */
94 	double desired_fsutil;
95 	int age_fs;
96 	uint32_t num_age_dirs;
97 
98 	/* Use an ffsb thread group to do the aging work */
99 	struct ffsb_tg *aging_tg;
100 
101 	/* If a particular operation wants to maintain fs-specific
102 	 * data, it should use this array.  Naturally, the ops must
103 	 * synchonize access to the data for now, they are all just
104 	 * putting pointers to a particular benchfiles struct here,
105 	 * which is already sync'ed
106 	 */
107 	void *op_data[FFSB_NUMOPS];
108 
109 	/* per-fs stats */
110 	ffsb_statsc_t fsc;
111 	ffsb_statsd_t fsd;
112 
113 	size_weight_t *size_weights;
114 	unsigned num_weights;
115 	unsigned sum_weights;
116 
117 } ffsb_fs_t;
118 
119 /* Set up the structure, zeros everything out and dups the basedir
120  * string
121  */
122 void init_ffsb_fs(ffsb_fs_t *fs, char *basedir, uint32_t num_data_dirs,
123 		  uint32_t num_start_files, unsigned flags);
124 
125 /* Does not remove files/dirs on disk, only frees up data
126  * structures
127  */
128 void destroy_ffsb_fs(ffsb_fs_t *fs);
129 
130 /* Set up the files and such on the disk including aging if requested.
131  * Should call back into each op, which initialize its op_data[]
132  * entry.  Aging is done by starting the aging_tg thread group, and
133  * waiting until the desired utilization is achieved.  It can (and is)
134  * be used with pthread_create().  Parameter should be a ffsb_fs_t * ,
135  * and it will return the same type
136  */
137 void *construct_ffsb_fs(void *ffsb_fs_ptr);
138 
139 /* Shallow clone, original should simply be discarded (not destroyed).
140  * Generally should only be used by parser to write into the config
141  * object
142  */
143 void clone_ffsb_fs(ffsb_fs_t *target, ffsb_fs_t *original);
144 
145 void fs_print_config(ffsb_fs_t *fs);
146 
147 char *fs_get_basedir(ffsb_fs_t *fs);
148 int fs_get_directio(ffsb_fs_t *fs);
149 void fs_set_directio(ffsb_fs_t *fs, int dio);
150 int fs_get_alignio(ffsb_fs_t *fs);
151 void fs_set_alignio(ffsb_fs_t *fs, int aio);
152 int fs_get_libcio(ffsb_fs_t *fs);
153 void fs_set_libcio(ffsb_fs_t *fs, int lio);
154 int fs_get_reuse_fs(ffsb_fs_t *fs);
155 void fs_set_reuse_fs(ffsb_fs_t *fs, int rfs);
156 
157 struct benchfiles *fs_get_datafiles(ffsb_fs_t *fs);
158 struct benchfiles *fs_get_metafiles(ffsb_fs_t *fs);
159 struct benchfiles *fs_get_agefiles(ffsb_fs_t *fs);
160 
161 void fs_set_aging_tg(ffsb_fs_t *fs, struct ffsb_tg *, double util);
162 struct ffsb_tg *fs_get_aging_tg(ffsb_fs_t *fs);
163 int fs_get_agefs(ffsb_fs_t *fs);
164 
165 void fs_set_opdata(ffsb_fs_t *fs, void *data, unsigned opnum);
166 void *fs_get_opdata(ffsb_fs_t *fs, unsigned opnum);
167 void fs_set_min_filesize(ffsb_fs_t *fs, uint64_t size);
168 void fs_set_max_filesize(ffsb_fs_t *fs, uint64_t size);
169 void fs_set_create_blocksize(ffsb_fs_t *fs, uint32_t blocksize);
170 void fs_set_age_blocksize(ffsb_fs_t *fs, uint32_t blocksize);
171 uint32_t fs_get_create_blocksize(ffsb_fs_t *fs);
172 uint32_t fs_get_age_blocksize(ffsb_fs_t *fs);
173 uint64_t fs_get_min_filesize(ffsb_fs_t *fs);
174 uint64_t fs_get_max_filesize(ffsb_fs_t *fs);
175 uint32_t fs_get_numstartfiles(ffsb_fs_t *fs);
176 uint32_t fs_get_numdirs(ffsb_fs_t *fs);
177 
178 double fs_get_desired_fsutil(ffsb_fs_t *fs);
179 
180 /* For these two, fs == NULL is OK */
181 int fs_needs_stats(ffsb_fs_t *fs, syscall_t s);
182 void fs_add_stat(ffsb_fs_t *fs, syscall_t sys, uint32_t val);
183 
184 #endif /* _FFSB_FS_H_ */
185