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 _PARSER_H_ 19#define _PARSER_H_ 20 21#include "ffsb.h" 22#include "list.h" 23 24#define COMMENT_CHAR '#' 25 26#define STORE_SINGLE 0x0001 27#define STORE_LIST 0x0002 28 29#define TYPE_U32 0x0001 30#define TYPE_U64 0x0002 31#define TYPE_STRING 0x0004 32#define TYPE_BOOLEAN 0x0008 33#define TYPE_DOUBLE 0x0010 34#define TYPE_RANGE 0x0020 35#define TYPE_SIZEWEIGHT 0x0040 36#define TYPE_DEPRECATED 0x0080 37#define TYPE_WEIGHT 0x0100 38#define TYPE_SIZE32 0x0200 39#define TYPE_SIZE64 0x0400 40 41#define ROOT 0x0001 42#define THREAD_GROUP 0x0002 43#define FILESYSTEM 0x0004 44#define END 0x0008 45#define STATS 0x0010 46 47#define GLOBAL_OPTIONS { \ 48 {"num_filesystems", NULL, TYPE_DEPRECATED, STORE_SINGLE}, \ 49 {"num_threadgroups", NULL, TYPE_DEPRECATED, STORE_SINGLE}, \ 50 {"verbose", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 51 {"time", NULL, TYPE_U32, STORE_SINGLE}, \ 52 {"directio", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 53 {"bufferio", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 54 {"alignio", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 55 {"callout", NULL, TYPE_STRING, STORE_SINGLE}, \ 56 {NULL, NULL, 0, 0} } 57 58#define THREADGROUP_OPTIONS { \ 59 {"bindfs", NULL, TYPE_STRING, STORE_SINGLE}, \ 60 {"num_threads", NULL, TYPE_U32, STORE_SINGLE}, \ 61 {"read_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 62 {"readall_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 63 {"read_random", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 64 {"read_skip", NULL, TYPE_U32, STORE_SINGLE}, \ 65 {"read_size", NULL, TYPE_SIZE64, STORE_SINGLE}, \ 66 {"read_blocksize", NULL, TYPE_SIZE32, STORE_SINGLE}, \ 67 {"read_skipsize", NULL, TYPE_SIZE32, STORE_SINGLE}, \ 68 {"write_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 69 {"write_fsync_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 70 {"write_random", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 71 {"fsync_file", NULL, TYPE_DEPRECATED, STORE_SINGLE}, \ 72 {"write_size", NULL, TYPE_SIZE64, STORE_SINGLE}, \ 73 {"write_blocksize", NULL, TYPE_SIZE32, STORE_SINGLE}, \ 74 {"create_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 75 {"create_fsync_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 76 {"delete_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 77 {"append_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 78 {"append_fsync_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 79 {"metaop_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 80 {"createdir_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 81 {"op_delay", NULL, TYPE_U32, STORE_SINGLE}, \ 82 {"stat_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 83 {"writeall_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 84 {"writeall_fsync_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 85 {"open_close_weight", NULL, TYPE_WEIGHT, STORE_SINGLE}, \ 86 {NULL, NULL, 0} } 87 88#define FILESYSTEM_OPTIONS { \ 89 {"location", NULL, TYPE_STRING, STORE_SINGLE}, \ 90 {"num_files", NULL, TYPE_U32, STORE_SINGLE}, \ 91 {"num_dirs", NULL, TYPE_U32, STORE_SINGLE}, \ 92 {"reuse", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 93 {"min_filesize", NULL, TYPE_SIZE64, STORE_SINGLE}, \ 94 {"max_filesize", NULL, TYPE_SIZE64, STORE_SINGLE}, \ 95 {"create_blocksize", NULL, TYPE_SIZE32, STORE_SINGLE}, \ 96 {"age_blocksize", NULL, TYPE_SIZE32, STORE_SINGLE}, \ 97 {"desired_util", NULL, TYPE_DOUBLE, STORE_SINGLE}, \ 98 {"agefs", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 99 {"size_weight", NULL, TYPE_SIZEWEIGHT, STORE_LIST}, \ 100 {"init_util", NULL, TYPE_DOUBLE, STORE_SINGLE}, \ 101 {"init_size", NULL, TYPE_SIZE64, STORE_SINGLE}, \ 102 {"clone", NULL, TYPE_STRING, STORE_SINGLE}, \ 103 {NULL, NULL, 0} } 104 105#define STATS_OPTIONS { \ 106 {"enable_stats", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 107 {"enable_range", NULL, TYPE_BOOLEAN, STORE_SINGLE}, \ 108 {"ignore", NULL, TYPE_STRING, STORE_LIST}, \ 109 {"msec_range", NULL, TYPE_RANGE, STORE_LIST}, \ 110 {NULL, NULL, 0} } 111 112#define CONTAINER_DESC { \ 113 {"filesystem", FILESYSTEM, 10}, \ 114 {"threadgroup", THREAD_GROUP, 11}, \ 115 {"end", END, 3}, \ 116 {"stats", STATS, 5}, \ 117 {NULL, 0, 0} } 118 119typedef struct container { 120 struct config_options *config; 121 uint32_t type; 122 struct container *child; 123 struct container *next; 124} container_t; 125 126typedef struct config_options { 127 char *name; 128 void *value; 129 int type; 130 int storage_type; 131} config_options_t; 132 133typedef struct container_desc { 134 char *name; 135 uint16_t type; 136 uint16_t size; 137} container_desc_t; 138 139typedef struct range { 140 double a; 141 double b; 142} range_t; 143 144typedef struct value_list { 145 void *value; 146 struct list_head list; 147} value_list_t; 148 149void ffsb_parse_newconfig(ffsb_config_t *fc, char *filename); 150 151#endif 152