- struct rb_node **p, *parent;
-
- memset(&n->rb, 0, sizeof(n->rb));
- p = &rb.rb_node;
- parent = NULL;
- while (*p) {
- struct node *__n;
-
- parent = *p;
- __n = rb_entry(parent, struct node, rb);
- if (n->hits > __n->hits)
- p = &(*p)->rb_left;
- else
- p = &(*p)->rb_right;
+ printf("genzipf: test zipf/pareto values for fio input\n");
+ printf("\t-h\tThis help screen\n");
+ printf("\t-p\tGenerate size of data set that are hit by this percentage\n");
+ printf("\t-t\tDistribution type (zipf, pareto, or normal)\n");
+ printf("\t-i\tDistribution algorithm input (zipf theta, pareto power,\n"
+ "\t\tor normal %% deviation)\n");
+ printf("\t-b\tBlock size of a given range (in bytes)\n");
+ printf("\t-g\tSize of data set (in gigabytes)\n");
+ printf("\t-o\tNumber of output rows\n");
+ printf("\t-c\tOutput ranges in CSV format\n");
+}
+
+static int parse_options(int argc, char *argv[])
+{
+ const char *optstring = "t:g:i:o:b:p:ch";
+ int c, dist_val_set = 0;
+
+ while ((c = getopt(argc, argv, optstring)) != -1) {
+ switch (c) {
+ case 'h':
+ usage();
+ return 1;
+ case 'p':
+ percentage = atof(optarg);
+ break;
+ case 'b':
+ block_size = strtoul(optarg, NULL, 10);
+ break;
+ case 't':
+ if (!strncmp(optarg, "zipf", 4))
+ dist_type = TYPE_ZIPF;
+ else if (!strncmp(optarg, "pareto", 6))
+ dist_type = TYPE_PARETO;
+ else if (!strncmp(optarg, "normal", 6))
+ dist_type = TYPE_NORMAL;
+ else {
+ printf("wrong dist type: %s\n", optarg);
+ return 1;
+ }
+ break;
+ case 'g':
+ gb_size = strtoul(optarg, NULL, 10);
+ break;
+ case 'i':
+ dist_val = atof(optarg);
+ dist_val_set = 1;
+ break;
+ case 'o':
+ output_nranges = strtoul(optarg, NULL, 10);
+ break;
+ case 'c':
+ output_type = OUTPUT_CSV;
+ break;
+ default:
+ printf("bad option %c\n", c);
+ return 1;
+ }