Provided by: nbdkit_1.32.5-1ubuntu2_amd64
NAME
nbdkit-blocksize-policy-filter - set minimum, preferred and maximum block size, and apply error policy
SYNOPSIS
nbdkit --filter=blocksize-policy PLUGIN [blocksize-error-policy=allow|error] [blocksize-minimum=N] [blocksize-preferred=N] [blocksize-maximum=N]
DESCRIPTION
"nbdkit-blocksize-policy-filter" is an nbdkit(1) filter that can add block size constraints to plugins which don't already support them. It can also enforce an error policy for badly behaved clients which do not obey the block size constraints. For more information about block size constraints, see section "Block size constraints" in https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md. The simplest usage is to place this filter on top of any plugin which does not advertise block size constraints, and set the "blocksize-minimum", "blocksize-preferred" and "blocksize-maximum" parameters with the desired constraints. For example: nbdkit --filter=blocksize-policy memory 1G \ blocksize-preferred=32K would adjust nbdkit-memory-plugin(1) so that clients should prefer 32K requests. You can query the NBD server advertised constraints using nbdinfo(1): $ nbdinfo nbd://localhost [...] block_size_minimum: 1 block_size_preferred: 32768 block_size_maximum: 4294967295 The second part of this filter is adjusting the error policy when badly behaved clients do not obey the minimum or maximum request size. Normally nbdkit permits these requests, leaving it up to the plugin whether it rejects the request with an error or tries to process the request (eg. trying to split an over-large request or doing a read-modify- write for an unaligned write). With this filter you can use "blocksize-error-policy=error" to reject these requests in the filter with an EINVAL error. The plugin will not see them. Combining with nbdkit-blocksize-filter(1) A related filter is nbdkit-blocksize-filter(1). That filter can split and combine requests for plugins that cannot handle requests under or over a particular size. Both filters may be used together like this (note that the order of the filters is important): nbdkit --filter=blocksize-policy \ --filter=blocksize \ PLUGIN ... \ blocksize-error-policy=allow \ blocksize-minimum=64K minblock=64K This says to advertise a minimum block size of 64K. Well-behaved clients will obey this. Badly behaved clients will send requests < 64K which will be converted to slow 64K read- modify-write cycles to the underlying plugin. In either case the plugin will only see requests on 64K (or multiples of 64K) boundaries.
PARAMETERS
blocksize-error-policy=allow blocksize-error-policy=error If a client sends a request which is smaller than the permitted minimum size or larger than the permitted maximum size, or not aligned to the minimum size, "blocksize-error-policy" chooses what the filter will do. The default (and also nbdkit's default) is "allow" which means pass the request through to the plugin. Use "error" to return an EINVAL error back to the client. The plugin will not see the badly formed request in this case. blocksize-minimum=N blocksize-preferred=N blocksize-maximum=N Advertise minimum, preferred and/or maximum block size to the client. Well-behaved clients should obey these constraints. For each parameter, you can specify it as a size (using the usual modifiers like "4K"). If the parameter is omitted then either the constraint advertised by the plugin itself is used, or a sensible default for plugins which do not advertise block size constraints.
FILES
$filterdir/nbdkit-blocksize-policy-filter.so The filter. Use "nbdkit --dump-config" to find the location of $filterdir.
VERSION
"nbdkit-limit-filter" first appeared in nbdkit 1.30.
SEE ALSO
nbdkit(1), nbdkit-blocksize-filter(1), nbdkit-filter(3), nbdkit-plugin(3).
AUTHORS
Richard W.M. Jones
COPYRIGHT
Copyright (C) 2022 Red Hat Inc.
LICENSE
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. • Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.