]> git.proxmox.com Git - mirror_zfs.git/blob - cmd/zpios/zpios.h
Add linux zpios support
[mirror_zfs.git] / cmd / zpios / zpios.h
1 /*****************************************************************************\
2 * ZPIOS is a heavily modified version of the original PIOS test code.
3 * It is designed to have the test code running in the Linux kernel
4 * against ZFS while still being flexibly controled from user space.
5 *
6 * Copyright (C) 2008-2010 Lawrence Livermore National Security, LLC.
7 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
8 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
9 * LLNL-CODE-403049
10 *
11 * Original PIOS Test Code
12 * Copyright (C) 2004 Cluster File Systems, Inc.
13 * Written by Peter Braam <braam@clusterfs.com>
14 * Atul Vidwansa <atul@clusterfs.com>
15 * Milind Dumbare <milind@clusterfs.com>
16 *
17 * This file is part of ZFS on Linux.
18 * For details, see <http://github.com/behlendorf/zfs/>.
19 *
20 * ZPIOS is free software; you can redistribute it and/or modify it
21 * under the terms of the GNU General Public License as published by the
22 * Free Software Foundation; either version 2 of the License, or (at your
23 * option) any later version.
24 *
25 * ZPIOS is distributed in the hope that it will be useful, but WITHOUT
26 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 * for more details.
29 *
30 * You should have received a copy of the GNU General Public License along
31 * with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
32 \*****************************************************************************/
33
34 #ifndef _ZPIOS_H
35 #define _ZPIOS_H
36
37 #include <zpios-ctl.h>
38
39 #define VERSION_SIZE 64
40
41 /* Regular expressions */
42 #define REGEX_NUMBERS "^[0-9]*[0-9]$"
43 #define REGEX_NUMBERS_COMMA "^([0-9]+,)*[0-9]+$"
44 #define REGEX_SIZE "^[0-9][0-9]*[kmgt]$"
45 #define REGEX_SIZE_COMMA "^([0-9][0-9]*[kmgt]+,)*[0-9][0-9]*[kmgt]$"
46
47 /* Flags for low, high, incr */
48 #define FLAG_SET 0x01
49 #define FLAG_LOW 0x02
50 #define FLAG_HIGH 0x04
51 #define FLAG_INCR 0x08
52
53 #define TRUE 1
54 #define FALSE 0
55
56 #define KB (1024)
57 #define MB (KB * 1024)
58 #define GB (MB * 1024)
59 #define TB (GB * 1024)
60
61 #define KMGT_SIZE 16
62
63 /* All offsets, sizes and counts can be passed to the application in
64 * multiple ways.
65 * 1. a value (stored in val[0], val_count will be 1)
66 * 2. a comma separated list of values (stored in val[], using val_count)
67 * 3. a range and block sizes, low, high, factor (val_count must be 0)
68 */
69 typedef struct pios_range_repeat {
70 uint64_t val[32]; /* Comma sep array, or low, high, inc */
71 uint64_t val_count; /* Num of values */
72 uint64_t val_low;
73 uint64_t val_high;
74 uint64_t val_inc_perc;
75 uint64_t next_val; /* Used for multiple runs in get_next() */
76 } range_repeat_t;
77
78 typedef struct cmd_args {
79 range_repeat_t T; /* Thread count */
80 range_repeat_t N; /* Region count */
81 range_repeat_t O; /* Offset count */
82 range_repeat_t C; /* Chunksize */
83 range_repeat_t S; /* Regionsize */
84
85 const char *pool; /* Pool */
86 const char *name; /* Name */
87 uint32_t flags; /* Flags */
88 uint32_t io_type; /* DMUIO only */
89 uint32_t verbose; /* Verbose */
90 uint32_t human_readable; /* Human readable output */
91
92 uint64_t regionnoise; /* Region noise */
93 uint64_t chunknoise; /* Chunk noise */
94 uint64_t thread_delay; /* Thread delay */
95
96 char pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */
97 char post[ZPIOS_PATH_SIZE]; /* Post-exec hook */
98 char log[ZPIOS_PATH_SIZE]; /* Requested log dir */
99
100 /* Control */
101 int current_id;
102 uint64_t current_T;
103 uint64_t current_N;
104 uint64_t current_C;
105 uint64_t current_S;
106 uint64_t current_O;
107
108 uint32_t rc;
109 } cmd_args_t;
110
111 int set_count(char *pattern1, char *pattern2, range_repeat_t *range,
112 char *optarg, uint32_t *flags, char *arg);
113 int set_lhi(char *pattern, range_repeat_t *range, char *optarg,
114 int flag, uint32_t *flag_thread, char *arg);
115 int set_noise(uint64_t *noise, char *optarg, char *arg);
116 int set_load_params(cmd_args_t *args, char *optarg);
117 int check_mutual_exclusive_command_lines(uint32_t flag, char *arg);
118 void print_stats_header(cmd_args_t *args);
119 void print_stats(cmd_args_t *args, zpios_cmd_t *cmd);
120
121 #endif /* _ZPIOS_H */