server: Remember .open(readonly) status
The previous patch argued that globally affecting .can_write based on
'-r' (the global 'readonly') prevents the ability for a filter to call
next_open(nxdata, false) to purposefully write to the plugin, even
while advertising .can_write=0 to the client. But it also
demonstrated that when a filter passes readonly=true to next_open, we
were still making needless probes into the plugin, for something the
filter won't be using.
This patch improves things to prime the .can_write cache according to
.open. The same script from the previous patch now fails a lot faster
under -r (since nozero is not a filter that changes readonly=false to
true, the plugin now fails .can_zero quickly):
$ /bin/time -f %e ./nbdkit -U - -r --filter=nozero sh script zeromode=notrim \
--run 'qemu-nbd --list -k $unixsocket >/dev/null'
nbdkit: sh[1]: error: zeromode 'notrim' requires plugin zero support
qemu-nbd: Failed to read initial magic: Unexpected end-of-file before all bytes were read
Command exited with non-zero status 1
0.06
Signed-off-by: Eric Blake <eblake@redhat.com>