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.
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>.
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>
17 * This file is part of ZFS on Linux.
18 * For details, see <http://zfsonlinux.org/>.
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.
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
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/>.
38 * Contains shared definitions which both the userspace
39 * and kernelspace portions of zpios must agree on.
45 #define ZPIOS_NAME "zpios"
46 #define ZPIOS_DEV "/dev/zpios"
50 #define DMU_WRITE 0x0001
51 #define DMU_READ 0x0002
52 #define DMU_VERIFY 0x0004
53 #define DMU_REMOVE 0x0008
54 #define DMU_FPP 0x0010
55 #define DMU_WRITE_ZC 0x0020 /* Incompatible w/DMU_VERIFY */
56 #define DMU_READ_ZC 0x0040 /* Incompatible w/DMU_VERIFY */
57 #define DMU_WRITE_NOWAIT 0x0080
58 #define DMU_READ_NOPF 0x0100
60 #define ZPIOS_NAME_SIZE 16
61 #define ZPIOS_PATH_SIZE 128
63 #define PHASE_PRE_RUN "pre-run"
64 #define PHASE_PRE_CREATE "pre-create"
65 #define PHASE_PRE_WRITE "pre-write"
66 #define PHASE_PRE_READ "pre-read"
67 #define PHASE_PRE_REMOVE "pre-remove"
68 #define PHASE_POST_RUN "post-run"
69 #define PHASE_POST_CREATE "post-create"
70 #define PHASE_POST_WRITE "post-write"
71 #define PHASE_POST_READ "post-read"
72 #define PHASE_POST_REMOVE "post-remove"
74 #define ZPIOS_CFG_MAGIC 0x87237190U
75 typedef struct zpios_cfg
{
76 uint32_t cfg_magic
; /* Unique magic */
77 int32_t cfg_cmd
; /* Config command */
78 int32_t cfg_arg1
; /* Config command arg 1 */
79 int32_t cfg_rc1
; /* Config response 1 */
82 typedef struct zpios_timespec
{
87 typedef struct zpios_time
{
88 zpios_timespec_t start
;
89 zpios_timespec_t stop
;
90 zpios_timespec_t delta
;
93 typedef struct zpios_stats
{
94 zpios_time_t total_time
;
105 #define ZPIOS_CMD_MAGIC 0x49715385U
106 typedef struct zpios_cmd
{
107 uint32_t cmd_magic
; /* Unique magic */
108 uint32_t cmd_id
; /* Run ID */
109 char cmd_pool
[ZPIOS_NAME_SIZE
]; /* Pool name */
110 uint64_t cmd_chunk_size
; /* Chunk size */
111 uint32_t cmd_thread_count
; /* Thread count */
112 uint32_t cmd_region_count
; /* Region count */
113 uint64_t cmd_region_size
; /* Region size */
114 uint64_t cmd_offset
; /* Region offset */
115 uint32_t cmd_region_noise
; /* Region noise */
116 uint32_t cmd_chunk_noise
; /* Chunk noise */
117 uint32_t cmd_thread_delay
; /* Thread delay */
118 uint32_t cmd_flags
; /* Test flags */
119 char cmd_pre
[ZPIOS_PATH_SIZE
]; /* Pre-exec hook */
120 char cmd_post
[ZPIOS_PATH_SIZE
]; /* Post-exec hook */
121 char cmd_log
[ZPIOS_PATH_SIZE
]; /* Requested log dir */
122 uint64_t cmd_data_size
; /* Opaque data size */
123 char cmd_data_str
[0]; /* Opaque data region */
127 #define ZPIOS_CFG _IOWR('f', 101, zpios_cfg_t)
128 #define ZPIOS_CMD _IOWR('f', 102, zpios_cmd_t)
130 /* Valid configuration commands */
131 #define ZPIOS_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */
132 #define ZPIOS_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */
135 #define NSEC_PER_SEC 1000000000L
140 zpios_timespec_normalize(zpios_timespec_t
*ts
, uint32_t sec
, uint32_t nsec
)
142 while (nsec
>= NSEC_PER_SEC
) {
143 nsec
-= NSEC_PER_SEC
;
147 nsec
+= NSEC_PER_SEC
;
156 zpios_timespec_add(zpios_timespec_t lhs
, zpios_timespec_t rhs
)
158 zpios_timespec_t ts_delta
;
159 zpios_timespec_normalize(&ts_delta
, lhs
.ts_sec
+ rhs
.ts_sec
,
160 lhs
.ts_nsec
+ rhs
.ts_nsec
);
166 zpios_timespec_sub(zpios_timespec_t lhs
, zpios_timespec_t rhs
)
168 zpios_timespec_t ts_delta
;
169 zpios_timespec_normalize(&ts_delta
, lhs
.ts_sec
- rhs
.ts_sec
,
170 lhs
.ts_nsec
- rhs
.ts_nsec
);
178 zpios_timespec_now(void)
180 zpios_timespec_t zts_now
;
181 struct timespec ts_now
;
183 ts_now
= current_kernel_time();
184 zts_now
.ts_sec
= ts_now
.tv_sec
;
185 zts_now
.ts_nsec
= ts_now
.tv_nsec
;
194 zpios_timespec_to_double(zpios_timespec_t ts
)
197 ((double)(ts
.ts_sec
) +
198 ((double)(ts
.ts_nsec
) / (double)(NSEC_PER_SEC
)));
203 #endif /* _ZPIOS_CTL_H */