nbdkit-spinning-filter(1)

NAME
nbdkit-spinning-filter - add seek delays to simulate a spinning hard disk

SYNOPSIS
 nbdkit --filter=spinning PLUGIN [heads=N] [separate-heads=true|false]
                                 [max-seek-time=N] [half-seek-time=N]
                                 [min-seek-time=N]

DESCRIPTION
"nbdkit-spinning-filter" is a filter for nbdkit(1) which adds seek delays to simulate a spinning hard disk with a mechanical arm and head. You can use this to test the NBD rotational property.

In the default configuration this filter simulates a disk with one head. Accesses which are close to the current position of this head have a very small delay. Accesses which are far away suffer increasingly larger delays as the simulated head seeks to that position on the disk. Each access moves the simulated position of the head.

For example to turn nbdkit-memory-plugin(1) (a RAM disk) into something which behaves more like a spinning disk:

 nbdkit --filter=spinning memory 1G

  Multiple heads
You can control the number of heads and whether they can move independently or not. Setting "heads=4" and "separate-heads=false" simulates a disk with a single mechanical arm, two platters and four heads. From the point of view of logical blocks this looks like the following, where the heads move in tandem over 4 equally spaced sections of the disk:

                         arm
                          │                       head
      ┌────────────┬──────┴─────┬────────────┐  ↙
      ⇓            ⇓            ⇓            ⇓
 ┌─────────────────────────────────────────────────┐
 └─────────────────────────────────────────────────┘

In this mode, requests are serialized waiting for the arm to move even if the requests are for different heads (as happens on a real disk).

Using "separate-heads=true" simulates heads which move on independent arms (but each head is still confined to its quarter of the disk):

                            range of movement for 4ᵗʰ arm/head
                                     ┌──────┴─────┐
    ⇓                 ⇓    ⇓            ⇓
 ┌─────────────────────────────────────────────────┐
 └─────────────────────────────────────────────────┘

In this mode, requests may operate in parallel if they are handled by different heads.

  The rotational property
The rotational property is a boolean flag in the NBD protocol which hints to the client whether the plugin behaves like a spinning disk (if rotational is true) or like a solid state disk or RAM (if rotational is false).

This filter always advertises the rotational property, because it behaves like a spinning disk.

Well-behaved NBD clients should observe this property and adjust their behaviour, for instance by scheduling disk accesses to reduce seeking.

You can place nbdkit-rotational-filter(1) in front of this filter if you want to simulate what happens with a spinning disk which does not advertise the property correctly:

 nbdkit --filter=rotational --filter=spinning PLUGIN rotational=false

Use nbdinfo(1) to examine the rotational property of an NBD server.

  Seek times
By default, seeks to adjacent tracks take 10 milliseconds, seeking from the first sector to the last sector of the disk takes ½ second, and seeking half way across the disk takes 0.2 seconds (so the curve of seek times is mildly quadratic). Note these seek times are at least an order of magnitude larger than a typical hard disk, in order to exaggerate the effect for testing purposes.

You can adjust the time taken to seek across the whole disk ("max-seek-time"), across half of the disk ("half-seek-time"), and from one track to an adjacent track ("min-seek-time") in order to change this curve. For example, setting "half-seek-time=500ms max-seek-time=1000ms" will make seek times twice as slow as the default and approximately linear with distance.

PARAMETERS

heads=N
    Set the number of simulated heads to "N" (default is 1).

separate-heads=true
separate-heads=false
    Simulate separate, independently moving heads (true), or heads connected together on a single arm (false). See the description above. The default is "false".

min-seek-time=N
half-seek-time=N
max-seek-time=N
    Adjust the time taken to seek to an adjacent track, seek across half of the disk, and seek across the whole disk. All numbers are in seconds. The defaults are "min-seek-time=10ms", "half-seek-time=200ms" and "max-seek-time=500ms".

    See nbdkit_parse_delay(3) for the precise format of these parameters.

FILES

$filterdir/nbdkit-spinning-filter.so
    The filter.

    Use "nbdkit --dump-config" to find the location of $filterdir.

VERSION
"nbdkit-spinning-filter" first appeared in nbdkit 1.40.

SEE ALSO
nbdkit(1), nbdkit-delay-filter(1), nbdkit-rate-filter(1), nbdkit-rotational-filter(1), nbdkit-memory-plugin(1), nbdinfo(1), nbdkit-filter(3), nbdkit_parse_delay(3), https://en.wikipedia.org/wiki/Hard_disk_drive, https://en.wikipedia.org/wiki/Hard_disk_drive_performance_characteristics, https://blog.stuffedcow.net/2019/09/hard-disk-geometry-microbenchmarking/

AUTHORS
Richard W.M. Jones

COPYRIGHT
Copyright Red Hat

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.