1nbdkit-error-filter(1)              NBDKIT              nbdkit-error-filter(1)
2
3
4

NAME

6       nbdkit-error-filter - inject errors for testing clients
7

SYNOPSIS

9        nbdkit --filter=error PLUGIN
10            [error=EPERM|EIO|ENOMEM|EINVAL|ENOSPC|ESHUTDOWN]
11            [error-rate=10%|0.1]
12            [error-file=/tmp/inject]
13            [error-pread=...] [error-pread-rate=...] [error-pread-file=...]
14            [error-pwrite=...] [error-pwrite-rate=...] [error-pwrite-file=...]
15            [error-trim=...] [error-trim-rate=...] [error-trim-file=...]
16            [error-zero=...] [error-zero-rate=...] [error-zero-file=...]
17            [error-extents=...] [error-extents-rate=...] [error-extents-file=...]
18            [error-cache=...] [error-cache-rate=...] [error-cache-file=...]
19

DESCRIPTION

21       "nbdkit-error-filter" is an nbdkit filter that injects random errors
22       into replies from the server.  This is used for testing that NBD
23       clients can handle errors.
24
25       All parameters are optional, but you should usually specify one of the
26       "error-rate" or "error-*-rate" parameters, otherwise this filter will
27       do nothing.
28

EXAMPLES

30       Inject a low rate of errors randomly into the connection:
31
32        nbdkit --filter=error file disk.img error-rate=1%
33
34       Reading, trimming, cache and extents (block status) requests will be
35       successful, but all writes and zeroing will return "No space left on
36       device":
37
38        nbdkit --filter=error file disk.img \
39                                   error=ENOSPC \
40                                   error-pwrite-rate=100% \
41                                   error-zero-rate=100%
42
43       To make all connections fail hard 60 seconds after the server is
44       started, use:
45
46        rm -f /tmp/inject
47        nbdkit --filter=error file disk.img \
48                                   error-rate=100% \
49                                   error-file=/tmp/inject
50        sleep 60; touch /tmp/inject
51

PARAMETERS

53       error=EPERM|EIO|ENOMEM|EINVAL|ENOSPC|ESHUTDOWN
54           When a random error is injected, you can select which one from the
55           range of possible NBD errors (the NBD protocol only supports a
56           limited range of error codes).
57
58           This parameter is optional and the default is "EIO" ("Input/output
59           error").
60
61       error-rate=N%
62       error-rate=0..1
63           The rate of injected errors per NBD request.  This can be expressed
64           as either a percentage between "0%" and "100%" or as a probability
65           between 0 and 1.  If "0%" or 0 is used then no errors are ever
66           injected, and if "100%" or 1 is used then all requests return
67           errors.
68
69           This parameter is optional and the default is "0%".  Unless you set
70           this, the filter will do nothing.
71
72       error-file=FILENAME
73           Errors will only be injected when FILENAME exists.  (Note you must
74           also specify the "error-rate").
75
76           You can use this for fine-grained control over when to inject
77           errors, for example if you want to trigger an error at an exact
78           moment during a test, arrange for this file to be created at the
79           appropriate time.  Or conversely to test error recovery in a
80           client, create the file initially, and then delete it to check the
81           client can recover.
82
83           This parameter is optional.
84
85       error-pread, error-pread-rate, error-pread-file.
86           Same as "error", "error-rate" and "error-file" but only apply the
87           settings to NBD pread requests.
88
89       error-pwrite, error-pwrite-rate, error-pwrite-file.
90           Same as "error", "error-rate" and "error-file" but only apply the
91           settings to NBD pwrite requests.
92
93       error-trim, error-trim-rate, error-trim-file.
94           Same as "error", "error-rate" and "error-file" but only apply the
95           settings to NBD trim requests.
96
97       error-zero, error-zero-rate, error-zero-file.
98           Same as "error", "error-rate" and "error-file" but only apply the
99           settings to NBD zero requests.
100
101       error-extents, error-extents-rate, error-extents-file.
102           (nbdkit ≥ 1.12)
103
104           Same as "error", "error-rate" and "error-file" but only apply the
105           settings to NBD block status requests to read extents.
106
107       error-cache, error-cache-rate, error-cache-file.
108           (nbdkit ≥ 1.14)
109
110           Same as "error", "error-rate" and "error-file" but only apply the
111           settings to NBD cache requests.
112

NOTES

114   Peculiar debug output
115       If you are looking at the debugging output (using "nbdkit -f -v")
116       references to the name of this filter show up as "error-inject:", and
117       such lines indicate that the filter is not altering output, for
118       example:
119
120        nbdkit: file.9: debug: error-inject: pread count=1024 offset=0 flags=0x0
121
122       Conversely, references to the string "error:" occur when the
123       nbdkit_error(3) API was used, including when this filter injects an
124       error, as in:
125
126        nbdkit: file.4: error: injecting ENOSPC error into pwrite
127

FILES

129       $filterdir/nbdkit-error-filter.so
130           The filter.
131
132           Use "nbdkit --dump-config" to find the location of $filterdir.
133

VERSION

135       "nbdkit-error-filter" first appeared in nbdkit 1.6.
136

SEE ALSO

138       nbdkit(1), nbdkit-file-plugin(1), nbdkit-full-plugin(1),
139       nbdkit-retry-filter(1), nbdkit-retry-request-filter(1),
140       nbdkit-filter(3).
141

AUTHORS

143       Richard W.M. Jones
144
146       Copyright (C) 2018 Red Hat Inc.
147

LICENSE

149       Redistribution and use in source and binary forms, with or without
150       modification, are permitted provided that the following conditions are
151       met:
152
153       •   Redistributions of source code must retain the above copyright
154           notice, this list of conditions and the following disclaimer.
155
156       •   Redistributions in binary form must reproduce the above copyright
157           notice, this list of conditions and the following disclaimer in the
158           documentation and/or other materials provided with the
159           distribution.
160
161       •   Neither the name of Red Hat nor the names of its contributors may
162           be used to endorse or promote products derived from this software
163           without specific prior written permission.
164
165       THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY
166       EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
167       IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
168       PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE
169       LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
170       CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
171       SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
172       BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
173       WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
174       OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
175       ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
176
177
178
179nbdkit-1.32.5                     2023-01-03            nbdkit-error-filter(1)
Impressum