]>
Commit | Line | Data |
---|---|---|
d1d7e268 | 1 | /* |
302ef151 BB |
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 | |
4e33ba4c | 4 | * against ZFS while still being flexibly controlled from user space. |
302ef151 BB |
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. | |
92db59ca | 18 | * For details, see <http://zfsonlinux.org/>. |
302ef151 BB |
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/>. | |
56b39863 DB |
32 | * |
33 | * Copyright (c) 2015, Intel Corporation. | |
d1d7e268 | 34 | */ |
302ef151 BB |
35 | |
36 | #ifndef _ZPIOS_CTL_H | |
d1d7e268 | 37 | #define _ZPIOS_CTL_H |
302ef151 | 38 | |
d1d7e268 MK |
39 | /* |
40 | * Contains shared definitions which both the userspace | |
302ef151 BB |
41 | * and kernelspace portions of zpios must agree on. |
42 | */ | |
43 | #ifndef _KERNEL | |
44 | #include <stdint.h> | |
45 | #endif | |
46 | ||
d1d7e268 MK |
47 | #define ZPIOS_NAME "zpios" |
48 | #define ZPIOS_DEV "/dev/zpios" | |
49 | ||
50 | #define DMU_IO 0x01 | |
51 | ||
52 | #define DMU_WRITE 0x0001 | |
53 | #define DMU_READ 0x0002 | |
54 | #define DMU_VERIFY 0x0004 | |
55 | #define DMU_REMOVE 0x0008 | |
56 | #define DMU_FPP 0x0010 | |
57 | #define DMU_WRITE_ZC 0x0020 /* Incompatible w/DMU_VERIFY */ | |
58 | #define DMU_READ_ZC 0x0040 /* Incompatible w/DMU_VERIFY */ | |
59 | #define DMU_WRITE_NOWAIT 0x0080 | |
60 | #define DMU_READ_NOPF 0x0100 | |
61 | ||
62 | #define ZPIOS_NAME_SIZE 16 | |
63 | #define ZPIOS_PATH_SIZE 128 | |
64 | ||
65 | #define PHASE_PRE_RUN "pre-run" | |
66 | #define PHASE_PRE_CREATE "pre-create" | |
67 | #define PHASE_PRE_WRITE "pre-write" | |
68 | #define PHASE_PRE_READ "pre-read" | |
69 | #define PHASE_PRE_REMOVE "pre-remove" | |
70 | #define PHASE_POST_RUN "post-run" | |
71 | #define PHASE_POST_CREATE "post-create" | |
72 | #define PHASE_POST_WRITE "post-write" | |
73 | #define PHASE_POST_READ "post-read" | |
74 | #define PHASE_POST_REMOVE "post-remove" | |
302ef151 BB |
75 | |
76 | #define ZPIOS_CFG_MAGIC 0x87237190U | |
77 | typedef struct zpios_cfg { | |
78 | uint32_t cfg_magic; /* Unique magic */ | |
79 | int32_t cfg_cmd; /* Config command */ | |
80 | int32_t cfg_arg1; /* Config command arg 1 */ | |
81 | int32_t cfg_rc1; /* Config response 1 */ | |
82 | } zpios_cfg_t; | |
83 | ||
84 | typedef struct zpios_timespec { | |
85 | uint32_t ts_sec; | |
86 | uint32_t ts_nsec; | |
87 | } zpios_timespec_t; | |
88 | ||
89 | typedef struct zpios_time { | |
90 | zpios_timespec_t start; | |
91 | zpios_timespec_t stop; | |
92 | zpios_timespec_t delta; | |
93 | } zpios_time_t; | |
94 | ||
95 | typedef struct zpios_stats { | |
96 | zpios_time_t total_time; | |
97 | zpios_time_t cr_time; | |
98 | zpios_time_t rm_time; | |
99 | zpios_time_t wr_time; | |
100 | zpios_time_t rd_time; | |
101 | uint64_t wr_data; | |
102 | uint64_t wr_chunks; | |
103 | uint64_t rd_data; | |
104 | uint64_t rd_chunks; | |
105 | } zpios_stats_t; | |
106 | ||
107 | #define ZPIOS_CMD_MAGIC 0x49715385U | |
108 | typedef struct zpios_cmd { | |
109 | uint32_t cmd_magic; /* Unique magic */ | |
110 | uint32_t cmd_id; /* Run ID */ | |
111 | char cmd_pool[ZPIOS_NAME_SIZE]; /* Pool name */ | |
112 | uint64_t cmd_chunk_size; /* Chunk size */ | |
113 | uint32_t cmd_thread_count; /* Thread count */ | |
114 | uint32_t cmd_region_count; /* Region count */ | |
115 | uint64_t cmd_region_size; /* Region size */ | |
116 | uint64_t cmd_offset; /* Region offset */ | |
117 | uint32_t cmd_region_noise; /* Region noise */ | |
118 | uint32_t cmd_chunk_noise; /* Chunk noise */ | |
119 | uint32_t cmd_thread_delay; /* Thread delay */ | |
120 | uint32_t cmd_flags; /* Test flags */ | |
56b39863 | 121 | uint32_t cmd_block_size; /* ZFS block size */ |
d1d7e268 MK |
122 | char cmd_pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */ |
123 | char cmd_post[ZPIOS_PATH_SIZE]; /* Post-exec hook */ | |
302ef151 BB |
124 | char cmd_log[ZPIOS_PATH_SIZE]; /* Requested log dir */ |
125 | uint64_t cmd_data_size; /* Opaque data size */ | |
126 | char cmd_data_str[0]; /* Opaque data region */ | |
127 | } zpios_cmd_t; | |
128 | ||
129 | /* Valid ioctls */ | |
d1d7e268 MK |
130 | #define ZPIOS_CFG _IOWR('f', 101, zpios_cfg_t) |
131 | #define ZPIOS_CMD _IOWR('f', 102, zpios_cmd_t) | |
302ef151 BB |
132 | |
133 | /* Valid configuration commands */ | |
d1d7e268 MK |
134 | #define ZPIOS_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */ |
135 | #define ZPIOS_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */ | |
302ef151 BB |
136 | |
137 | #ifndef NSEC_PER_SEC | |
d1d7e268 | 138 | #define NSEC_PER_SEC 1000000000L |
302ef151 BB |
139 | #endif |
140 | ||
141 | static inline | |
d1d7e268 MK |
142 | void |
143 | zpios_timespec_normalize(zpios_timespec_t *ts, uint32_t sec, uint32_t nsec) | |
302ef151 BB |
144 | { |
145 | while (nsec >= NSEC_PER_SEC) { | |
146 | nsec -= NSEC_PER_SEC; | |
147 | sec++; | |
148 | } | |
3bfd95d5 | 149 | while (((int32_t)nsec) < 0) { |
302ef151 BB |
150 | nsec += NSEC_PER_SEC; |
151 | sec--; | |
152 | } | |
153 | ts->ts_sec = sec; | |
154 | ts->ts_nsec = nsec; | |
155 | } | |
156 | ||
157 | static inline | |
d1d7e268 MK |
158 | zpios_timespec_t |
159 | zpios_timespec_add(zpios_timespec_t lhs, zpios_timespec_t rhs) | |
302ef151 BB |
160 | { |
161 | zpios_timespec_t ts_delta; | |
162 | zpios_timespec_normalize(&ts_delta, lhs.ts_sec + rhs.ts_sec, | |
d1d7e268 MK |
163 | lhs.ts_nsec + rhs.ts_nsec); |
164 | return (ts_delta); | |
302ef151 BB |
165 | } |
166 | ||
167 | static inline | |
d1d7e268 MK |
168 | zpios_timespec_t |
169 | zpios_timespec_sub(zpios_timespec_t lhs, zpios_timespec_t rhs) | |
302ef151 BB |
170 | { |
171 | zpios_timespec_t ts_delta; | |
172 | zpios_timespec_normalize(&ts_delta, lhs.ts_sec - rhs.ts_sec, | |
d1d7e268 MK |
173 | lhs.ts_nsec - rhs.ts_nsec); |
174 | return (ts_delta); | |
302ef151 BB |
175 | } |
176 | ||
177 | #ifdef _KERNEL | |
178 | ||
179 | static inline | |
d1d7e268 MK |
180 | zpios_timespec_t |
181 | zpios_timespec_now(void) | |
302ef151 BB |
182 | { |
183 | zpios_timespec_t zts_now; | |
184 | struct timespec ts_now; | |
185 | ||
186 | ts_now = current_kernel_time(); | |
187 | zts_now.ts_sec = ts_now.tv_sec; | |
188 | zts_now.ts_nsec = ts_now.tv_nsec; | |
189 | ||
d1d7e268 | 190 | return (zts_now); |
302ef151 BB |
191 | } |
192 | ||
193 | #else | |
194 | ||
195 | static inline | |
d1d7e268 MK |
196 | double |
197 | zpios_timespec_to_double(zpios_timespec_t ts) | |
302ef151 | 198 | { |
d1d7e268 MK |
199 | return |
200 | ((double)(ts.ts_sec) + | |
201 | ((double)(ts.ts_nsec) / (double)(NSEC_PER_SEC))); | |
302ef151 BB |
202 | } |
203 | ||
204 | #endif /* _KERNEL */ | |
205 | ||
206 | #endif /* _ZPIOS_CTL_H */ |