On 8/23/19 9:40 AM, Eric Blake wrote:
Allow plugins to affect the handling of the new
NBD_CMD_FLAG_FAST_ZERO
flag, then update affected plugins. In particular, in-memory plugins
are always fast; the full plugin is better served by omitting .zero
and relying on .pwrite fallback; nbd takes advantage of libnbd
extensions proposed in parallel to pass through support; and
v2 language bindings expose the choice to their scripts.
+++ b/server/plugins.c
@@ -404,11 +404,25 @@ plugin_can_zero (struct backend *b, struct connection *conn)
static int
plugin_can_fast_zero (struct backend *b, struct connection *conn)
{
+ struct backend_plugin *p = container_of (b, struct backend_plugin, backend);
+ int r;
+
assert (connection_get_handle (conn, 0));
debug ("can_fast_zero");
- return 0; /* Upcoming patch will actually add support. */
+ if (p->plugin.can_fast_zero)
+ return p->plugin.can_fast_zero (connection_get_handle (conn, 0));
+ /* Advertise support for fast zeroes if no .zero or .can_zero is
+ * false: in those cases, we fail fast instead of using .pwrite.
+ * This also works when v1 plugin has only ._zero_old.
+ */
+ if (p->plugin.zero == NULL)
+ return 1;
+ r = plugin_can_zero (b, conn);
+ if (r == -1)
+ return -1;
+ return !r;
}
Needs this squashed in for libnbd to pass rather than skip its new
'can-fast-zero-flag' test:
diff --git i/server/plugins.c w/server/plugins.c
index 84329cf4..695a77ab 100644
--- i/server/plugins.c
+++ w/server/plugins.c
@@ -208,6 +208,7 @@ plugin_dump_fields (struct backend *b)
HAS (can_cache);
HAS (cache);
HAS (thread_model);
+ HAS (can_fast_zero);
#undef HAS
/* Custom fields. */
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org