search for: command_cb

Displaying 20 results from an estimated 55 matches for "command_cb".

2020 Sep 07
0
[libnbd PATCH 1/2] generator: Refactor handling of closures in unlocked functions
...int64_t nbd_unlocked_aio_pread (struct nbd_handle *h, void *buf, size_t count, uint64_t offset, - nbd_completion_callback completion, + nbd_completion_callback *completion, uint32_t flags) { - struct command_cb cb = { .completion = completion }; + struct command_cb cb = { .completion = *completion }; /* We could silently accept flag DF, but it really only makes sense * with callbacks, because otherwise there is no observable change @@ -283,12 +283,12 @@ nbd_unlocked_aio_pread (struct nbd_handle *...
2019 Jul 16
1
[libnbd PATCH] generator: Prefer closure opaque after function pointer in C
...const char *); + void *debug_data; /* Linked list of close callbacks. */ struct close_callback *close_callbacks; @@ -249,12 +249,12 @@ typedef int (*read_fn) (void *user_data, const void *buf, size_t count, typedef int (*callback_fn) (void *user_data, int64_t cookie, int *error); struct command_cb { - void *user_data; union { extent_fn extent; read_fn read; } fn; callback_fn callback; + void *user_data; }; struct command_in_flight { diff --git a/lib/rw.c b/lib/rw.c index f2fe4e0..d32f0dc 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -60,12 +60,12 @@ nbd_unlocked_pread (stru...
2019 Jul 16
2
[PATCH libnbd] generator: Define new Closure type
** INCOMPLETE ** This is the generator change as discussed on the list already. The Python and OCaml bindings are not yet done. It passes all [C only] tests and valgrind. Note that nbd_add_close_callback is inconsistent with other closure types because it passes the user_data parameter after the function. (This is not caused by the current patch, it was already inconsistent). We decided that
2019 Aug 03
1
[PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.
...nt (*read_fn) (unsigned valid_flag, void *user_data, - const void *buf, size_t count, - uint64_t offset, unsigned status, int *error); -typedef int (*callback_fn) (unsigned valid_flag, void *user_data, - int *error); - struct command_cb { union { - extent_fn extent; - read_fn read; + nbd_extent_callback extent; + nbd_chunk_callback chunk; } fn; void *fn_user_data; /* associated with one of the fn callbacks above */ - callback_fn callback; - void *user_data; /* associated with the callback function */ + nbd_...
2019 Jun 18
0
[libnbd PATCH 4/8] states: Prepare for read callback
...socket_ops *ops; }; -typedef int (*extent_fn) (void *data, const char *metacontext, uint64_t offset, uint32_t *entries, size_t nr_entries); +typedef int (*extent_fn) (void *data, const char *metacontext, uint64_t offset, + uint32_t *entries, size_t nr_entries); + +struct command_cb { + void *opaque; + union { + extent_fn extent; + /* More to come */ + } fn; +}; struct command_in_flight { struct command_in_flight *next; @@ -240,8 +249,8 @@ struct command_in_flight { uint64_t handle; uint64_t offset; uint32_t count; - void *data; /* Buffer for read/write...
2020 Sep 04
0
[libnbd PATCH 1/2] api: Add nbd_set_strict_mode
..._handle *h) +{ + return h->strict; +} + const char * nbd_unlocked_get_package_name (struct nbd_handle *h) { diff --git a/lib/rw.c b/lib/rw.c index 8b736d3..b5c1698 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -267,13 +267,15 @@ nbd_unlocked_aio_pread (struct nbd_handle *h, void *buf, { struct command_cb cb = { .completion = completion }; - /* We could silently accept flag DF, but it really only makes sense - * with callbacks, because otherwise there is no observable change - * except that the server may fail where it would otherwise succeed. - */ - if (flags != 0) { - set_error (EINVAL...
2019 Jun 29
0
[libnbd PATCH 5/6] api: Add new nbd_aio_FOO_notify functions
...et, NULL, NULL, + flags); +} + +int64_t +nbd_unlocked_aio_pread_notify (struct nbd_handle *h, void *buf, + size_t count, uint64_t offset, + void *opaque, notify_fn notify, uint32_t flags) +{ + struct command_cb cb = { .opaque = opaque, .notify = notify, }; + /* We could silently accept flag DF, but it really only makes sense * with callbacks, because otherwise there is no observable change * except that the server may fail where it would otherwise succeed. @@ -259,7 +270,7 @@ nbd_unlocked_aio_p...
2019 Jul 16
0
[PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
...unt, +typedef int (*read_fn) (void *user_data, const void *buf, size_t count, uint64_t offset, int status, int *error); -typedef int (*callback_fn) (void *data, int64_t cookie, int *error); +typedef int (*callback_fn) (void *user_data, int64_t cookie, int *error); struct command_cb { - void *opaque; + void *user_data; union { extent_fn extent; read_fn read; diff --git a/lib/rw.c b/lib/rw.c index a878fea..f2fe4e0 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -60,12 +60,12 @@ nbd_unlocked_pread (struct nbd_handle *h, void *buf, int nbd_unlocked_pread_structured (stru...
2020 Sep 07
4
[libnbd PATCH 0/2] Fix memory leak with closures
As promised in my earlier thread on libnbd completion callback question. Eric Blake (2): generator: Refactor handling of closures in unlocked functions generator: Free closures on failure docs/libnbd.pod | 2 +- generator/C.ml | 48 +++++++++++------ generator/C.mli | 1 + lib/debug.c | 7 +-- lib/opt.c | 31 ++++++-----
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...t a/lib/internal.h b/lib/internal.h index 301b798..5996a4f 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -85,7 +85,6 @@ struct nbd_handle { /* For debugging. */ bool debug; nbd_debug_callback debug_callback; - void *debug_data; /* State machine. * @@ -257,9 +256,7 @@ struct command_cb { nbd_extent_callback extent; nbd_chunk_callback chunk; } fn; - void *fn_user_data; /* associated with one of the fn callbacks above */ nbd_completion_callback completion; - void *user_data; /* associated with the completion callback */ }; struct command { diff --git a/lib/rw....
2019 Jul 16
2
[PATCH libnbd v2] generator: Define new Closure type
As before, but this one has working Python bindings. OCaml still TBD. Rich.
2020 Sep 11
0
[libnbd PATCH v2 3/5] api: Add nbd_set_strict_mode
...*h) +{ + return h->strict; +} + const char * nbd_unlocked_get_package_name (struct nbd_handle *h) { diff --git a/lib/rw.c b/lib/rw.c index 95c002c..f49fe25 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -295,10 +295,12 @@ nbd_unlocked_aio_pread_structured (struct nbd_handle *h, void *buf, struct command_cb cb = { .fn.chunk = *chunk, .completion = *completion }; - if ((flags & LIBNBD_CMD_FLAG_DF) != 0 && - nbd_unlocked_can_df (h) != 1) { - set_error (EINVAL, "server does not support the DF flag"); - return -1; + if (h->strict & LIB...
2020 Sep 04
4
[RFC libnbd PATCH 0/2] Add knobs for client- vs. server-side validation
We have been inconsistent on how much we reject client-side without even consulting the server, vs. how much we depend on the server to detect failure (even if our request can be deemed undefined per NBD protocol). I'd like to change it so that by default, we reject as much as we can client-side for less traffic, but where the user can also change things on the fly for server-side integration
2020 Sep 11
0
[libnbd PATCH v2 5/5] api: Add STRICT_BOUNDS/ZERO_SIZE to nbd_set_strict_mode
...int16_t type); extern int64_t nbd_internal_command_common (struct nbd_handle *h, uint16_t flags, uint16_t type, uint64_t offset, uint64_t count, - void *data, struct command_cb *cb); + int count_err, void *data, + struct command_cb *cb); /* socket.c */ struct socket *nbd_internal_socket_create (int fd); diff --git a/generator/API.ml b/generator/API.ml index 4cd425b..d3b1d1b 100644 ---...
2019 Aug 06
0
[PATCH libnbd 1/3] api: Change nbd_read_only -> nbd_is_read_only.
...+nbd_unlocked_is_read_only (struct nbd_handle *h) { return get_flag (h, NBD_FLAG_READ_ONLY); } diff --git a/lib/rw.c b/lib/rw.c index bba62be..50ba23d 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -341,7 +341,7 @@ nbd_unlocked_aio_pwrite_callback (struct nbd_handle *h, const void *buf, { struct command_cb cb = { .completion = completion, .user_data = user_data, }; - if (nbd_unlocked_read_only (h) == 1) { + if (nbd_unlocked_is_read_only (h) == 1) { set_error (EINVAL, "server does not support write operations"); return -1; } @@ -406,7 +406,7 @@ nbd_unlocked_aio_trim_callback...
2019 Aug 13
0
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
...void *user_data, - uint32_t flags) + size_t count, uint64_t offset, + nbd_completion_callback completion, + void *user_data, + uint32_t flags) { struct command_cb cb = { .completion = completion, .user_data = user_data, }; @@ -285,23 +278,11 @@ nbd_unlocked_aio_pread_callback (struct nbd_handle *h, void *buf, int64_t nbd_unlocked_aio_pread_structured (struct nbd_handle *h, void *buf, size_t count, uint64_t offset, -...
2019 Aug 13
2
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
This applies on top of the OClosure v2 series posted a few minutes ago. Rich.
2019 Jun 29
0
[libnbd PATCH 4/6] states: Prepare for aio notify callback
...t offset, uint32_t *entries, size_t nr_entries, int *error); typedef int (*read_fn) (void *data, const void *buf, size_t count, uint64_t offset, int *error, int status); +typedef int (*notify_fn) (void *data, int64_t handle, int *error); struct command_cb { void *opaque; @@ -246,6 +247,7 @@ struct command_cb { extent_fn extent; read_fn read; } fn; + notify_fn notify; }; struct command_in_flight { diff --git a/tests/server-death.c b/tests/server-death.c index d490753..f8747e4 100644 --- a/tests/server-death.c +++ b/tests/server-de...
2020 Sep 11
10
[libnbd PATCH v2 0/5] Add knobs for client- vs. server-side validation
In v2: - now based on my proposal to add LIBNBD_SHUTDOWN_IMMEDIATE - four flags instead of two: STRICT_FLAGS is new (patch 4), and STRICT_BOUNDS is separate from STRICT_ZERO_SIZE (patch 5) - various refactorings for more shared code and less duplication Eric Blake (5): api: Add xxx_MASK constant for each Flags type generator: Refactor filtering of accepted OFlags api: Add
2019 Aug 06
5
[PATCH libnbd 0/3] One API and small documentation changes.
One API change, some small documentation changes.