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       Note that the use of this filter rounds the image size down to a
30       multiple of the caching granularity (the larger of 4096 or the
31       "f_bsize" field of fstatvfs(3)), to ease the implementation. If you
32       need to round the image size up instead to access the last few bytes,
33       combine this filter with nbdkit-truncate-filter(1).
34
35       This filter only caches image contents.  To cache image metadata, use
36       nbdkit-cacheextents-filter(1) between this filter and the plugin.  To
37       accelerate sequential reads, use nbdkit-readahead-filter(1) instead.
38

PARAMETERS

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

CACHE MAXIMUM SIZE

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

ENVIRONMENT VARIABLES

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

FILES

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

VERSION

128       "nbdkit-cache-filter" first appeared in nbdkit 1.2.
129

SEE ALSO

131       nbdkit(1), nbdkit-file-plugin(1), nbdkit-cacheextents-filter(1),
132       nbdkit-readahead-filter(1), nbdkit-truncate-filter(1),
133       nbdkit-filter(3), qemu-img(1).
134

AUTHORS

136       Eric Blake
137
138       Richard W.M. Jones
139
141       Copyright (C) 2018-2019 Red Hat Inc.
142

LICENSE

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