1eda14cbcSMatt Macy.\" 2eda14cbcSMatt Macy.\" CDDL HEADER START 3eda14cbcSMatt Macy.\" 4eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the 5eda14cbcSMatt Macy.\" Common Development and Distribution License (the "License"). 6eda14cbcSMatt Macy.\" You may not use this file except in compliance with the License. 7eda14cbcSMatt Macy.\" 8eda14cbcSMatt Macy.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9271171e0SMartin Matuska.\" or https://opensource.org/licenses/CDDL-1.0. 10eda14cbcSMatt Macy.\" See the License for the specific language governing permissions 11eda14cbcSMatt Macy.\" and limitations under the License. 12eda14cbcSMatt Macy.\" 13eda14cbcSMatt Macy.\" When distributing Covered Code, include this CDDL HEADER in each 14eda14cbcSMatt Macy.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15eda14cbcSMatt Macy.\" If applicable, add the following below this CDDL HEADER, with the 16eda14cbcSMatt Macy.\" fields enclosed by brackets "[]" replaced with your own identifying 17eda14cbcSMatt Macy.\" information: Portions Copyright [yyyy] [name of copyright owner] 18eda14cbcSMatt Macy.\" 19eda14cbcSMatt Macy.\" CDDL HEADER END 20eda14cbcSMatt Macy.\" 21eda14cbcSMatt Macy.\" Copyright 2013 Darik Horn <dajhorn@vanadac.com>. All rights reserved. 22*1719886fSMartin Matuska.\" Copyright (c) 2024, Klara Inc. 23eda14cbcSMatt Macy.\" 2416038816SMartin Matuska.\" lint-ok: WARNING: sections out of conventional order: Sh SYNOPSIS 2516038816SMartin Matuska.\" 26*1719886fSMartin Matuska.Dd April 4, 2024 2716038816SMartin Matuska.Dt ZINJECT 8 2816038816SMartin Matuska.Os 2916038816SMartin Matuska. 3016038816SMartin Matuska.Sh NAME 3116038816SMartin Matuska.Nm zinject 3216038816SMartin Matuska.Nd ZFS Fault Injector 3316038816SMartin Matuska.Sh DESCRIPTION 3416038816SMartin Matuska.Nm 3516038816SMartin Matuskacreates artificial problems in a ZFS pool by simulating data corruption 3616038816SMartin Matuskaor device failures. 3716038816SMartin MatuskaThis program is dangerous. 3816038816SMartin Matuska. 3916038816SMartin Matuska.Sh SYNOPSIS 4016038816SMartin Matuska.Bl -tag -width Ds 4116038816SMartin Matuska.It Xo 4216038816SMartin Matuska.Nm zinject 4316038816SMartin Matuska.Xc 44eda14cbcSMatt MacyList injection records. 4516038816SMartin Matuska. 4616038816SMartin Matuska.It Xo 4716038816SMartin Matuska.Nm zinject 4816038816SMartin Matuska.Fl b Ar objset : Ns Ar object : Ns Ar level : Ns Ar start : Ns Ar end 4916038816SMartin Matuska.Op Fl f Ar frequency 5016038816SMartin Matuska.Fl amu 5116038816SMartin Matuska.Op pool 5216038816SMartin Matuska.Xc 53eda14cbcSMatt MacyForce an error into the pool at a bookmark. 5416038816SMartin Matuska. 5516038816SMartin Matuska.It Xo 5616038816SMartin Matuska.Nm zinject 5716038816SMartin Matuska.Fl c Ar id Ns | Ns Sy all 5816038816SMartin Matuska.Xc 59eda14cbcSMatt MacyCancel injection records. 6016038816SMartin Matuska. 6116038816SMartin Matuska.It Xo 6216038816SMartin Matuska.Nm zinject 6316038816SMartin Matuska.Fl d Ar vdev 6416038816SMartin Matuska.Fl A Sy degrade Ns | Ns Sy fault 6516038816SMartin Matuska.Ar pool 6616038816SMartin Matuska.Xc 67eda14cbcSMatt MacyForce a vdev into the DEGRADED or FAULTED state. 6816038816SMartin Matuska. 6916038816SMartin Matuska.It Xo 7016038816SMartin Matuska.Nm zinject 7116038816SMartin Matuska.Fl d Ar vdev 7216038816SMartin Matuska.Fl D Ar latency : Ns Ar lanes 73e2257b31SMartin Matuska.Op Fl T Ar read|write 7416038816SMartin Matuska.Ar pool 7516038816SMartin Matuska.Xc 76c03c5b1cSMartin MatuskaAdd an artificial delay to I/O requests on a particular 7716038816SMartin Matuskadevice, such that the requests take a minimum of 7816038816SMartin Matuska.Ar latency 7916038816SMartin Matuskamilliseconds to complete. 8016038816SMartin MatuskaEach delay has an associated number of 8116038816SMartin Matuska.Ar lanes 8216038816SMartin Matuskawhich defines the number of concurrent 83c03c5b1cSMartin MatuskaI/O requests that can be processed. 8416038816SMartin Matuska.Pp 8516038816SMartin MatuskaFor example, with a single lane delay of 10 ms 8616038816SMartin Matuska.No (\& Ns Fl D Ar 10 : Ns Ar 1 ) , 87c03c5b1cSMartin Matuskathe device will only be able to service a single I/O request 8816038816SMartin Matuskaat a time with each request taking 10 ms to complete. 8916038816SMartin MatuskaSo, if only a single request is submitted every 10 ms, the 90eda14cbcSMatt Macyaverage latency will be 10 ms; but if more than one request 91eda14cbcSMatt Macyis submitted every 10 ms, the average latency will be more 92eda14cbcSMatt Macythan 10 ms. 9316038816SMartin Matuska.Pp 94eda14cbcSMatt MacySimilarly, if a delay of 10 ms is specified to have two 9516038816SMartin Matuskalanes 9616038816SMartin Matuska.No (\& Ns Fl D Ar 10 : Ns Ar 2 ) , 9716038816SMartin Matuskathen the device will be able to service 9816038816SMartin Matuskatwo requests at a time, each with a minimum latency of 10 ms. 9916038816SMartin MatuskaSo, if two requests are submitted every 10 ms, then 100eda14cbcSMatt Macythe average latency will be 10 ms; but if more than two 101eda14cbcSMatt Macyrequests are submitted every 10 ms, the average latency 102eda14cbcSMatt Macywill be more than 10 ms. 10316038816SMartin Matuska.Pp 10416038816SMartin MatuskaAlso note, these delays are additive. 10516038816SMartin MatuskaSo two invocations of 10616038816SMartin Matuska.Fl D Ar 10 : Ns Ar 1 10716038816SMartin Matuskaare roughly equivalent to a single invocation of 10816038816SMartin Matuska.Fl D Ar 10 : Ns Ar 2 . 10916038816SMartin MatuskaThis also means, that one can specify multiple 11016038816SMartin Matuskalanes with differing target latencies. 11116038816SMartin MatuskaFor example, an invocation of 11216038816SMartin Matuska.Fl D Ar 10 : Ns Ar 1 11316038816SMartin Matuskafollowed by 11416038816SMartin Matuska.Fl D Ar 25 : Ns Ar 2 11516038816SMartin Matuskawill create 3 lanes on the device: one lane with a latency 116eda14cbcSMatt Macyof 10 ms and two lanes with a 25 ms latency. 11716038816SMartin Matuska. 11816038816SMartin Matuska.It Xo 11916038816SMartin Matuska.Nm zinject 12016038816SMartin Matuska.Fl d Ar vdev 12116038816SMartin Matuska.Op Fl e Ar device_error 12216038816SMartin Matuska.Op Fl L Ar label_error 12316038816SMartin Matuska.Op Fl T Ar failure 12416038816SMartin Matuska.Op Fl f Ar frequency 12516038816SMartin Matuska.Op Fl F 12616038816SMartin Matuska.Ar pool 12716038816SMartin Matuska.Xc 128eda14cbcSMatt MacyForce a vdev error. 12916038816SMartin Matuska. 13016038816SMartin Matuska.It Xo 13116038816SMartin Matuska.Nm zinject 13216038816SMartin Matuska.Fl I 13316038816SMartin Matuska.Op Fl s Ar seconds Ns | Ns Fl g Ar txgs 13416038816SMartin Matuska.Ar pool 13516038816SMartin Matuska.Xc 136eda14cbcSMatt MacySimulate a hardware failure that fails to honor a cache flush. 13716038816SMartin Matuska. 13816038816SMartin Matuska.It Xo 13916038816SMartin Matuska.Nm zinject 14016038816SMartin Matuska.Fl p Ar function 14116038816SMartin Matuska.Ar pool 14216038816SMartin Matuska.Xc 143eda14cbcSMatt MacyPanic inside the specified function. 14416038816SMartin Matuska. 14516038816SMartin Matuska.It Xo 14616038816SMartin Matuska.Nm zinject 14716038816SMartin Matuska.Fl t Sy data 14816038816SMartin Matuska.Fl C Ar dvas 14916038816SMartin Matuska.Op Fl e Ar device_error 15016038816SMartin Matuska.Op Fl f Ar frequency 15116038816SMartin Matuska.Op Fl l Ar level 15216038816SMartin Matuska.Op Fl r Ar range 15316038816SMartin Matuska.Op Fl amq 15416038816SMartin Matuska.Ar path 15516038816SMartin Matuska.Xc 156eda14cbcSMatt MacyForce an error into the contents of a file. 15716038816SMartin Matuska. 15816038816SMartin Matuska.It Xo 15916038816SMartin Matuska.Nm zinject 16016038816SMartin Matuska.Fl t Sy dnode 16116038816SMartin Matuska.Fl C Ar dvas 16216038816SMartin Matuska.Op Fl e Ar device_error 16316038816SMartin Matuska.Op Fl f Ar frequency 16416038816SMartin Matuska.Op Fl l Ar level 16516038816SMartin Matuska.Op Fl amq 16616038816SMartin Matuska.Ar path 16716038816SMartin Matuska.Xc 168eda14cbcSMatt MacyForce an error into the metadnode for a file or directory. 16916038816SMartin Matuska. 17016038816SMartin Matuska.It Xo 17116038816SMartin Matuska.Nm zinject 17216038816SMartin Matuska.Fl t Ar mos_type 17316038816SMartin Matuska.Fl C Ar dvas 17416038816SMartin Matuska.Op Fl e Ar device_error 17516038816SMartin Matuska.Op Fl f Ar frequency 17616038816SMartin Matuska.Op Fl l Ar level 17716038816SMartin Matuska.Op Fl r Ar range 17816038816SMartin Matuska.Op Fl amqu 17916038816SMartin Matuska.Ar pool 18016038816SMartin Matuska.Xc 181eda14cbcSMatt MacyForce an error into the MOS of a pool. 18216038816SMartin Matuska.El 18316038816SMartin Matuska.Sh OPTIONS 18416038816SMartin Matuska.Bl -tag -width "-C dvas" 18516038816SMartin Matuska.It Fl a 186eda14cbcSMatt MacyFlush the ARC before injection. 18716038816SMartin Matuska.It Fl b Ar objset : Ns Ar object : Ns Ar level : Ns Ar start : Ns Ar end 18816038816SMartin MatuskaForce an error into the pool at this bookmark tuple. 18916038816SMartin MatuskaEach number is in hexadecimal, and only one block can be specified. 19016038816SMartin Matuska.It Fl C Ar dvas 19116038816SMartin MatuskaInject the given error only into specific DVAs. 19216038816SMartin MatuskaThe mask should be specified as a list of 0-indexed DVAs separated by commas 193c03c5b1cSMartin Matuska.No (e.g . Ar 0,2 Ns No ). 19416038816SMartin MatuskaThis option is not applicable to logical data errors such as 19516038816SMartin Matuska.Sy decompress 196eda14cbcSMatt Macyand 19716038816SMartin Matuska.Sy decrypt . 19816038816SMartin Matuska.It Fl d Ar vdev 199eda14cbcSMatt MacyA vdev specified by path or GUID. 20016038816SMartin Matuska.It Fl e Ar device_error 201eda14cbcSMatt MacySpecify 20216038816SMartin Matuska.Bl -tag -compact -width "decompress" 20316038816SMartin Matuska.It Sy checksum 20416038816SMartin Matuskafor an ECKSUM error, 20516038816SMartin Matuska.It Sy decompress 20616038816SMartin Matuskafor a data decompression error, 20716038816SMartin Matuska.It Sy decrypt 20816038816SMartin Matuskafor a data decryption error, 20916038816SMartin Matuska.It Sy corrupt 21016038816SMartin Matuskato flip a bit in the data after a read, 21116038816SMartin Matuska.It Sy dtl 21216038816SMartin Matuskafor an ECHILD error, 21316038816SMartin Matuska.It Sy io 214*1719886fSMartin Matuskafor an EIO error where reopening the device will succeed, 21516038816SMartin Matuska.It Sy nxio 216*1719886fSMartin Matuskafor an ENXIO error where reopening the device will fail, or 217*1719886fSMartin Matuska.It Sy noop 218*1719886fSMartin Matuskato drop the IO without executing it, and return success. 21916038816SMartin Matuska.El 22016038816SMartin Matuska.Pp 22116038816SMartin MatuskaFor EIO and ENXIO, the "failed" reads or writes still occur. 22216038816SMartin MatuskaThe probe simply sets the error value reported by the I/O pipeline 22316038816SMartin Matuskaso it appears the read or write failed. 22416038816SMartin MatuskaDecryption errors only currently work with file data. 22516038816SMartin Matuska.It Fl f Ar frequency 22616038816SMartin MatuskaOnly inject errors a fraction of the time. 22716038816SMartin MatuskaExpressed as a real number percentage between 22816038816SMartin Matuska.Sy 0.0001 22916038816SMartin Matuskaand 23016038816SMartin Matuska.Sy 100 . 23116038816SMartin Matuska.It Fl F 23216038816SMartin MatuskaFail faster. 23316038816SMartin MatuskaDo fewer checks. 23416038816SMartin Matuska.It Fl f Ar txgs 235eda14cbcSMatt MacyRun for this many transaction groups before reporting failure. 23616038816SMartin Matuska.It Fl h 237eda14cbcSMatt MacyPrint the usage message. 23816038816SMartin Matuska.It Fl l Ar level 23916038816SMartin MatuskaInject an error at a particular block level. 24016038816SMartin MatuskaThe default is 24116038816SMartin Matuska.Sy 0 . 24216038816SMartin Matuska.It Fl L Ar label_error 243eda14cbcSMatt MacySet the label error region to one of 24416038816SMartin Matuska.Sy nvlist , 24516038816SMartin Matuska.Sy pad1 , 24616038816SMartin Matuska.Sy pad2 , 24716038816SMartin Matuskaor 24816038816SMartin Matuska.Sy uber . 24916038816SMartin Matuska.It Fl m 250eda14cbcSMatt MacyAutomatically remount the underlying filesystem. 25116038816SMartin Matuska.It Fl q 25216038816SMartin MatuskaQuiet mode. 25316038816SMartin MatuskaOnly print the handler number added. 25416038816SMartin Matuska.It Fl r Ar range 255eda14cbcSMatt MacyInject an error over a particular logical range of an object, which 256eda14cbcSMatt Macywill be translated to the appropriate blkid range according to the 257eda14cbcSMatt Macyobject's properties. 25816038816SMartin Matuska.It Fl s Ar seconds 259eda14cbcSMatt MacyRun for this many seconds before reporting failure. 26016038816SMartin Matuska.It Fl T Ar failure 261eda14cbcSMatt MacySet the failure type to one of 26216038816SMartin Matuska.Sy all , 263*1719886fSMartin Matuska.Sy ioctl , 26416038816SMartin Matuska.Sy claim , 26516038816SMartin Matuska.Sy free , 26616038816SMartin Matuska.Sy read , 26716038816SMartin Matuskaor 26816038816SMartin Matuska.Sy write . 26916038816SMartin Matuska.It Fl t Ar mos_type 270eda14cbcSMatt MacySet this to 27116038816SMartin Matuska.Bl -tag -compact -width "spacemap" 27216038816SMartin Matuska.It Sy mos 27316038816SMartin Matuskafor any data in the MOS, 27416038816SMartin Matuska.It Sy mosdir 27516038816SMartin Matuskafor an object directory, 27616038816SMartin Matuska.It Sy config 27716038816SMartin Matuskafor the pool configuration, 27816038816SMartin Matuska.It Sy bpobj 27916038816SMartin Matuskafor the block pointer list, 28016038816SMartin Matuska.It Sy spacemap 28116038816SMartin Matuskafor the space map, 28216038816SMartin Matuska.It Sy metaslab 28316038816SMartin Matuskafor the metaslab, or 28416038816SMartin Matuska.It Sy errlog 28516038816SMartin Matuskafor the persistent error log. 28616038816SMartin Matuska.El 28716038816SMartin Matuska.It Fl u 288eda14cbcSMatt MacyUnload the pool after injection. 28916038816SMartin Matuska.El 29016038816SMartin Matuska. 29116038816SMartin Matuska.Sh ENVIRONMENT VARIABLES 29216038816SMartin Matuska.Bl -tag -width "ZF" 29316038816SMartin Matuska.It Ev ZFS_HOSTID 29416038816SMartin MatuskaRun 29516038816SMartin Matuska.Nm 29616038816SMartin Matuskain debug mode. 29716038816SMartin Matuska.El 29816038816SMartin Matuska. 29916038816SMartin Matuska.Sh SEE ALSO 30016038816SMartin Matuska.Xr zfs 8 , 30116038816SMartin Matuska.Xr zpool 8 302