search for: sh_cache

Displaying 13 results from an estimated 13 matches for "sh_cache".

2019 May 10
0
[nbdkit PATCH 6/9] sh: Implement .cache script callback
...i_conn"); } +static int +sh_can_cache (void *handle) +{ + return boolean_method (handle, "can_cache"); +} + static int sh_flush (void *handle, uint32_t flags) { @@ -782,6 +788,38 @@ sh_extents (void *handle, uint32_t count, uint64_t offset, uint32_t flags, } } +static int +sh_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +{ + char *h = handle; + char cbuf[32], obuf[32]; + const char *args[] = { script, "cache", h, cbuf, obuf, NULL }; + + snprintf (cbuf, sizeof cbuf, "%" PRIu32, count); + snprintf (obuf, sizeof obuf, "%&quo...
2019 May 16
0
[nbdkit PATCH v2 07/24] sh: Implement .cache script callback
...quot;, + script, "can_cache"); + errno = EIO; + return -1; + + default: abort (); + } +} + static int sh_flush (void *handle, uint32_t flags) { @@ -782,6 +829,38 @@ sh_extents (void *handle, uint32_t count, uint64_t offset, uint32_t flags, } } +static int +sh_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +{ + char *h = handle; + char cbuf[32], obuf[32]; + const char *args[] = { script, "cache", h, cbuf, obuf, NULL }; + + snprintf (cbuf, sizeof cbuf, "%" PRIu32, count); + snprintf (obuf, sizeof obuf, "%&quo...
2020 Sep 21
0
[nbdkit PATCH v3 06/14] api: Add .export_description
...e = sh_can_cache, + .can_fast_zero = sh_can_fast_zero, - .pread = sh_pread, - .pwrite = sh_pwrite, - .flush = sh_flush, - .trim = sh_trim, - .zero = sh_zero, - .extents = sh_extents, - .cache = sh_cache, + .pread = sh_pread, + .pwrite = sh_pwrite, + .flush = sh_flush, + .trim = sh_trim, + .zero = sh_zero, + .extents = sh_extents, + .cache = sh_cache, .errno_is_preserved = 1, }; diff --git a/plugin...
2019 Aug 02
0
[nbdkit PATCH v2 14/17] sh: Use pipe2 with CLOEXEC when possible
...+++ b/plugins/sh/sh.c @@ -263,6 +263,7 @@ sh_config_complete (void) } } +/* See also .fork_safe and the comments in call.c:call3() */ #define THREAD_MODEL NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS static int @@ -960,7 +961,9 @@ static struct nbdkit_plugin plugin = { .cache = sh_cache, .errno_is_preserved = 1, - .fork_safe = 0, /* use of fork() is not yet safe from fd leaks */ +#ifdef HAVE_PIPE2 + .fork_safe = 1, /* use of fork() is only safe with atomic CLOEXEC */ +#endif }; NBDKIT_REGISTER_PLUGIN(plugin) -- 2.20.1
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
0
[nbdkit PATCH 1/2] sh, eval: Cache .can_zero and .can_flush
...e; + struct sh_handle *h = handle; char cbuf[32], obuf[32], fbuf[32]; - const char *args[] = { script, method, h, cbuf, obuf, fbuf, NULL }; + const char *args[] = { script, method, h->h, cbuf, obuf, fbuf, NULL }; CLEANUP_FREE char *s = NULL; size_t slen; int r; @@ -840,9 +868,9 @@ sh_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) { const char *method = "cache"; const char *script = get_script (method); - char *h = handle; + struct sh_handle *h = handle; char cbuf[32], obuf[32]; - const char *args[] = { script, method, h, cbuf, obuf, NULL...
2019 Aug 02
0
[nbdkit PATCH v2 10/17] plugins: Add .fork_safe field
...d = 1, + .fork_safe = 1, /* no use of fork() */ }; NBDKIT_REGISTER_PLUGIN(plugin) diff --git a/plugins/sh/sh.c b/plugins/sh/sh.c index 5869d9a4..669008e9 100644 --- a/plugins/sh/sh.c +++ b/plugins/sh/sh.c @@ -960,6 +960,7 @@ static struct nbdkit_plugin plugin = { .cache = sh_cache, .errno_is_preserved = 1, + .fork_safe = 0, /* use of fork() is not yet safe from fd leaks */ }; NBDKIT_REGISTER_PLUGIN(plugin) diff --git a/plugins/split/split.c b/plugins/split/split.c index 68682b29..babbaf4a 100644 --- a/plugins/split/split.c +++ b/plugins/split/split.c @@ -339,...
2019 May 10
11
[nbdkit PATCH 0/9] RFC: implement NBD_CMD_CACHE
I'm still working my way through the filters before this series will be complete, but this is enough of a start to at least get some feedback on the idea of implementing another NBD protocol extension. Eric Blake (9): server: Internal hooks for implementing NBD_CMD_CACHE plugins: Add .cache callback file, split: Implement .cache with posix_fadvise nbd: Implement NBD_CMD_CACHE
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
2020 Aug 27
10
[nbdkit PATCH v2 0/8] exportname filter
This is a revision of my .default_export work, plus new work on .export_descriptions and a new exportname filter. I think it is now ready to check in. Things I'd still like in 1.22: - the file plugin should implement .list_exports (patch already posted, but it needs rebasing on this series) - the ext2 filter should override .list_exports when in exportname mode - the nbd plugin should be
2020 Sep 21
18
[nbdkit PATCH v3 00/14] exportname filter
It's been several weeks since I posted v2 (I got distracted by improving libnbd to better test things, which in turn surfaced some major memory leak problems in nbdsh that are now fixed). Many of the patches are minor rebases from v2, with the biggest changes being fallout from: - patch 2: rename nbdkit_add_default_export to nbdkit_use_default_export - overall: this missed 1.22, so update
2019 Aug 02
23
[nbdkit PATCH v2 00/17] fd leak safety
This is a major rewrite compared to my v1 series, where I've tried a lot harder to ensure that we still accommodate building on Haiku (although I have not actually yet fired up a Haiku VM to try it for myself). I also managed to make the sh plugin fully parallel, on capable platforms. See also my question on patch 10 on whether I've picked the best naming convention. Eric Blake (17):
2019 May 16
27
[nbdkit PATCH v2 00/24] implement NBD_CMD_CACHE
Since v1: - rework .can_cache to be tri-state, with default of no advertisement (ripple effect through other patches) - add a lot more patches in order to round out filter support And in the meantime, Rich pushed NBD_CMD_CACHE support into libnbd, so in theory we now have a way to test cache commands through the entire stack. Eric Blake (24): server: Internal hooks for implementing