search for: plugin_thread_model

Displaying 20 results from an estimated 42 matches for "plugin_thread_model".

2018 Jan 17
0
[PATCH 1/9] plugins: Move locking to a new file.
...ndex 111a810..74bb8e4 100644 --- a/src/connections.c +++ b/src/connections.c @@ -211,7 +211,7 @@ _handle_single_connection (int sockin, int sockout) int nworkers = threads ? threads : DEFAULT_PARALLEL_REQUESTS; pthread_t *workers = NULL; - if (!plugin_is_parallel() || nworkers == 1) + if (plugin_thread_model () < NBDKIT_THREAD_MODEL_PARALLEL || nworkers == 1) nworkers = 0; conn = new_connection (sockin, sockout, nworkers); if (!conn) @@ -287,9 +287,9 @@ handle_single_connection (int sockin, int sockout) { int r; - plugin_lock_connection (); + lock_connection (); r = _handle_sin...
2018 Jan 16
0
[PATCH nbdkit 1/3] plugins: Move locking to a new file.
...ndex 111a810..74bb8e4 100644 --- a/src/connections.c +++ b/src/connections.c @@ -211,7 +211,7 @@ _handle_single_connection (int sockin, int sockout) int nworkers = threads ? threads : DEFAULT_PARALLEL_REQUESTS; pthread_t *workers = NULL; - if (!plugin_is_parallel() || nworkers == 1) + if (plugin_thread_model () < NBDKIT_THREAD_MODEL_PARALLEL || nworkers == 1) nworkers = 0; conn = new_connection (sockin, sockout, nworkers); if (!conn) @@ -287,9 +287,9 @@ handle_single_connection (int sockin, int sockout) { int r; - plugin_lock_connection (); + lock_connection (); r = _handle_sin...
2018 Jan 16
1
Re: [PATCH nbdkit 1/3] plugins: Move locking to a new file.
...c | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > src/plugins.c | 77 +++++------------------------------- > 5 files changed, 142 insertions(+), 79 deletions(-) > > +++ b/src/locks.c > +void > +lock_connection (void) > +{ > + int thread_model = plugin_thread_model (); > + > + if (thread_model <= NBDKIT_THREAD_MODEL_SERIALIZE_CONNECTIONS) { > +++ b/src/plugins.c > +int > +plugin_thread_model (void) > +{ > + assert (dl); > + > + return plugin._thread_model; > +} The new code asserts dl prior to locking the connection; &g...
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.
2018 Jan 16
4
[PATCH nbdkit v2 2/3] Refactor plugin_* functions into a backend
v1 -> v2: - Fixed everything mentioned in the review. Rich.
2018 Jan 16
0
[PATCH nbdkit 2/3] Refactor plugin_* functions into a backend struct.
...git a/src/connections.c b/src/connections.c index 74bb8e4..921a5b2 100644 --- a/src/connections.c +++ b/src/connections.c @@ -211,16 +211,17 @@ _handle_single_connection (int sockin, int sockout) int nworkers = threads ? threads : DEFAULT_PARALLEL_REQUESTS; pthread_t *workers = NULL; - if (plugin_thread_model () < NBDKIT_THREAD_MODEL_PARALLEL || nworkers == 1) + if (backend->thread_model (backend) < NBDKIT_THREAD_MODEL_PARALLEL || + nworkers == 1) nworkers = 0; conn = new_connection (sockin, sockout, nworkers); if (!conn) goto done; - if (plugin_open (conn, readonly) ==...
2018 Jan 17
0
[PATCH 2/9] Refactor plugin_* functions into a backend struct.
...git a/src/connections.c b/src/connections.c index 74bb8e4..921a5b2 100644 --- a/src/connections.c +++ b/src/connections.c @@ -211,16 +211,17 @@ _handle_single_connection (int sockin, int sockout) int nworkers = threads ? threads : DEFAULT_PARALLEL_REQUESTS; pthread_t *workers = NULL; - if (plugin_thread_model () < NBDKIT_THREAD_MODEL_PARALLEL || nworkers == 1) + if (backend->thread_model (backend) < NBDKIT_THREAD_MODEL_PARALLEL || + nworkers == 1) nworkers = 0; conn = new_connection (sockin, sockout, nworkers); if (!conn) goto done; - if (plugin_open (conn, readonly) ==...
2018 Jan 16
0
[PATCH nbdkit v2 2/3] Refactor plugin_* functions into a backend struct.
...git a/src/connections.c b/src/connections.c index 74bb8e4..921a5b2 100644 --- a/src/connections.c +++ b/src/connections.c @@ -211,16 +211,17 @@ _handle_single_connection (int sockin, int sockout) int nworkers = threads ? threads : DEFAULT_PARALLEL_REQUESTS; pthread_t *workers = NULL; - if (plugin_thread_model () < NBDKIT_THREAD_MODEL_PARALLEL || nworkers == 1) + if (backend->thread_model (backend) < NBDKIT_THREAD_MODEL_PARALLEL || + nworkers == 1) nworkers = 0; conn = new_connection (sockin, sockout, nworkers); if (!conn) goto done; - if (plugin_open (conn, readonly) ==...
2018 Jan 17
14
[PATCH 0/9] Add filters to nbdkit.
The first three patches are identical to: https://www.redhat.com/archives/libguestfs/2018-January/msg00079.html "[PATCH nbdkit v2 0/3] Refactor plugin_* functions into a backend" The rest of the patches add filters using the new filter API previously described here: https://www.redhat.com/archives/libguestfs/2018-January/msg00073.html This needs a lot more testing -- and tests --
2018 Jan 17
0
[PATCH 4/9] backend: Add a .plugin_name method.
...char *(*version) (struct backend *); void (*dump_fields) (struct backend *); diff --git a/src/plugins.c b/src/plugins.c index 6a2ef66..f0fe864 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -465,6 +465,7 @@ static struct backend plugin_functions = { .free = plugin_free, .thread_model = plugin_thread_model, .name = plugin_name, + .plugin_name = plugin_name, .usage = plugin_usage, .version = plugin_version, .dump_fields = plugin_dump_fields, -- 2.15.1
2019 Aug 02
1
[nbdkit PATCH] server: Restrict thread model when no atomic CLOEXEC
...--git a/server/plugins.c b/server/plugins.c index 3bb20c93..be952504 100644 --- a/server/plugins.c +++ b/server/plugins.c @@ -39,6 +39,7 @@ #include <inttypes.h> #include <assert.h> #include <errno.h> +#include <sys/socket.h> #include <dlfcn.h> @@ -90,6 +91,14 @@ plugin_thread_model (struct backend *b) int thread_model = p->plugin._thread_model; int r; +#if !(defined SOCK_CLOEXEC && defined HAVE_MKOSTEMP && defined HAVE_PIPE2 && \ + defined HAVE_ACCEPT4) + if (thread_model > NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS) { + nbdkit_de...
2018 Jan 17
2
Re: [PATCH 4/9] backend: Add a .plugin_name method.
...have a way to report independent version numbers (via .version) for the filter, compared to the version of the underlying plugin (via .plugin_version)? > +++ b/src/plugins.c > @@ -465,6 +465,7 @@ static struct backend plugin_functions = { > .free = plugin_free, > .thread_model = plugin_thread_model, > .name = plugin_name, > + .plugin_name = plugin_name, > .usage = plugin_usage, > .version = plugin_version, > .dump_fields = plugin_dump_fields, > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvi...
2019 May 20
0
[nbdkit PATCH 1/2] plugins: Add .thread_model callback
...(void *handle, uint32_t count, uint64_t offset, uint32_t flags); + + int (*thread_model) (void); }; extern void nbdkit_set_error (int err); diff --git a/server/plugins.c b/server/plugins.c index f293e6a..85736bb 100644 --- a/server/plugins.c +++ b/server/plugins.c @@ -87,8 +87,18 @@ static int plugin_thread_model (struct backend *b) { struct backend_plugin *p = container_of (b, struct backend_plugin, backend); + int thread_model = p->plugin._thread_model; + int r; - return p->plugin._thread_model; + if (p->plugin.thread_model) { + r = p->plugin.thread_model (); + if (r == -1) +...
2018 Jan 19
16
[nbdkit PATCH v2 00/13] Add filters + FUA support to nbdkit
A combination of the work that both Rich and I have been doing lately, where filters use only the new API with flags on every command that the client can send over the wire (we can then add support for more flags in nbdkit without having to add new callbacks, as NBD adds more flags upstream). Eric Blake (4): protocol: Split flags from cmd field in requests backend: Pass flags argument through
2019 Nov 02
2
[PATCH nbdkit] server: Use GCC hints to move debug and error handling code out of hot paths.
...\ + nbdkit_debug ((fs), ##__VA_ARGS__); \ + } while (0) /* log-*.c */ #if !HAVE_VFPRINTF_PERCENT_M diff --git a/server/plugins.c b/server/plugins.c index 87daaf2..65f6817 100644 --- a/server/plugins.c +++ b/server/plugins.c @@ -71,7 +71,7 @@ plugin_thread_model (struct backend *b) #if !(defined SOCK_CLOEXEC && defined HAVE_MKOSTEMP && defined HAVE_PIPE2 && \ defined HAVE_ACCEPT4) if (thread_model > NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS) { - nbdkit_debug ("system lacks atomic CLOEXEC, serializing to avoid...
2019 Aug 30
0
[nbdkit PATCH 2/9] server: Consolidate common backend tasks into new backend.c
...debug ("%s: unload", p->name); - if (p->plugin.unload) - p->plugin.unload (); - - if (DO_DLCLOSE) - dlclose (p->dl); - free (p->filename); - - unlock_unload (); - - free (p->name); + backend_unload (b, p->plugin.unload); free (p); } @@ -113,9 +95,7 @@ plugin_thread_model (struct backend *b) static const char * plugin_name (struct backend *b) { - struct backend_plugin *p = container_of (b, struct backend_plugin, backend); - - return p->name; + return b->name; } static void @@ -124,11 +104,11 @@ plugin_usage (struct backend *b) struct backend_plugin...
2018 Jan 17
0
[PATCH 7/9] Implement filters.
..."%s: unload", f->filename); + if (f->filter.unload) + f->filter.unload (); + + dlclose (f->dl); + free (f->filename); + + unlock_unload (); + + free (f); +} + +/* These are actually passing through to the final plugin, hence + * the function names. + */ +static int +plugin_thread_model (struct backend *b) +{ + struct backend_filter *f = container_of (b, struct backend_filter, backend); + + return f->backend.next->thread_model (f->backend.next); +} + +static int +plugin_errno_is_preserved (struct backend *b) +{ + struct backend_filter *f = container_of (b, struct backe...
2019 May 20
3
[nbdkit PATCH 0/2] More on .thread_model
Rich pointed out that making thread_model dynamic even for plugins makes some sense, so here is the code for doing it for 'sh'. I'm less confident on how to do it for OCaml and Rust (not to mention that those allow the plugin to already compile in their model, rather than the language binding glue forcing a model). The other languages (lua, perl, python, ruby) still need to be
2020 Mar 19
5
[nbdkit PATCH 0/2] More caching of initial setup
When I added .can_FOO caching in 1.16, I missed the case that the sh plugin itself was calling .can_flush twice in some situations (in order to default .can_fua). Then right after, I regressed it to call .can_zero twice (in order to default .can_fast_zero). I also missed that .thread_model could use better caching, because at the time, I did not add testsuite coverage. Fix that now. Eric Blake
2019 Aug 02
2
Re: [nbdkit PATCH v2 10/17] plugins: Add .fork_safe field
On Fri, Aug 02, 2019 at 02:26:11PM -0500, Eric Blake wrote: > Allow a plugin field to declare whether a parallel plugin can tolerate > windows where fds are not CLOEXEC, or must take precautions to avoid > leaking fds if the plugin may fork. For safety reasons, the flag > defaults to off, but many in-tree plugins can set it to on (most > commonly because they don't fork after