search for: plugin_can_write

Displaying 20 results from an estimated 57 matches for "plugin_can_write".

2017 Nov 15
1
[nbdkit PATCH] connections: Extract common export flag computation code
...src/connections.c index 8dc1925..f9edea7 100644 --- a/src/connections.c +++ b/src/connections.c @@ -237,13 +237,57 @@ free_connection (struct connection *conn) } static int +compute_eflags (struct connection *conn, uint16_t *flags) +{ + uint16_t eflags = NBD_FLAG_HAS_FLAGS; + int fl; + + fl = plugin_can_write (conn); + if (fl == -1) + return -1; + if (readonly || !fl) { + eflags |= NBD_FLAG_READ_ONLY; + conn->readonly = 1; + } + if (!conn->readonly) { + eflags |= NBD_FLAG_SEND_WRITE_ZEROES; + } + + fl = plugin_can_flush (conn); + if (fl == -1) + return -1; + if (fl) { + e...
2016 Sep 26
1
[PATCH] nbdkit: flags are 32 bits for oldstyle connections
..._t r; uint64_t exportsize; - uint16_t gflags, eflags; + uint32_t flags; int fl; r = plugin_get_size (conn); @@ -169,14 +169,13 @@ exportsize = (uint64_t) r; conn->exportsize = exportsize; - gflags = 0; - eflags = NBD_FLAG_HAS_FLAGS; + flags = NBD_FLAG_HAS_FLAGS; fl = plugin_can_write (conn); if (fl == -1) return -1; if (readonly || !fl) { - eflags |= NBD_FLAG_READ_ONLY; + flags |= NBD_FLAG_READ_ONLY; conn->readonly = 1; } @@ -184,7 +183,7 @@ if (fl == -1) return -1; if (fl) { - eflags |= NBD_FLAG_SEND_FLUSH | NBD_FLAG_SEND_FUA; + f...
2016 Sep 27
1
Re: Memory corruption when testing nbdkit python plugin with nbd-tester-client?
...gainst client requests: plugin_register (const char *_filename, plugin_cleanup (void) plugin_config (const char *key, const char *value) plugin_config_complete (void) plugin_open (struct connection *conn, int readonly) plugin_close (struct connection *conn) plugin_get_size (struct connection *conn) plugin_can_write (struct connection *conn) plugin_can_flush (struct connection *conn) plugin_is_rotational (struct connection *conn) plugin_can_trim (struct connection *conn) That means dumping the plugin-internal data on connection close is not locked against the requests within that connection, and any garbage c...
2018 Jan 16
0
[PATCH nbdkit 2/3] Refactor plugin_* functions into a backend struct.
...connection *conn) */ if (!quit) { if (conn->handle) - plugin_close (conn); + backend->close (backend, conn); } free (conn); @@ -352,7 +354,7 @@ compute_eflags (struct connection *conn, uint16_t *flags) uint16_t eflags = NBD_FLAG_HAS_FLAGS; int fl; - fl = plugin_can_write (conn); + fl = backend->can_write (backend, conn); if (fl == -1) return -1; if (readonly || !fl) { @@ -363,7 +365,7 @@ compute_eflags (struct connection *conn, uint16_t *flags) eflags |= NBD_FLAG_SEND_WRITE_ZEROES; } - fl = plugin_can_flush (conn); + fl = backend->can_...
2019 Jan 30
3
[PATCH nbdkit] xz: Do not pass can_write through to the plugin.
...correct. An alternate way I can think to fix this would be for the core server to maintain a readonly flag for each layer (instead of just per- server). You could also argue that our readonly test in server/connections.c:compute_eflags is wrong and/or that the implementations of server/plugins.c:plugin_can_write and server/filters.c:filter_can_write have the wrong default - they should consult the readonly flag which was passed to that layer's open call. However the fix only affects one filter, and we're not maintaining an API for filters, so maybe we can defer the problem. Rich.
2018 Jan 17
0
[PATCH 2/9] Refactor plugin_* functions into a backend struct.
...connection *conn) */ if (!quit) { if (conn->handle) - plugin_close (conn); + backend->close (backend, conn); } free (conn); @@ -352,7 +354,7 @@ compute_eflags (struct connection *conn, uint16_t *flags) uint16_t eflags = NBD_FLAG_HAS_FLAGS; int fl; - fl = plugin_can_write (conn); + fl = backend->can_write (backend, conn); if (fl == -1) return -1; if (readonly || !fl) { @@ -363,7 +365,7 @@ compute_eflags (struct connection *conn, uint16_t *flags) eflags |= NBD_FLAG_SEND_WRITE_ZEROES; } - fl = plugin_can_flush (conn); + fl = backend->can_...
2018 Jan 16
0
[PATCH nbdkit v2 2/3] Refactor plugin_* functions into a backend struct.
...connection *conn) */ if (!quit) { if (conn->handle) - plugin_close (conn); + backend->close (backend, conn); } free (conn); @@ -352,7 +354,7 @@ compute_eflags (struct connection *conn, uint16_t *flags) uint16_t eflags = NBD_FLAG_HAS_FLAGS; int fl; - fl = plugin_can_write (conn); + fl = backend->can_write (backend, conn); if (fl == -1) return -1; if (readonly || !fl) { @@ -363,7 +365,7 @@ compute_eflags (struct connection *conn, uint16_t *flags) eflags |= NBD_FLAG_SEND_WRITE_ZEROES; } - fl = plugin_can_flush (conn); + fl = backend->can_...
2018 Jan 16
4
[PATCH nbdkit v2 2/3] Refactor plugin_* functions into a backend
v1 -> v2: - Fixed everything mentioned in the review. Rich.
2017 Feb 06
0
[PATCH 1/2] Define .errno_is_preserved constant instead of a .errno_is_reliable callback.
...+extern int plugin_errno_is_preserved (void); extern int plugin_open (struct connection *conn, int readonly); extern void plugin_close (struct connection *conn); extern int64_t plugin_get_size (struct connection *conn); -extern int plugin_errno_is_reliable (struct connection *conn); extern int plugin_can_write (struct connection *conn); extern int plugin_can_flush (struct connection *conn); extern int plugin_is_rotational (struct connection *conn); diff --git a/src/plugins.c b/src/plugins.c index 837a54f..eeed8a9 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -236,6 +236,7 @@ plugin_dump_fields (voi...
2018 Jan 16
6
[PATCH nbdkit 0/3] Refactor plugin_* functions into a backend struct.
Somewhat invasive but mostly mechanical change to how plugins are called. This patch is in preparation for adding a second backend subtype for filters. Rich.
2020 Mar 17
0
[nbdkit PATCH 1/4] server: Normalize plugin can_* values
...re @@ -308,13 +308,21 @@ plugin_get_size (struct backend *b, void *handle) return p->plugin.get_size (handle); } +static int normalize_bool (int value) +{ + if (value == -1 || value == 0) + return value; + /* Normalize all other non-zero values to true */ + return 1; +} + static int plugin_can_write (struct backend *b, void *handle) { struct backend_plugin *p = container_of (b, struct backend_plugin, backend); if (p->plugin.can_write) - return p->plugin.can_write (handle); + return normalize_bool (p->plugin.can_write (handle)); else return p->plugin.pwrite ||...
2017 Jan 27
0
[nbdkit PATCH v3 1/4] plugins: Don't use bogus errno from non-C plugins
...ugin_unlock_request (struct connection *conn); extern int plugin_open (struct connection *conn, int readonly); extern void plugin_close (struct connection *conn); extern int64_t plugin_get_size (struct connection *conn); +extern int plugin_errno_is_reliable (struct connection *conn); extern int plugin_can_write (struct connection *conn); extern int plugin_can_flush (struct connection *conn); extern int plugin_is_rotational (struct connection *conn); diff --git a/src/plugins.c b/src/plugins.c index 92f8505..d486f2d 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -395,6 +395,21 @@ plugin_get_size (struc...
2017 Feb 06
3
[PATCH nbdkit 0/2] Change .errno_is_reliable function to .errno_is_preserved constant.
See patch 1 for rationale.
2020 Mar 17
1
Re: [nbdkit PATCH 1/4] server: Normalize plugin can_* values
...*handle) > return p->plugin.get_size (handle); > } > > +static int normalize_bool (int value) > +{ > + if (value == -1 || value == 0) > + return value; > + /* Normalize all other non-zero values to true */ > + return 1; > +} > + > static int > plugin_can_write (struct backend *b, void *handle) > { > struct backend_plugin *p = container_of (b, struct backend_plugin, backend); > > if (p->plugin.can_write) > - return p->plugin.can_write (handle); > + return normalize_bool (p->plugin.can_write (handle)); > else...
2018 Jan 17
0
[PATCH 5/9] connections: Allow multiple handles to be stored in the connection object.
...n)); + assert (connection_get_handle (conn, 0)); assert (p->plugin.get_size != NULL); debug ("get_size"); - return p->plugin.get_size (connection_get_handle (conn)); + return p->plugin.get_size (connection_get_handle (conn, 0)); } static int @@ -284,12 +284,12 @@ plugin_can_write (struct backend *b, struct connection *conn) { struct backend_plugin *p = container_of (b, struct backend_plugin, backend); - assert (connection_get_handle (conn)); + assert (connection_get_handle (conn, 0)); debug ("can_write"); if (p->plugin.can_write) - return p...
2018 Jan 19
0
[nbdkit PATCH v2 08/13] connections: Allow multiple handles to be stored in the connection object.
...conn)); + assert (connection_get_handle (conn, 0)); assert (p->plugin.get_size != NULL); debug ("get_size"); - return p->plugin.get_size (connection_get_handle (conn)); + return p->plugin.get_size (connection_get_handle (conn, 0)); } static int @@ -284,12 +284,12 @@ plugin_can_write (struct backend *b, struct connection *conn) { struct backend_plugin *p = container_of (b, struct backend_plugin, backend); - assert (connection_get_handle (conn)); + assert (connection_get_handle (conn, 0)); debug ("can_write"); if (p->plugin.can_write) - return p-&g...
2017 Feb 20
1
Re: Fwd: nbdkit async
The concern is a client is blocked while processing a request. The nbdkit server design requires a thread per request being processed regardless of the number of connections or clients. We want to run 1000's of requests in parallel without needing a thread at nbdkit layer per request in flight. Our plugin layer is built around boost asio and a few threads in a worker pool running an io
2018 Jan 24
0
[nbdkit PATCH 2/3] filter: Add .can_zero/.can_fua overrides
...kend *b, struct connection *conn) return p->plugin.trim != NULL; } +static int +plugin_can_zero (struct backend *b, struct connection *conn) +{ + debug ("can_zero"); + + // We always allow .zero to fall back to .write, so plugins don't + // need to override this + return plugin_can_write (b, conn); +} + +static int +plugin_can_fua (struct backend *b, struct connection *conn) +{ + debug ("can_fua"); + + // TODO - wire FUA flag support into plugins. Until then, this copies + // can_flush, since that's how we emulate FUA + return plugin_can_flush (b, conn); +} + sta...
2019 Aug 23
1
[nbdkit PATCH 1/3] server: Add internal support for NBDKIT_FLAG_FAST_ZERO
...tents, .can_fua = filter_can_fua, .can_multi_conn = filter_can_multi_conn, diff --git a/server/plugins.c b/server/plugins.c index 34cc3cb5..c6dcf408 100644 --- a/server/plugins.c +++ b/server/plugins.c @@ -401,6 +401,16 @@ plugin_can_zero (struct backend *b, struct connection *conn) return plugin_can_write (b, conn); } +static int +plugin_can_fast_zero (struct backend *b, struct connection *conn) +{ + assert (connection_get_handle (conn, 0)); + + debug ("can_fast_zero"); + + return 0; /* Upcoming patch will actually add support. */ +} + static int plugin_can_extents (struct backend *...
2018 Jan 24
8
[nbdkit PATCH 0/3] Add nozero filter
I still need to add testsuite coverage. Perhaps it might be easier if I create a new '--filter=log logfile=foo' filter that produces a log of which commands a client sent, then compare the log using a known client that uses write_zeroes (qemu-io works well) both with and without --filter=nozero to prove that the change in advertisement changes the commands sent over the wire (that would