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