1*61145dc2SMartin Matuska.\" SPDX-License-Identifier: CDDL-1.0 2eda14cbcSMatt Macy.\" 3eda14cbcSMatt Macy.\" CDDL HEADER START 4eda14cbcSMatt Macy.\" 5eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the 6eda14cbcSMatt Macy.\" Common Development and Distribution License (the "License"). 7eda14cbcSMatt Macy.\" You may not use this file except in compliance with the License. 8eda14cbcSMatt Macy.\" 9eda14cbcSMatt Macy.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10271171e0SMartin Matuska.\" or https://opensource.org/licenses/CDDL-1.0. 11eda14cbcSMatt Macy.\" See the License for the specific language governing permissions 12eda14cbcSMatt Macy.\" and limitations under the License. 13eda14cbcSMatt Macy.\" 14eda14cbcSMatt Macy.\" When distributing Covered Code, include this CDDL HEADER in each 15eda14cbcSMatt Macy.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16eda14cbcSMatt Macy.\" If applicable, add the following below this CDDL HEADER, with the 17eda14cbcSMatt Macy.\" fields enclosed by brackets "[]" replaced with your own identifying 18eda14cbcSMatt Macy.\" information: Portions Copyright [yyyy] [name of copyright owner] 19eda14cbcSMatt Macy.\" 20eda14cbcSMatt Macy.\" CDDL HEADER END 21eda14cbcSMatt Macy.\" 22eda14cbcSMatt Macy.\" Copyright 2013 Darik Horn <dajhorn@vanadac.com>. All rights reserved. 23c6767dc1SMartin Matuska.\" Copyright (c) 2024, 2025, Klara, Inc. 24eda14cbcSMatt Macy.\" 2516038816SMartin Matuska.\" lint-ok: WARNING: sections out of conventional order: Sh SYNOPSIS 2616038816SMartin Matuska.\" 27c6767dc1SMartin Matuska.Dd January 14, 2025 2816038816SMartin Matuska.Dt ZINJECT 8 2916038816SMartin Matuska.Os 3016038816SMartin Matuska. 3116038816SMartin Matuska.Sh NAME 3216038816SMartin Matuska.Nm zinject 3316038816SMartin Matuska.Nd ZFS Fault Injector 3416038816SMartin Matuska.Sh DESCRIPTION 3516038816SMartin Matuska.Nm 3616038816SMartin Matuskacreates artificial problems in a ZFS pool by simulating data corruption 3716038816SMartin Matuskaor device failures. 3816038816SMartin MatuskaThis program is dangerous. 3916038816SMartin Matuska. 4016038816SMartin Matuska.Sh SYNOPSIS 4116038816SMartin Matuska.Bl -tag -width Ds 4216038816SMartin Matuska.It Xo 4316038816SMartin Matuska.Nm zinject 4416038816SMartin Matuska.Xc 45eda14cbcSMatt MacyList injection records. 4616038816SMartin Matuska. 4716038816SMartin Matuska.It Xo 4816038816SMartin Matuska.Nm zinject 4916038816SMartin Matuska.Fl b Ar objset : Ns Ar object : Ns Ar level : Ns Ar start : Ns Ar end 5016038816SMartin Matuska.Op Fl f Ar frequency 5116038816SMartin Matuska.Fl amu 5216038816SMartin Matuska.Op pool 5316038816SMartin Matuska.Xc 54eda14cbcSMatt MacyForce an error into the pool at a bookmark. 5516038816SMartin Matuska. 5616038816SMartin Matuska.It Xo 5716038816SMartin Matuska.Nm zinject 5816038816SMartin Matuska.Fl c Ar id Ns | Ns Sy all 5916038816SMartin Matuska.Xc 60eda14cbcSMatt MacyCancel injection records. 6116038816SMartin Matuska. 6216038816SMartin Matuska.It Xo 6316038816SMartin Matuska.Nm zinject 6416038816SMartin Matuska.Fl d Ar vdev 6516038816SMartin Matuska.Fl A Sy degrade Ns | Ns Sy fault 6616038816SMartin Matuska.Ar pool 6716038816SMartin Matuska.Xc 68eda14cbcSMatt MacyForce a vdev into the DEGRADED or FAULTED state. 6916038816SMartin Matuska. 7016038816SMartin Matuska.It Xo 7116038816SMartin Matuska.Nm zinject 7216038816SMartin Matuska.Fl d Ar vdev 7316038816SMartin Matuska.Fl D Ar latency : Ns Ar lanes 74e2257b31SMartin Matuska.Op Fl T Ar read|write 7516038816SMartin Matuska.Ar pool 7616038816SMartin Matuska.Xc 77c03c5b1cSMartin MatuskaAdd an artificial delay to I/O requests on a particular 7816038816SMartin Matuskadevice, such that the requests take a minimum of 7916038816SMartin Matuska.Ar latency 8016038816SMartin Matuskamilliseconds to complete. 8116038816SMartin MatuskaEach delay has an associated number of 8216038816SMartin Matuska.Ar lanes 8316038816SMartin Matuskawhich defines the number of concurrent 84c03c5b1cSMartin MatuskaI/O requests that can be processed. 8516038816SMartin Matuska.Pp 8616038816SMartin MatuskaFor example, with a single lane delay of 10 ms 8716038816SMartin Matuska.No (\& Ns Fl D Ar 10 : Ns Ar 1 ) , 88c03c5b1cSMartin Matuskathe device will only be able to service a single I/O request 8916038816SMartin Matuskaat a time with each request taking 10 ms to complete. 9016038816SMartin MatuskaSo, if only a single request is submitted every 10 ms, the 91eda14cbcSMatt Macyaverage latency will be 10 ms; but if more than one request 92eda14cbcSMatt Macyis submitted every 10 ms, the average latency will be more 93eda14cbcSMatt Macythan 10 ms. 9416038816SMartin Matuska.Pp 95eda14cbcSMatt MacySimilarly, if a delay of 10 ms is specified to have two 9616038816SMartin Matuskalanes 9716038816SMartin Matuska.No (\& Ns Fl D Ar 10 : Ns Ar 2 ) , 9816038816SMartin Matuskathen the device will be able to service 9916038816SMartin Matuskatwo requests at a time, each with a minimum latency of 10 ms. 10016038816SMartin MatuskaSo, if two requests are submitted every 10 ms, then 101eda14cbcSMatt Macythe average latency will be 10 ms; but if more than two 102eda14cbcSMatt Macyrequests are submitted every 10 ms, the average latency 103eda14cbcSMatt Macywill be more than 10 ms. 10416038816SMartin Matuska.Pp 10516038816SMartin MatuskaAlso note, these delays are additive. 10616038816SMartin MatuskaSo two invocations of 10716038816SMartin Matuska.Fl D Ar 10 : Ns Ar 1 10816038816SMartin Matuskaare roughly equivalent to a single invocation of 10916038816SMartin Matuska.Fl D Ar 10 : Ns Ar 2 . 11016038816SMartin MatuskaThis also means, that one can specify multiple 11116038816SMartin Matuskalanes with differing target latencies. 11216038816SMartin MatuskaFor example, an invocation of 11316038816SMartin Matuska.Fl D Ar 10 : Ns Ar 1 11416038816SMartin Matuskafollowed by 11516038816SMartin Matuska.Fl D Ar 25 : Ns Ar 2 11616038816SMartin Matuskawill create 3 lanes on the device: one lane with a latency 117eda14cbcSMatt Macyof 10 ms and two lanes with a 25 ms latency. 11816038816SMartin Matuska. 11916038816SMartin Matuska.It Xo 12016038816SMartin Matuska.Nm zinject 12116038816SMartin Matuska.Fl d Ar vdev 12216038816SMartin Matuska.Op Fl e Ar device_error 12316038816SMartin Matuska.Op Fl L Ar label_error 12416038816SMartin Matuska.Op Fl T Ar failure 12516038816SMartin Matuska.Op Fl f Ar frequency 12616038816SMartin Matuska.Op Fl F 12716038816SMartin Matuska.Ar pool 12816038816SMartin Matuska.Xc 129eda14cbcSMatt MacyForce a vdev error. 13016038816SMartin Matuska. 13116038816SMartin Matuska.It Xo 13216038816SMartin Matuska.Nm zinject 1330d4ad640SMartin Matuska.Fl i Ar seconds 1340d4ad640SMartin Matuska.Ar pool 1350d4ad640SMartin Matuska.Xc 1360d4ad640SMartin MatuskaAdd an artificial delay during the future import of a pool. 1370d4ad640SMartin MatuskaThis injector is automatically cleared after the import is finished. 1380d4ad640SMartin Matuska. 1390d4ad640SMartin Matuska.It Xo 1400d4ad640SMartin Matuska.Nm zinject 14116038816SMartin Matuska.Fl I 14216038816SMartin Matuska.Op Fl s Ar seconds Ns | Ns Fl g Ar txgs 14316038816SMartin Matuska.Ar pool 14416038816SMartin Matuska.Xc 145eda14cbcSMatt MacySimulate a hardware failure that fails to honor a cache flush. 14616038816SMartin Matuska. 14716038816SMartin Matuska.It Xo 14816038816SMartin Matuska.Nm zinject 14916038816SMartin Matuska.Fl p Ar function 15016038816SMartin Matuska.Ar pool 15116038816SMartin Matuska.Xc 152eda14cbcSMatt MacyPanic inside the specified function. 15316038816SMartin Matuska. 15416038816SMartin Matuska.It Xo 15516038816SMartin Matuska.Nm zinject 15616038816SMartin Matuska.Fl t Sy data 15716038816SMartin Matuska.Fl C Ar dvas 15816038816SMartin Matuska.Op Fl e Ar device_error 15916038816SMartin Matuska.Op Fl f Ar frequency 16016038816SMartin Matuska.Op Fl l Ar level 16116038816SMartin Matuska.Op Fl r Ar range 16216038816SMartin Matuska.Op Fl amq 16316038816SMartin Matuska.Ar path 16416038816SMartin Matuska.Xc 165eda14cbcSMatt MacyForce an error into the contents of a file. 16616038816SMartin Matuska. 16716038816SMartin Matuska.It Xo 16816038816SMartin Matuska.Nm zinject 16916038816SMartin Matuska.Fl t Sy dnode 17016038816SMartin Matuska.Fl C Ar dvas 17116038816SMartin Matuska.Op Fl e Ar device_error 17216038816SMartin Matuska.Op Fl f Ar frequency 17316038816SMartin Matuska.Op Fl l Ar level 17416038816SMartin Matuska.Op Fl amq 17516038816SMartin Matuska.Ar path 17616038816SMartin Matuska.Xc 177eda14cbcSMatt MacyForce an error into the metadnode for a file or directory. 17816038816SMartin Matuska. 17916038816SMartin Matuska.It Xo 18016038816SMartin Matuska.Nm zinject 18116038816SMartin Matuska.Fl t Ar mos_type 18216038816SMartin Matuska.Fl C Ar dvas 18316038816SMartin Matuska.Op Fl e Ar device_error 18416038816SMartin Matuska.Op Fl f Ar frequency 18516038816SMartin Matuska.Op Fl l Ar level 18616038816SMartin Matuska.Op Fl r Ar range 18716038816SMartin Matuska.Op Fl amqu 18816038816SMartin Matuska.Ar pool 18916038816SMartin Matuska.Xc 190eda14cbcSMatt MacyForce an error into the MOS of a pool. 19116038816SMartin Matuska.El 19216038816SMartin Matuska.Sh OPTIONS 19316038816SMartin Matuska.Bl -tag -width "-C dvas" 19416038816SMartin Matuska.It Fl a 195eda14cbcSMatt MacyFlush the ARC before injection. 19616038816SMartin Matuska.It Fl b Ar objset : Ns Ar object : Ns Ar level : Ns Ar start : Ns Ar end 19716038816SMartin MatuskaForce an error into the pool at this bookmark tuple. 19816038816SMartin MatuskaEach number is in hexadecimal, and only one block can be specified. 19916038816SMartin Matuska.It Fl C Ar dvas 20016038816SMartin MatuskaInject the given error only into specific DVAs. 20116038816SMartin MatuskaThe mask should be specified as a list of 0-indexed DVAs separated by commas 202c03c5b1cSMartin Matuska.No (e.g . Ar 0,2 Ns No ). 20316038816SMartin MatuskaThis option is not applicable to logical data errors such as 20416038816SMartin Matuska.Sy decompress 205eda14cbcSMatt Macyand 20616038816SMartin Matuska.Sy decrypt . 20716038816SMartin Matuska.It Fl d Ar vdev 208eda14cbcSMatt MacyA vdev specified by path or GUID. 20916038816SMartin Matuska.It Fl e Ar device_error 210eda14cbcSMatt MacySpecify 21116038816SMartin Matuska.Bl -tag -compact -width "decompress" 21216038816SMartin Matuska.It Sy checksum 21316038816SMartin Matuskafor an ECKSUM error, 21416038816SMartin Matuska.It Sy decompress 21516038816SMartin Matuskafor a data decompression error, 21616038816SMartin Matuska.It Sy decrypt 21716038816SMartin Matuskafor a data decryption error, 21816038816SMartin Matuska.It Sy corrupt 21916038816SMartin Matuskato flip a bit in the data after a read, 22016038816SMartin Matuska.It Sy dtl 22116038816SMartin Matuskafor an ECHILD error, 22216038816SMartin Matuska.It Sy io 2231719886fSMartin Matuskafor an EIO error where reopening the device will succeed, 22416038816SMartin Matuska.It Sy nxio 2251719886fSMartin Matuskafor an ENXIO error where reopening the device will fail, or 2261719886fSMartin Matuska.It Sy noop 2271719886fSMartin Matuskato drop the IO without executing it, and return success. 22816038816SMartin Matuska.El 22916038816SMartin Matuska.Pp 23016038816SMartin MatuskaFor EIO and ENXIO, the "failed" reads or writes still occur. 23116038816SMartin MatuskaThe probe simply sets the error value reported by the I/O pipeline 23216038816SMartin Matuskaso it appears the read or write failed. 23316038816SMartin MatuskaDecryption errors only currently work with file data. 23416038816SMartin Matuska.It Fl f Ar frequency 23516038816SMartin MatuskaOnly inject errors a fraction of the time. 23616038816SMartin MatuskaExpressed as a real number percentage between 23716038816SMartin Matuska.Sy 0.0001 23816038816SMartin Matuskaand 23916038816SMartin Matuska.Sy 100 . 24016038816SMartin Matuska.It Fl F 24116038816SMartin MatuskaFail faster. 24216038816SMartin MatuskaDo fewer checks. 24316038816SMartin Matuska.It Fl f Ar txgs 244eda14cbcSMatt MacyRun for this many transaction groups before reporting failure. 24516038816SMartin Matuska.It Fl h 246eda14cbcSMatt MacyPrint the usage message. 24716038816SMartin Matuska.It Fl l Ar level 24816038816SMartin MatuskaInject an error at a particular block level. 24916038816SMartin MatuskaThe default is 25016038816SMartin Matuska.Sy 0 . 25116038816SMartin Matuska.It Fl L Ar label_error 252eda14cbcSMatt MacySet the label error region to one of 25316038816SMartin Matuska.Sy nvlist , 25416038816SMartin Matuska.Sy pad1 , 25516038816SMartin Matuska.Sy pad2 , 25616038816SMartin Matuskaor 25716038816SMartin Matuska.Sy uber . 25816038816SMartin Matuska.It Fl m 259eda14cbcSMatt MacyAutomatically remount the underlying filesystem. 26016038816SMartin Matuska.It Fl q 26116038816SMartin MatuskaQuiet mode. 26216038816SMartin MatuskaOnly print the handler number added. 26316038816SMartin Matuska.It Fl r Ar range 264eda14cbcSMatt MacyInject an error over a particular logical range of an object, which 265eda14cbcSMatt Macywill be translated to the appropriate blkid range according to the 266eda14cbcSMatt Macyobject's properties. 26716038816SMartin Matuska.It Fl s Ar seconds 268eda14cbcSMatt MacyRun for this many seconds before reporting failure. 269c6767dc1SMartin Matuska.It Fl T Ar type 270c6767dc1SMartin MatuskaInject the error into I/O of this type. 271c6767dc1SMartin Matuska.Bl -tag -compact -width "read, write, flush, claim, free" 272c6767dc1SMartin Matuska.It Sy read , Sy write , Sy flush , Sy claim , Sy free 273c6767dc1SMartin MatuskaFundamental I/O types 274c6767dc1SMartin Matuska.It Sy all 275c6767dc1SMartin MatuskaAll fundamental I/O types 276c6767dc1SMartin Matuska.It Sy probe 277c6767dc1SMartin MatuskaDevice probe I/O 278c6767dc1SMartin Matuska.El 27916038816SMartin Matuska.It Fl t Ar mos_type 280eda14cbcSMatt MacySet this to 28116038816SMartin Matuska.Bl -tag -compact -width "spacemap" 28216038816SMartin Matuska.It Sy mos 28316038816SMartin Matuskafor any data in the MOS, 28416038816SMartin Matuska.It Sy mosdir 28516038816SMartin Matuskafor an object directory, 28616038816SMartin Matuska.It Sy config 28716038816SMartin Matuskafor the pool configuration, 28816038816SMartin Matuska.It Sy bpobj 28916038816SMartin Matuskafor the block pointer list, 29016038816SMartin Matuska.It Sy spacemap 29116038816SMartin Matuskafor the space map, 29216038816SMartin Matuska.It Sy metaslab 29316038816SMartin Matuskafor the metaslab, or 29416038816SMartin Matuska.It Sy errlog 29516038816SMartin Matuskafor the persistent error log. 29616038816SMartin Matuska.El 29716038816SMartin Matuska.It Fl u 298eda14cbcSMatt MacyUnload the pool after injection. 29916038816SMartin Matuska.El 30016038816SMartin Matuska. 30116038816SMartin Matuska.Sh ENVIRONMENT VARIABLES 30216038816SMartin Matuska.Bl -tag -width "ZF" 30316038816SMartin Matuska.It Ev ZFS_HOSTID 30416038816SMartin MatuskaRun 30516038816SMartin Matuska.Nm 30616038816SMartin Matuskain debug mode. 30716038816SMartin Matuska.El 30816038816SMartin Matuska. 30916038816SMartin Matuska.Sh SEE ALSO 31016038816SMartin Matuska.Xr zfs 8 , 31116038816SMartin Matuska.Xr zpool 8 312