docs: Add a stardard FILES section to most plugin and filter man pages.
[nbdkit/ericb.git] / TODO
blobd8a267eaeebd80531d27e2189a56541718b1595b
1 To-do list for nbdkit
2 ======================================================================
4 General ideas for improvements
5 ------------------------------
7 * Listen on specific interfaces or protocols (eg. only IPv6).
9 * Performance - measure and improve it.
11 * Exit on last connection (the default behaviour of qemu-nbd unless
12   you use -t).
14 * Limit number of incoming connections (like qemu-nbd -e).
16 * For parallel plugins, only create threads on demand from parallel
17   client requests, rather than pre-creating all threads at connection
18   time, up to the thread pool size limit.  Of course, once created, a
19   thread is reused as possible until the connection closes.
21 * Async callbacks.  The current parallel support requires one thread
22   per pending message; a solution with fewer threads would split
23   low-level code between request and response, where the callback has
24   to inform nbdkit when the response is ready:
25   https://www.redhat.com/archives/libguestfs/2018-January/msg00149.html
27 * More NBD protocol features.  The currently missing features are
28   structured replies for sparse reads, block size constraints, and
29   online resize.
31 * Add a callback to let plugins request minimum alignment for the
32   buffer to pread/pwrite; useful for a plugin utilizing O_DIRECT or
33   other situation where pre-aligned buffers are more efficient.
34   Ideally, a blocksize filter would honor strict alignment below and
35   advertise loose alignment above; all other filters (particularly
36   ones like offset) can fail to initialize if they can't guarantee
37   strict alignment and don't want to deal with bounce buffers.
39 * Test that zero-length read/write/extents requests behave sanely
40   (NBD protocol says they are unspecified).
42 * If a client negotiates structured replies, and issues a read/extents
43   call that exceeds EOF (qemu 3.1 is one such client, when nbdkit
44   serves non-sector-aligned images), return the valid answer for the
45   subset of the request in range and then NBD_REPLY_TYPE_ERROR_OFFSET
46   for the tail, rather than erroring the entire request.
48 * Test and document how to run nbdkit from inetd and xinetd in
49   nbdkit-service(1).
51 * Audit the code base to get rid of strerror() usage (the function is
52   not thread-safe); however, using geterror_r() can be tricky as it
53   has a different signature in glibc than in POSIX.
55 * Teach nbdkit_error() to have smart newline appending (for existing
56   inconsistent clients), while fixing internal uses to omit the
57   newline. Commit ef4f72ef has some ideas on smart newlines, but that
58   should probably be factored into a utility function.
60 * We may need a way to lock nbdkit into memory and adjust the OOM
61   killer score.  See this LKML discussion:
62   https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1933394.html
63   and also look at the implementation of the -swap option in
64   nbd-client.
66 * Add a mode of operation where nbdkit is handed a pre-opened fd to be
67   used immediately in transmission phase (skipping handshake).  There
68   are already third-party clients of the kernel's /dev/nbdX which rely
69   on their own protocol instead of NBD handshake, before calling
70   ioctl(NBD_SET_SOCK); this mode would let the third-party client
71   continue to keep their non-standard handshake while utilizing nbdkit
72   to prototype new behaviors in serving the kernel.
74 * Clients should be able to list export names supported by plugins.
75   Current behaviour is not really correct: We only list the -e
76   parameter from the command line, which is different from the export
77   name(s) that a plugin might want to support.  Probably we should
78   deprecate the -e option entirely since it does nothing useful.
80 * Add plugin "connect" method.  This would be called on a connection
81   before handshaking or TLS negotiation, and could be used (with
82   nbdkit_peer_name) to accept or reject connections based on IP
83   address, rather like a poor man's TCP wrappers.  See also commit
84   c05686f9577f.
86 Suggestions for plugins
87 -----------------------
89 Note: qemu supports other formats such as libnfs, iscsi, gluster and
90 ceph/rbd, and while similar plugins could be written for nbdkit there
91 is no compelling reason unless the result is better than qemu-nbd.
92 For the majority of users it would be better if they were directed to
93 qemu-nbd for these use cases.
95 * XVA files
97   https://lists.gnu.org/archive/html/qemu-devel/2017-11/msg02971.html
98   is a partial solution but it needs cleaning up.
100 nbdkit-floppy-plugin:
102 * Add boot sector support.  In theory this is easy (eg. using
103   SYSLINUX), but the practical reality of making a fully bootable
104   floppy is rather more complex.
106 * Add multiple dir merging.
108 nbdkit-linuxdisk-plugin:
110 * Add multiple dir merging (in e2fsprogs mke2fs).
112 Suggestions for filters
113 -----------------------
115 * tar plugin should really be a filter
117 * gzip plugin should really be a filter
119 * libarchive could be used to implement a general tar/zip filter
121 * LUKS encrypt/decrypt filter, bonus points if compatible with qemu
122   LUKS-encrypted disk images
124 * masking plugin features for testing clients (see 'nozero' and 'fua'
125   filters for examples)
127 * nbdkit-cache-filter should handle ENOSPC errors automatically by
128   reclaiming blocks from the cache
130 nbdkit-rate-filter:
132 * allow other kinds of traffic shaping such as VBR
134 * limit traffic per client (ie. per IP address)
136 * split large requests to avoid long, lumpy sleeps when request size
137   is much larger than rate limit
139 nbdkit-retry-filter:
141 * allow user to specify which errors cause a retry and which ones are
142   passed through; for example there's probably no point retrying on
143   ENOMEM
145 * implement a softer mode (retry-reopen=no) where we don't reopen the
146   plugin, we just retry the data command that failed
148 * there are all kinds of extra complications possible here,
149   eg. specifying a pattern of retrying and reopening:
150   retry-method=RRRORRRRRORRRRR meaning to retry the data command 3
151   times, reopen, retry 5 times, etc.
153 * subsecond times
155 Filters for security
156 --------------------
158 Things like blacklisting or whitelisting IP addresses can be done
159 using external wrappers (TCP wrappers, systemd).
161 However it might be nice to have a configurable filter for preventing
162 valid but not sensible requests.  The server already filters invalid
163 requests.  This would be like seccomp, and could be implemented using
164 an eBPF-based parser.  Unfortunately actual eBPF is difficult to use
165 for userspace processes.  The "standard" isn't solidly defined - the
166 Linux kernel implementation is the standard - and Linux has by far the
167 best implementation, particularly around bytecode verification and
168 JITting.  There is a userspace VM (ubpf) but it has very limited
169 capabilities compared to Linux.
171 Composing nbdkit
172 ----------------
174 Filters allow certain types of composition, but others would not be
175 possible, for example RAIDing over multiple nbd sources.  Because the
176 plugin API limits us to loading a single plugin to the server, the
177 best way to do this (and the most robust) is to compose multiple
178 nbdkit processes.  Perhaps libnbd will prove useful for this purpose.
180 Build-related
181 -------------
183 * Figure out how to get 'make distcheck' working. VPATH builds are
184   working, but various pkg-config results that try to stick
185   bash-completion and ocaml add-ons into their system-wide home do
186   not play nicely with --prefix builds for a non-root user.
188 * Port to Windows.
190 Rust plugins
191 ------------
193 * Consider supporting a more idiomatic style for writing Rust plugins.
195 * Better documentation.
197 * Add tests.
199 * There is no attempt to ‘make install’ or otherwise package the
200   crate.  Since it looks as if Rust code is normally distributed as
201   source it's not clear what that would even mean.
203 V3 plugin protocol
204 ------------------
206 From time to time we may update the plugin protocol.  This section
207 collects ideas for things which might be fixed in the next version of
208 the protocol.
210 Note that we keep the old protocol(s) around so that source
211 compatibility is retained.  Plugins must opt in to the new protocol
212 using ‘#define NBDKIT_API_VERSION <version>’.
214 * All methods taking a ‘count’ field should be uint64_t (instead of
215   uint32_t).  Although the NBD protocol does not support 64 bit
216   lengths, it might do in future.
218 * pread could be changed to allow it to support Structured Replies
219   (SRs).  This could mean allowing it to return partial data, holes,
220   zeroes, etc.  For a client that negotiates SR coupled with a plugin
221   that supports .extents, the v2 protocol would allow us to at least
222   synthesize NBD_REPLY_TYPE_OFFSET_HOLE for less network traffic, even
223   though the plugin will still have to fully populate the .pread
224   buffer; the v3 protocol should make sparse reads more direct.
226 * Parameters should be systematized so that they aren't just (key,
227   value) strings.  nbdkit should know the possible keys for the plugin
228   and filters, and the type of the values, and both check and parse
229   them for the plugin.
231 * Modify open() API so it takes an export name parameter.