It's easy to use the sh script to demonstrate that nbdkit is
inefficiently calling into .get_size, .can_fua, and friends more than
necessary. We've also commented on the list in the past that it would
be nice to ensure that when filters call into next_ops, they are not
violating constraints (as we've have to fix several bugs in the past
where we did not have such checking to protect ourselves). This
series fixes both (well, we may still have buggy filters, but if so,
now we'll get earlier assertion failures instead of random plugin
behavior).
Another benefit - this gives us a single point for adding any code for
performing NBD_INFO_BLOCKSIZE support, where we'll have to hoist what
the blocksize filter is currently doing into something that nbdkit
does from any one backend calling into another with different sizing
constraints. However, that is not done in this series.
My pending work on fast zeroes was easy enough to rebase on top of
this (in fact, I wrote this because I noticed that .can_zero was being
called more than necessary in implementing .can_fast_zero).
Eric Blake (9):
server: Fewer dereferences in filter
server: Consolidate common backend tasks into new backend.c
server: Create new backend_* functions for central handling
server: Rework storage of per-backend handle
server: Cache per-connection size
server: Cache per-connection can_FOO flags
filters: Change semantics of .can_zero
server: Move fallbacks from protocol.c to backend.c
server: Move command validation from protocol.c to backend.c
docs/nbdkit-filter.pod | 62 +++-
docs/nbdkit-plugin.pod | 6 +-
server/internal.h | 108 +++++-
server/Makefile.am | 3 +-
server/backend.c | 515 +++++++++++++++++++++++++++
server/connections.c | 51 +--
server/filters.c | 379 ++++++--------------
server/main.c | 2 +-
server/plugins.c | 192 +++-------
server/protocol-handshake-newstyle.c | 20 +-
server/protocol-handshake-oldstyle.c | 3 +-
server/protocol-handshake.c | 97 +++--
server/protocol.c | 201 +++--------
include/nbdkit-filter.h | 4 +
filters/blocksize/blocksize.c | 2 -
filters/cache/cache.c | 1 -
filters/cow/cow.c | 16 +-
filters/nozero/nozero.c | 9 +-
tests/test-layers.c | 50 +--
19 files changed, 963 insertions(+), 758 deletions(-)
create mode 100644 server/backend.c
--
2.21.0