[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [Libguestfs] [nbdkit PATCH 3/3] plugins: Add .can_fast_
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [Libguestfs] [nbdkit PATCH 3/3] plugins: Add .can_fast_zero hook |
Date: |
Fri, 23 Aug 2019 16:16:18 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
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
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH 4/5] nbd: Implement server use of NBD FAST_ZERO, (continued)