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

NAME

6       nbdkit-cache-filter - nbdkit caching filter
7

SYNOPSIS

9        nbdkit --filter=cache plugin [cache=writeback|writethrough|unsafe]
10                                     [cache-max-size=SIZE]
11                                     [cache-high-threshold=N]
12                                     [cache-low-threshold=N]
13                                     [cache-on-read=true|false]
14                                     [plugin-args...]
15

DESCRIPTION

17       "nbdkit-cache-filter" is a filter that adds caching on top of a plugin.
18       This is useful if a plugin is slow or expensive to use, because nbdkit
19       will try to minimize requests to the plugin by caching previous
20       requests.
21
22       Note that many NBD clients are able to do caching, and because the
23       caching happens on the client side it will usually be more effective
24       than caching inside the server.  This filter can be used if the client
25       does not have effective caching, or (with "cache=unsafe") to defeat
26       flush requests from the client (which is unsafe and can cause data
27       loss, as the name suggests).
28
29       This filter only caches image contents.  To cache image metadata, use
30       nbdkit-cacheextents-filter(1) between this filter and the plugin.  To
31       accelerate sequential reads, use nbdkit-readahead-filter(1) instead.
32

PARAMETERS

34       cache=writeback
35           Store writes in the cache.  They are not written to the plugin
36           unless an explicit flush is done by the client.
37
38           This is the default caching mode, and is safe if your client issues
39           flush requests correctly (which is true for modern Linux and other
40           well-written NBD clients).
41
42       cache=writethrough
43           Always force writes through to the plugin.
44
45           This makes the cache less effective, but is necessary if your
46           client does not issue correct flush requests.
47
48       cache=unsafe
49           Ignore flush requests.  Never write to the plugin unless the cache
50           grows too large.
51
52           This is dangerous and can cause data loss, but this may be
53           acceptable if you only use it for testing or with data that you
54           don't care about or can cheaply reconstruct.
55
56       cache-max-size=SIZE
57       cache-high-threshold=N
58       cache-low-threshold=N
59           (nbdkit ≥ 1.10)
60
61           Limit the size of the cache to "SIZE".  See "CACHE MAXIMUM SIZE"
62           below.
63
64       cache-on-read=true
65           (nbdkit ≥ 1.10)
66
67           Cache read requests as well as write and cache requests.  Any time
68           a block is read from the plugin, it is saved in the cache (if there
69           is sufficient space) so the same data can be served more quickly
70           later.
71
72           Note that if the underlying data served by the plugin can be
73           modified by some other means (eg. something else can write to a
74           file which is being served by nbdkit-file-plugin(1)), this option
75           will cause nbdkit to serve stale data because reads won't always go
76           through to the plugin.
77
78       cache-on-read=false
79           Do not cache read requests (this is the default).
80

CACHE MAXIMUM SIZE

82       By default the cache can grow to any size (although not larger than the
83       virtual size of the underlying plugin) and you have to ensure there is
84       sufficient space in $TMPDIR for it.
85
86       Using the parameters "cache-max-size", "cache-high-threshold" and
87       "cache-low-threshold" you can limit the maximum size of the cache.
88
89       This requires kernel and filesystem support (for fallocate(2)
90       "FALLOC_FL_PUNCH_HOLE"), so it may not work on all platforms.
91
92       Some examples:
93
94       "cache-max-size=1G"
95           The cache is limited to around 1 gigabyte.
96
97       "cache-max-size=1G cache-high-threshold=95 cache-low-threshold=80"
98           Once the cache size reaches 972M (95% of 1G), blocks are reclaimed
99           from the cache until the size is reduced to 819M (80% of 1G).
100
101       The way this works is once the size of the cache exceeds
102       "SIZE" ✕ the high threshold, the filter works to reduce the size of the
103       cache until it is less than "SIZE" ✕ the low threshold.  Once the size
104       is below the low threshold, no more reclaim work is done until the size
105       exceeds the high threshold again.
106
107       The default thresholds are high 95% and low 80%.  You must set
108       0 < low < high.  The thresholds are expressed as integer percentages of
109       "cache-max-size".
110
111       Least recently used blocks are discarded first.
112

ENVIRONMENT VARIABLES

114       "TMPDIR"
115           The cache is stored in a temporary file located in /var/tmp by
116           default.  You can override this location by setting the "TMPDIR"
117           environment variable before starting nbdkit.
118

FILES

120       $filterdir/nbdkit-cache-filter.so
121           The filter.
122
123           Use "nbdkit --dump-config" to find the location of $filterdir.
124

VERSION

126       "nbdkit-cache-filter" first appeared in nbdkit 1.2.
127

SEE ALSO

129       nbdkit(1), nbdkit-file-plugin(1), nbdkit-cacheextents-filter(1),
130       nbdkit-readahead-filter(1), nbdkit-filter(3), qemu-img(1).
131

AUTHORS

133       Eric Blake
134
135       Richard W.M. Jones
136
138       Copyright (C) 2018-2021 Red Hat Inc.
139

LICENSE

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