xref: /freebsd/sys/contrib/openzfs/man/man1/ztest.1 (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1.\" SPDX-License-Identifier: CDDL-1.0
2.\"
3.\" CDDL HEADER START
4.\"
5.\" The contents of this file are subject to the terms of the
6.\" Common Development and Distribution License (the "License").
7.\" You may not use this file except in compliance with the License.
8.\"
9.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10.\" or https://opensource.org/licenses/CDDL-1.0.
11.\" See the License for the specific language governing permissions
12.\" and limitations under the License.
13.\"
14.\" When distributing Covered Code, include this CDDL HEADER in each
15.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16.\" If applicable, add the following below this CDDL HEADER, with the
17.\" fields enclosed by brackets "[]" replaced with your own identifying
18.\" information: Portions Copyright [yyyy] [name of copyright owner]
19.\"
20.\" CDDL HEADER END
21.\"
22.\" Copyright (c) 2009 Oracle and/or its affiliates. All rights reserved.
23.\" Copyright (c) 2009 Michael Gebetsroither <michael.geb@gmx.at>. All rights
24.\" reserved.
25.\" Copyright (c) 2017, Intel Corporation.
26.\"
27.Dd May 26, 2021
28.Dt ZTEST 1
29.Os
30.
31.Sh NAME
32.Nm ztest
33.Nd was written by the ZFS Developers as a ZFS unit test
34.Sh SYNOPSIS
35.Nm
36.Op Fl VEG
37.Op Fl v Ar vdevs
38.Op Fl s Ar size_of_each_vdev
39.Op Fl a Ar alignment_shift
40.Op Fl m Ar mirror_copies
41.Op Fl r Ar raidz_disks/draid_disks
42.Op Fl R Ar raid_parity
43.Op Fl K Ar raid_kind
44.Op Fl D Ar draid_data
45.Op Fl S Ar draid_spares
46.Op Fl C Ar vdev_class_state
47.Op Fl d Ar datasets
48.Op Fl t Ar threads
49.Op Fl g Ar gang_block_threshold
50.Op Fl i Ar initialize_pool_i_times
51.Op Fl k Ar kill_percentage
52.Op Fl p Ar pool_name
53.Op Fl T Ar time
54.Op Fl z Ar zil_failure_rate
55.
56.Nm
57.Fl X
58.Op Fl VG
59.Op Fl s Ar size_of_each_vdev
60.Op Fl a Ar alignment_shift
61.Op Fl r Ar raidz_disks
62.Op Fl R Ar raid_parity
63.Op Fl d Ar datasets
64.Op Fl t Ar threads
65.
66.Sh DESCRIPTION
67.Nm
68was written by the ZFS Developers as a ZFS unit test.
69The tool was developed in tandem with the ZFS functionality and was
70executed nightly as one of the many regression test against the daily build.
71As features were added to ZFS, unit tests were also added to
72.Nm .
73In addition, a separate test development team wrote and
74executed more functional and stress tests.
75.
76.Pp
77By default
78.Nm
79runs for ten minutes and uses block files
80(stored in
81.Pa /tmp )
82to create pools rather than using physical disks.
83Block files afford
84.Nm
85its flexibility to play around with
86zpool components without requiring large hardware configurations.
87However, storing the block files in
88.Pa /tmp
89may not work for you if you
90have a small tmp directory.
91.
92.Pp
93By default is non-verbose.
94This is why entering the command above will result in
95.Nm
96quietly executing for 5 minutes.
97The
98.Fl V
99option can be used to increase the verbosity of the tool.
100Adding multiple
101.Fl V
102options is allowed and the more you add the more chatty
103.Nm
104becomes.
105.
106.Pp
107After the
108.Nm
109run completes, you should notice many
110.Pa ztest.*
111files lying around.
112Once the run completes you can safely remove these files.
113Note that you shouldn't remove these files during a run.
114You can re-use these files in your next
115.Nm
116run by using the
117.Fl E
118option.
119.
120.Sh OPTIONS
121.Bl -tag -width "-v v"
122.It Fl h , \&? , -help
123Print a help summary.
124.It Fl v , -vdevs Ns = (default: Sy 5 )
125Number of vdevs.
126.It Fl s , -vdev-size Ns = (default: Sy 64M )
127Size of each vdev.
128.It Fl a , -alignment-shift Ns = (default: Sy 9 ) No (use Sy 0 No for random )
129Alignment shift used in test.
130.It Fl m , -mirror-copies Ns = (default: Sy 2 )
131Number of mirror copies.
132.It Fl r , -raid-disks Ns = (default: Sy 4 No for raidz/ Ns Sy 16 No for draid )
133Number of raidz/draid disks.
134.It Fl R , -raid-parity Ns = (default: Sy 1 )
135Raid parity (raidz & draid).
136.It Xo
137.Fl K , -raid-kind Ns = Ns
138.Sy raidz Ns | Ns Sy eraidz Ns | Ns Sy draid Ns | Ns Sy random
139(default:
140.Sy random Ns
141)
142.Xc
143The kind of RAID config to use.
144With
145.Sy random
146the kind alternates between raidz, eraidz (expandable raidz) and draid.
147.It Fl D , -draid-data Ns = (default: Sy 4 )
148Number of data disks in a dRAID redundancy group.
149.It Fl S , -draid-spares Ns = (default: Sy 1 )
150Number of dRAID distributed spare disks.
151.It Fl d , -datasets Ns = (default: Sy 7 )
152Number of datasets.
153.It Fl t , -threads Ns = (default: Sy 23 )
154Number of threads.
155.It Fl g , -gang-block-threshold Ns = (default: Sy 32K )
156Gang block threshold.
157.It Fl i , -init-count Ns = (default: Sy 1 )
158Number of pool initializations.
159.It Fl k , -kill-percentage Ns = (default: Sy 70% )
160Kill percentage.
161.It Fl p , -pool-name Ns = (default: Sy ztest )
162Pool name.
163.It Fl f , -vdev-file-directory Ns = (default: Pa /tmp )
164File directory for vdev files.
165.It Fl M , -multi-host
166Multi-host; simulate pool imported on remote host.
167.It Fl E , -use-existing-pool
168Use existing pool (use existing pool instead of creating new one).
169.It Fl T , -run-time Ns = (default: Sy 300 Ns s)
170Total test run time.
171.It Fl P , -pass-time Ns = (default: Sy 60 Ns s)
172Time per pass.
173.It Fl F , -freeze-loops Ns = (default: Sy 50 )
174Max loops in
175.Fn spa_freeze .
176.It Fl B , -alt-ztest Ns =
177Path to alternate ("older")
178.Nm ztest
179to drive, which will be used to initialize the pool, and, a stochastic half the
180time, to run the tests.
181The parallel
182.Pa lib
183directory is prepended to
184.Ev LD_LIBRARY_PATH ;
185i.e. given
186.Fl B Pa ./chroots/lenny/usr/bin/ Ns Nm ,
187.Pa ./chroots/lenny/usr/lib
188will be loaded.
189.It Fl C , -vdev-class-state Ns = Ns Sy on Ns | Ns Sy off Ns | Ns Sy random No (default : Sy random  )
190The vdev allocation class state.
191.It Fl o , -option Ns = Ns Ar variable Ns = Ns Ar value
192Set global
193.Ar variable
194to an unsigned 32-bit integer
195.Ar value
196(little-endian only).
197.It Fl G , -dump-debug
198Dump zfs_dbgmsg buffer before exiting due to an error.
199.It Fl V , -verbose
200Verbose (use multiple times for ever more verbosity).
201.It Fl X , -raidz-expansion
202Perform a dedicated raidz expansion test.
203.El
204.
205.Sh EXAMPLES
206To override
207.Pa /tmp
208as your location for block files, you can use the
209.Fl f
210option:
211.Dl # ztest -f /
212.Pp
213To get an idea of what
214.Nm
215is actually testing try this:
216.Dl # ztest -f / -VVV
217.Pp
218Maybe you'd like to run
219.Nm ztest
220for longer? To do so simply use the
221.Fl T
222option and specify the runlength in seconds like so:
223.Dl # ztest -f / -V -T 120
224.
225.Sh ENVIRONMENT VARIABLES
226.Bl -tag -width "ZF"
227.It Ev ZFS_HOSTID Ns = Ns Em id
228Use
229.Em id
230instead of the SPL hostid to identify this host.
231Intended for use with
232.Nm , but this environment variable will affect any utility which uses
233libzpool, including
234.Xr zpool 8 .
235Since the kernel is unaware of this setting,
236results with utilities other than ztest are undefined.
237.It Ev ZFS_STACK_SIZE Ns = Ns Em stacksize
238Limit the default stack size to
239.Em stacksize
240bytes for the purpose of
241detecting and debugging kernel stack overflows.
242This value defaults to
243.Em 32K
244which is double the default
245.Em 16K
246Linux kernel stack size.
247.Pp
248In practice, setting the stack size slightly higher is needed because
249differences in stack usage between kernel and user space can lead to spurious
250stack overflows (especially when debugging is enabled).
251The specified value
252will be rounded up to a floor of PTHREAD_STACK_MIN which is the minimum stack
253required for a NULL procedure in user space.
254.Pp
255By default the stack size is limited to
256.Em 256K .
257.El
258.
259.Sh SEE ALSO
260.Xr zdb 1 ,
261.Xr zfs 1 ,
262.Xr zpool 1 ,
263.Xr spl 4
264