Lines Matching +full:- +full:fs
2 * Copyright (c) International Business Machines Corp., 2001-2004
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
30 void init_ffsb_fs(ffsb_fs_t * fs, char *basedir, uint32_t num_data_dirs, in init_ffsb_fs() argument
33 memset(fs, 0, sizeof(ffsb_fs_t)); in init_ffsb_fs()
34 fs->basedir = ffsb_strdup(basedir); in init_ffsb_fs()
35 fs->num_dirs = num_data_dirs; in init_ffsb_fs()
36 fs->num_start_files = numstartfiles; in init_ffsb_fs()
37 fs->flags = flags; in init_ffsb_fs()
38 fs->create_blocksize = FFSB_FS_DEFAULT_CREATE_BLOCKSIZE; in init_ffsb_fs()
39 fs->age_blocksize = FFSB_FS_DEFAULT_AGE_BLOCKSIZE; in init_ffsb_fs()
40 fs->age_fs = 0; in init_ffsb_fs()
47 void destroy_ffsb_fs(ffsb_fs_t * fs) in destroy_ffsb_fs() argument
49 free(fs->basedir); in destroy_ffsb_fs()
50 destroy_filelist(&fs->files); in destroy_ffsb_fs()
51 destroy_filelist(&fs->fill); in destroy_ffsb_fs()
52 destroy_filelist(&fs->meta); in destroy_ffsb_fs()
57 target->basedir = orig->basedir; in clone_ffsb_fs()
58 target->flags = orig->flags; in clone_ffsb_fs()
61 memcpy(&target->files, &orig->files, sizeof(orig->files)); in clone_ffsb_fs()
62 memcpy(&target->fill, &orig->fill, sizeof(orig->fill)); in clone_ffsb_fs()
63 memcpy(&target->meta, &orig->meta, sizeof(orig->meta)); in clone_ffsb_fs()
65 target->num_dirs = orig->num_dirs; in clone_ffsb_fs()
66 target->num_start_files = orig->num_start_files; in clone_ffsb_fs()
67 target->minfilesize = orig->minfilesize; in clone_ffsb_fs()
68 target->maxfilesize = orig->maxfilesize; in clone_ffsb_fs()
70 target->start_fsutil = orig->start_fsutil; in clone_ffsb_fs()
71 target->desired_fsutil = orig->desired_fsutil; in clone_ffsb_fs()
73 target->age_fs = orig->age_fs; in clone_ffsb_fs()
74 target->num_age_dirs = orig->num_age_dirs; in clone_ffsb_fs()
75 target->aging_tg = orig->aging_tg; in clone_ffsb_fs()
77 target->create_blocksize = orig->create_blocksize; in clone_ffsb_fs()
78 target->age_blocksize = orig->age_blocksize; in clone_ffsb_fs()
80 memcpy(target->op_data, orig->op_data, sizeof(void *) * FFSB_NUMOPS); in clone_ffsb_fs()
83 static void add_files(ffsb_fs_t * fs, struct benchfiles *bf, int num, in add_files() argument
90 uint64_t initial_free = getfsutil_size(fs->basedir); in add_files()
92 if (fs_get_directio(fs)) { in add_files()
94 fs_set_directio(fs, 0); in add_files()
103 else if (fs->init_size) { in add_files()
104 if (getfsutil(fs->basedir) != initial_free || in add_files()
105 fs->init_size > (getfsutil_size(fs->basedir) - in add_files()
110 } else if (fs->init_fsutil) { in add_files()
111 if (fs->init_fsutil > getfsutil(fs->basedir)) in add_files()
119 if (fs->num_weights) { in add_files()
120 int num = 1 + getrandom(&rd, fs->sum_weights); in add_files()
123 while (fs->size_weights[curop].weight < num) { in add_files()
124 num -= fs->size_weights[curop].weight; in add_files()
127 size = fs->size_weights[curop].size; in add_files()
129 size = minsize + getllrandom(&rd, maxsize - minsize); in add_files()
132 fd = fhopencreate(cur->name, NULL, fs); in add_files()
133 writefile_helper(fd, size, blocksize, buf, NULL, fs); in add_files()
134 fhclose(fd, NULL, fs); in add_files()
138 condition--; in add_files()
139 else if (fs->init_size) { in add_files()
140 if (fs->init_size > getfsutil_size(fs->basedir) - in add_files()
145 } else if (fs->init_fsutil) { in add_files()
146 if (fs->init_fsutil > getfsutil(fs->basedir)) in add_files()
155 fs_set_directio(fs, 1); in add_files()
158 static void age_fs(ffsb_fs_t * fs, double utilization);
159 static ffsb_fs_t *construct_new_fileset(ffsb_fs_t * fs);
160 static ffsb_fs_t *check_existing_fileset(ffsb_fs_t * fs);
164 ffsb_fs_t *fs = (ffsb_fs_t *) data; in construct_ffsb_fs() local
167 if (fs_get_reuse_fs(fs)) { in construct_ffsb_fs()
168 printf("checking existing fs: %s\n", fs->basedir); in construct_ffsb_fs()
169 ret = check_existing_fileset(fs); in construct_ffsb_fs()
172 ret = construct_new_fileset(fs); in construct_ffsb_fs()
175 printf("creating new fileset %s\n", fs->basedir); in construct_ffsb_fs()
176 ret = construct_new_fileset(fs); in construct_ffsb_fs()
179 printf("fs setup on %s failed\n", fs->basedir); in construct_ffsb_fs()
187 ffsb_fs_t *fs = (ffsb_fs_t *) fs_ptr; in verify_file() local
188 uint64_t minsize = fs->minfilesize; in verify_file()
189 uint64_t maxsize = fs->maxfilesize; in verify_file()
229 static ffsb_fs_t *check_existing_fileset(ffsb_fs_t * fs) in check_existing_fileset() argument
233 uint32_t num_dirs = fs->num_dirs; in check_existing_fileset()
234 uint32_t num_files = fs->num_start_files; in check_existing_fileset()
236 if (fs->age_fs) { in check_existing_fileset()
245 snprintf(buf, FILENAME_MAX, "%s/%s", fs->basedir, FILES_BASE)) { in check_existing_fileset()
253 init_filelist(&fs->files, buf, FILES_BASE, 0, 0); in check_existing_fileset()
255 retval = grab_old_fileset(&fs->files, buf, verify_file, fs); in check_existing_fileset()
260 if ((get_listsize(&fs->files) != num_files) || in check_existing_fileset()
261 (get_numsubdirs(&fs->files) != num_dirs)) { in check_existing_fileset()
264 get_listsize(&fs->files), get_numsubdirs(&fs->files)); in check_existing_fileset()
265 destroy_filelist(&fs->files); in check_existing_fileset()
270 snprintf(buf, FILENAME_MAX, "%s/%s", fs->basedir, META_BASE)) { in check_existing_fileset()
275 init_filelist(&fs->meta, buf, META_BASE, 0, 1); in check_existing_fileset()
276 retval = grab_old_fileset(&fs->meta, buf, verify_file, fs); in check_existing_fileset()
279 destroy_filelist(&fs->files); in check_existing_fileset()
283 if ((get_listsize(&fs->meta) != 0) || (get_numsubdirs(&fs->meta) != 0)) { in check_existing_fileset()
286 destroy_filelist(&fs->files); in check_existing_fileset()
287 destroy_filelist(&fs->meta); in check_existing_fileset()
294 init_filelist(&fs->fill, buf, AGE_BASE, 0, 0); in check_existing_fileset()
297 ops_setup_bench(fs); in check_existing_fileset()
299 return fs; in check_existing_fileset()
303 * clean up fs, "rm -rf data meta"
310 static ffsb_fs_t *construct_new_fileset(ffsb_fs_t * fs) in construct_new_fileset() argument
314 /* TODO: Convert this quick and dirty rm -rf to a "real" in construct_new_fileset()
318 "rm -rf %s/data %s/meta", in construct_new_fileset()
319 fs->basedir, fs->basedir)) { in construct_new_fileset()
329 fs->start_fsutil = getfsutil(fs->basedir); in construct_new_fileset()
333 snprintf(buf, FILENAME_MAX, "%s/%s", fs->basedir, FILES_BASE)) { in construct_new_fileset()
341 init_filelist(&fs->files, buf, FILES_BASE, fs->num_dirs, 1); in construct_new_fileset()
342 init_filelist(&fs->fill, buf, AGE_BASE, fs->num_age_dirs, 1); in construct_new_fileset()
345 snprintf(buf, FILENAME_MAX, "%s/%s", fs->basedir, META_BASE); in construct_new_fileset()
349 init_filelist(&fs->meta, buf, META_BASE, 0, 1); in construct_new_fileset()
352 if (fs->age_fs) in construct_new_fileset()
353 age_fs(fs, fs->desired_fsutil); in construct_new_fileset()
356 ops_setup_bench(fs); in construct_new_fileset()
359 add_files(fs, &fs->files, fs->num_start_files, fs->minfilesize, in construct_new_fileset()
360 fs->maxfilesize, fs->create_blocksize); in construct_new_fileset()
361 return fs; in construct_new_fileset()
365 ffsb_fs_t *fs; member
372 double fsutil = getfsutil(pd->fs->basedir); in fs_get_util()
374 if (fsutil >= pd->util) in fs_get_util()
380 static void age_fs(ffsb_fs_t * fs, double utilization) in age_fs() argument
385 ffsb_tg_t *tg = fs_get_aging_tg(fs); in age_fs()
389 printf("aging fs %s from %.2lf to %.2lf\n", fs->basedir, in age_fs()
390 fs->start_fsutil, utilization); in age_fs()
393 init_ffsb_config_1fs(&fc, fs, tg); in age_fs()
395 pdata.fs = fs; in age_fs()
408 ops_setup_age(fs); in age_fs()
411 add_files(fs, &fs->fill, 10, 0, 0, fs->age_blocksize); in age_fs()
417 void fs_set_create_blocksize(ffsb_fs_t * fs, uint32_t blocksize) in fs_set_create_blocksize() argument
419 fs->create_blocksize = blocksize; in fs_set_create_blocksize()
422 void fs_set_age_blocksize(ffsb_fs_t * fs, uint32_t blocksize) in fs_set_age_blocksize() argument
424 fs->age_blocksize = blocksize; in fs_set_age_blocksize()
427 uint32_t fs_get_create_blocksize(ffsb_fs_t * fs) in fs_get_create_blocksize() argument
429 return fs->create_blocksize; in fs_get_create_blocksize()
432 uint32_t fs_get_age_blocksize(ffsb_fs_t * fs) in fs_get_age_blocksize() argument
434 return fs->age_blocksize; in fs_get_age_blocksize()
437 char *fs_get_basedir(ffsb_fs_t * fs) in fs_get_basedir() argument
439 return fs->basedir; in fs_get_basedir()
442 uint32_t fs_get_numstartfiles(ffsb_fs_t * fs) in fs_get_numstartfiles() argument
444 return fs->num_start_files; in fs_get_numstartfiles()
447 uint32_t fs_get_numdirs(ffsb_fs_t * fs) in fs_get_numdirs() argument
449 return fs->num_dirs; in fs_get_numdirs()
452 int fs_get_libcio(ffsb_fs_t * fs) in fs_get_libcio() argument
454 return fs->flags & FFSB_FS_LIBCIO; in fs_get_libcio()
457 void fs_set_libcio(ffsb_fs_t * fs, int lio) in fs_set_libcio() argument
460 fs->flags |= FFSB_FS_LIBCIO; in fs_set_libcio()
462 fs->flags &= ~0 & ~FFSB_FS_LIBCIO; in fs_set_libcio()
465 int fs_get_directio(ffsb_fs_t * fs) in fs_get_directio() argument
467 return fs->flags & FFSB_FS_DIRECTIO; in fs_get_directio()
470 void fs_set_directio(ffsb_fs_t * fs, int dio) in fs_set_directio() argument
473 fs->flags |= FFSB_FS_DIRECTIO; in fs_set_directio()
475 fs->flags &= ~0 & ~FFSB_FS_DIRECTIO; in fs_set_directio()
478 int fs_get_alignio(ffsb_fs_t * fs) in fs_get_alignio() argument
480 return fs->flags & FFSB_FS_ALIGNIO4K; in fs_get_alignio()
483 void fs_set_alignio(ffsb_fs_t * fs, int aio) in fs_set_alignio() argument
486 fs->flags |= FFSB_FS_ALIGNIO4K; in fs_set_alignio()
488 fs->flags &= ~0 & ~FFSB_FS_ALIGNIO4K; in fs_set_alignio()
491 int fs_get_reuse_fs(ffsb_fs_t * fs) in fs_get_reuse_fs() argument
493 return fs->flags & FFSB_FS_REUSE_FS; in fs_get_reuse_fs()
496 void fs_set_reuse_fs(ffsb_fs_t * fs, int rfs) in fs_set_reuse_fs() argument
499 fs->flags |= FFSB_FS_REUSE_FS; in fs_set_reuse_fs()
501 fs->flags &= ~0 & ~FFSB_FS_REUSE_FS; in fs_set_reuse_fs()
504 struct benchfiles *fs_get_datafiles(ffsb_fs_t * fs) in fs_get_datafiles() argument
506 return &fs->files; in fs_get_datafiles()
509 struct benchfiles *fs_get_metafiles(ffsb_fs_t * fs) in fs_get_metafiles() argument
511 return &fs->meta; in fs_get_metafiles()
514 struct benchfiles *fs_get_agefiles(ffsb_fs_t * fs) in fs_get_agefiles() argument
516 return &fs->fill; in fs_get_agefiles()
519 void fs_set_aging_tg(ffsb_fs_t * fs, struct ffsb_tg *tg, double util) in fs_set_aging_tg() argument
521 fs->aging_tg = tg; in fs_set_aging_tg()
522 fs->age_fs = 1; in fs_set_aging_tg()
523 fs->desired_fsutil = util; in fs_set_aging_tg()
526 struct ffsb_tg *fs_get_aging_tg(ffsb_fs_t * fs) in fs_get_aging_tg() argument
528 return fs->aging_tg; in fs_get_aging_tg()
531 int fs_get_agefs(ffsb_fs_t * fs) in fs_get_agefs() argument
533 return fs->age_fs; in fs_get_agefs()
537 void fs_set_num_age_dirs(ffsb_fs_t * fs, uint32_t numdirs) in fs_set_num_age_dirs() argument
539 fs->num_age_dirs = numdirs; in fs_set_num_age_dirs()
542 void fs_set_opdata(ffsb_fs_t * fs, void *data, unsigned opnum) in fs_set_opdata() argument
544 fs->op_data[opnum] = data; in fs_set_opdata()
547 void *fs_get_opdata(ffsb_fs_t * fs, unsigned opnum) in fs_get_opdata() argument
549 return fs->op_data[opnum]; in fs_get_opdata()
552 void fs_set_min_filesize(ffsb_fs_t * fs, uint64_t size) in fs_set_min_filesize() argument
554 fs->minfilesize = size; in fs_set_min_filesize()
557 void fs_set_max_filesize(ffsb_fs_t * fs, uint64_t size) in fs_set_max_filesize() argument
559 fs->maxfilesize = size; in fs_set_max_filesize()
562 uint64_t fs_get_min_filesize(ffsb_fs_t * fs) in fs_get_min_filesize() argument
564 return fs->minfilesize; in fs_get_min_filesize()
567 uint64_t fs_get_max_filesize(ffsb_fs_t * fs) in fs_get_max_filesize() argument
569 return fs->maxfilesize; in fs_get_max_filesize()
572 double fs_get_desired_fsutil(ffsb_fs_t * fs) in fs_get_desired_fsutil() argument
574 return fs->desired_fsutil; in fs_get_desired_fsutil()
577 void fs_print_config(ffsb_fs_t * fs) in fs_print_config() argument
581 printf("FileSystem %s\n", fs->basedir); in fs_print_config()
583 printf("\t num_dirs = %u\n", fs->num_dirs); in fs_print_config()
584 printf("\t starting files = %u\n", fs->num_start_files); in fs_print_config()
586 if (fs->num_weights) { in fs_print_config()
589 for (i = 0; i < fs->num_weights; i++) in fs_print_config()
590 printf("\t\t %12llu (%6s) -> %u (%.2f\%)\n", in fs_print_config()
591 fs->size_weights[i].size, in fs_print_config()
592 ffsb_printsize(buf, fs->size_weights[i].size, in fs_print_config()
593 256), fs->size_weights[i].weight, in fs_print_config()
594 ((float)fs->size_weights[i].weight / in fs_print_config()
595 (float)fs->sum_weights) * 100); in fs_print_config()
597 printf("\t min file size = %llu\t(%s)\n", fs->minfilesize, in fs_print_config()
598 ffsb_printsize(buf, fs->minfilesize, 256)); in fs_print_config()
599 printf("\t max file size = %llu\t(%s)\n", fs->maxfilesize, in fs_print_config()
600 ffsb_printsize(buf, fs->maxfilesize, 256)); in fs_print_config()
602 printf("\t directio = %s\n", (fs->flags & FFSB_FS_DIRECTIO) ? in fs_print_config()
604 printf("\t alignedio = %s\n", (fs->flags & FFSB_FS_ALIGNIO4K) ? in fs_print_config()
606 printf("\t bufferedio = %s\n", (fs->flags & FFSB_FS_LIBCIO) ? in fs_print_config()
609 printf("\t aging is %s\n", (fs->age_fs) ? "on" : "off"); in fs_print_config()
611 getfsutil(fs->basedir) * 100); in fs_print_config()
612 if (fs->age_fs) { in fs_print_config()
614 fs->desired_fsutil * 100); in fs_print_config()
616 tg_print_config_aging(fs->aging_tg, fs->basedir); in fs_print_config()
621 int fs_needs_stats(ffsb_fs_t * fs, syscall_t sys) in fs_needs_stats() argument
623 return (fs != NULL) ? (int)fs->fsd.config : 0; in fs_needs_stats()
626 void fs_add_stat(ffsb_fs_t * fs, syscall_t sys, uint32_t val) in fs_add_stat() argument
628 if (fs) in fs_add_stat()
629 ffsb_add_data(&fs->fsd, sys, val); in fs_add_stat()