search for: reply_cmd

Displaying 19 results from an estimated 19 matches for "reply_cmd".

Did you mean: reply_cb
2019 Jun 18
0
[libnbd PATCH 2/8] states: Consolidate search for current reply's command
...ply-simple.c b/generator/states-reply-simple.c index 7e5340c..12536e0 100644 --- a/generator/states-reply-simple.c +++ b/generator/states-reply-simple.c @@ -20,24 +20,15 @@ /* STATE MACHINE */ { REPLY.SIMPLE_REPLY.START: - struct command_in_flight *cmd; + struct command_in_flight *cmd = h->reply_cmd; uint32_t error; uint64_t handle; error = be32toh (h->sbuf.simple_reply.error); handle = be64toh (h->sbuf.simple_reply.handle); - /* Find the command amongst the commands in flight. */ - for (cmd = h->cmds_in_flight; cmd != NULL; cmd = cmd->next) { - if (cmd->handl...
2019 Jun 19
4
[libnbd PATCH] states: Never block state machine inside REPLY
...parsing a reply, requiring us to block + * until POLLIN, we instead track where in the state machine we left + * off, then return to READY to actually block. Then, on entry to + * REPLY.START, we can tell if this is the start of a new reply (rlen + * is 0, stay put), a continuation of the preamble (reply_cmd is NULL, + * resume with RECV_REPLY), or a continuation from any other location + * (reply_cmd contains the state to jump to). + */ + +static void +save_reply_state (struct nbd_handle *h) +{ + assert (h->reply_cmd); + assert (h->rlen); + h->reply_cmd->state = get_next_state (h); +} +...
2019 Jun 25
0
Re: [libnbd PATCH] states: Never block state machine inside REPLY
...uiring us to block > + * until POLLIN, we instead track where in the state machine we left > + * off, then return to READY to actually block. Then, on entry to > + * REPLY.START, we can tell if this is the start of a new reply (rlen > + * is 0, stay put), a continuation of the preamble (reply_cmd is NULL, > + * resume with RECV_REPLY), or a continuation from any other location > + * (reply_cmd contains the state to jump to). > + */ > + > +static void > +save_reply_state (struct nbd_handle *h) > +{ > + assert (h->reply_cmd); > + assert (h->rlen); > + h-...
2023 Jun 09
4
[libnbd PATCH v4 0/4] Saner reply header layout
This was v3 patch 2/22, reworked to address the confusion about how a structured reply header is read in two pieces before getting to the payload portion. I'm still working on rebasing the rest of my v3 series (patches 1, 3-22) from other comments given, but this seemed independent enough that it's worth posting now rather than holding it up for the rest of the series. Eric Blake (4):
2019 Jun 18
17
[libnbd PATCH 0/8] Add nbd_pread_callback
I've mentioned this topic before (in fact, the idea of adding NBD_CMD_FLAG_DF was first mentioned at [1]), but finally finished enough of an implementation to feel confident in posting it. I'd still like to add something under examples/ that uses the new API to implement strict checking of a server's structured replies read implementation (ensure that a server never sends data after
2019 Jul 25
0
[libnbd PATCH] lib: Call read/extent(FREE) before callback(VALID|FREE)
...structured.c b/generator/states-reply-structured.c index 20b0e9e..ff5b727 100644 --- a/generator/states-reply-structured.c +++ b/generator/states-reply-structured.c @@ -540,11 +540,20 @@ valid_flags (struct nbd_handle *h) return 0; REPLY.STRUCTURED_REPLY.FINISH: + struct command *cmd = h->reply_cmd; uint16_t flags; flags = be16toh (h->sbuf.sr.structured_reply.flags); - if (flags & NBD_REPLY_FLAG_DONE) + if (flags & NBD_REPLY_FLAG_DONE) { + if (cmd->type == NBD_CMD_BLOCK_STATUS && cmd->cb.fn.extent) + cmd->cb.fn.extent (LIBNBD_CALLBACK_FREE, cmd-&gt...
2019 Aug 14
2
[libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...cmd->error = error ? error : EPROTO; - if (flags & NBD_REPLY_FLAG_DONE) - FREE_CALLBACK (cmd->cb.fn.extent); } else /* Emit a debug message, but ignore it. */ @@ -530,17 +518,11 @@ return 0; REPLY.STRUCTURED_REPLY.FINISH: - struct command *cmd = h->reply_cmd; uint16_t flags; flags = be16toh (h->sbuf.sr.structured_reply.flags); - if (flags & NBD_REPLY_FLAG_DONE) { - if (cmd->type == NBD_CMD_BLOCK_STATUS) - FREE_CALLBACK (cmd->cb.fn.extent); - if (cmd->type == NBD_CMD_READ) - FREE_CALLBACK (cmd->cb.fn.chunk); +...
2019 Jun 18
0
[libnbd PATCH 5/8] states: Wire in a read callback
...diff --git a/generator/states-reply-simple.c b/generator/states-reply-simple.c index 935f6d2..ddc91ce 100644 --- a/generator/states-reply-simple.c +++ b/generator/states-reply-simple.c @@ -49,9 +49,22 @@ return 0; REPLY.SIMPLE_REPLY.RECV_READ_PAYLOAD: + struct command_in_flight *cmd = h->reply_cmd; + switch (recv_into_rbuf (h)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; - case 0: SET_NEXT_STATE (%^FINISH_COMMAND); + case 0: + /* guaranteed by START */ + assert (cmd); + if (cmd->cb.fn.read) { + assert (cmd->error == 0); + errno = 0; + if (cmd->cb....
2019 Jun 21
0
[libnbd PATCH v2 2/5] states: Wire in a read callback
...diff --git a/generator/states-reply-simple.c b/generator/states-reply-simple.c index 935f6d2..87622a0 100644 --- a/generator/states-reply-simple.c +++ b/generator/states-reply-simple.c @@ -49,9 +49,22 @@ return 0; REPLY.SIMPLE_REPLY.RECV_READ_PAYLOAD: + struct command_in_flight *cmd = h->reply_cmd; + switch (recv_into_rbuf (h)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; - case 0: SET_NEXT_STATE (%^FINISH_COMMAND); + case 0: + /* guaranteed by START */ + assert (cmd); + if (cmd->cb.fn.read) { + assert (cmd->error == 0); + errno = 0; + if (cmd->cb....
2019 Aug 15
0
Re: [libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...if (flags & NBD_REPLY_FLAG_DONE) > - FREE_CALLBACK (cmd->cb.fn.extent); > } > else > /* Emit a debug message, but ignore it. */ > @@ -530,17 +518,11 @@ > return 0; > > REPLY.STRUCTURED_REPLY.FINISH: > - struct command *cmd = h->reply_cmd; > uint16_t flags; > > flags = be16toh (h->sbuf.sr.structured_reply.flags); > - if (flags & NBD_REPLY_FLAG_DONE) { > - if (cmd->type == NBD_CMD_BLOCK_STATUS) > - FREE_CALLBACK (cmd->cb.fn.extent); > - if (cmd->type == NBD_CMD_READ) > -...
2019 Jun 28
1
[libnbd PATCH] disconnect: Prevent any further commands
...--git a/lib/internal.h b/lib/internal.h index 88ad703..11e0db6 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -191,6 +191,8 @@ struct nbd_handle { struct command_in_flight *cmds_to_issue, *cmds_in_flight, *cmds_done; /* Current command during a REPLY cycle */ struct command_in_flight *reply_cmd; + + bool disconnect_request; /* True if we've sent NBD_CMD_DISC */ }; struct meta_context { diff --git a/lib/rw.c b/lib/rw.c index 2dc60de..6b57f11 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -163,6 +163,11 @@ nbd_internal_command_common (struct nbd_handle *h, { struct command_in_flig...
2023 Aug 04
2
[libnbd PATCH v4 01/25] block_status: Add some sanity checking of server lengths
...gt; diff --git a/generator/states-reply-chunk.c b/generator/states-reply-chunk.c > index 17bb5149..735f9456 100644 > --- a/generator/states-reply-chunk.c > +++ b/generator/states-reply-chunk.c > @@ -461,6 +461,11 @@ REPLY.CHUNK_REPLY.RECV_BS_ENTRIES: > struct command *cmd = h->reply_cmd; > size_t i; > uint32_t context_id; > + int error; > + const char *name; > + uint32_t orig_len, len, flags; > + uint64_t total, cap; > + bool stop; > > switch (recv_into_rbuf (h)) { > case -1: SET_NEXT_STATE (%.DEAD); return 0; > @@ -481,30 +486,63...
2023 Jun 20
1
[libnbd PATCH v4 4/4] internal: Refactor layout of replies in sbuf
...offsetof (union reply_header, cookie), > + _cookie_aliasing_simple); > + STATIC_ASSERT (offsetof (union reply_header, structured.cookie) == > + offsetof (union reply_header, cookie), > + _cookie_aliasing_structured); > assert (h->reply_cmd == NULL); > assert (h->rlen == 0); > > - h->rbuf = &h->sbuf; > - h->rlen = sizeof h->sbuf.simple_reply; > + h->rbuf = &h->sbuf.reply.hdr; > + h->rlen = sizeof h->sbuf.reply.hdr.simple; > > r = h->sock->ops->recv (h, h-&...
2019 Jul 23
4
[libnbd PATCH] api: Allow completion callbacks to auto-retire
...struct command *prev_cmd, *cmd; uint64_t cookie; + bool retire; /* NB: This works for both simple and structured replies because the * handle (our cookie) is stored at the same offset. @@ -164,6 +165,23 @@ save_reply_state (struct nbd_handle *h) assert (cmd != NULL); assert (h->reply_cmd == cmd); h->reply_cmd = NULL; + retire = cmd->type == NBD_CMD_DISC; + + /* Notify the user */ + if (cmd->cb.callback) { + int error = cmd->error; + + assert (cmd->type != NBD_CMD_DISC); + switch (cmd->cb.callback (cmd->cb.user_data, cookie, &error)) { + ca...
2019 Jun 29
0
[libnbd PATCH 2/6] generator: Allow DEAD state actions to run
...n -1; + return 0; } SET_NEXT_STATE (%.READY); diff --git a/generator/states-reply-simple.c b/generator/states-reply-simple.c index cab72d6..23b6b5f 100644 --- a/generator/states-reply-simple.c +++ b/generator/states-reply-simple.c @@ -52,7 +52,7 @@ struct command_in_flight *cmd = h->reply_cmd; switch (recv_into_rbuf (h)) { - case -1: SET_NEXT_STATE (%.DEAD); return -1; + case -1: SET_NEXT_STATE (%.DEAD); return 0; case 1: save_reply_state (h); SET_NEXT_STATE (%.READY); diff --git a/generator/states-reply-structured.c b/generator/states-reply-structured.c index 91c6215...
2019 Jun 29
0
[libnbd PATCH 1/6] api: Add nbd_aio_in_flight
...program to - * acknowledge them. + * acknowledge them. in_flight tracks the combined length of the + * first two lists. */ struct command_in_flight *cmds_to_issue, *cmds_in_flight, *cmds_done; + int in_flight; /* Current command during a REPLY cycle */ struct command_in_flight *reply_cmd; diff --git a/lib/rw.c b/lib/rw.c index 6b57f11..53cd521 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -25,6 +25,7 @@ #include <inttypes.h> #include <errno.h> #include <assert.h> +#include <limits.h> #include "internal.h" @@ -167,6 +168,10 @@ nbd_internal_command_...
2019 Jun 21
9
[libnbd PATCH v2 0/5] nbd_pread_structured
Since v1: - rebase to applied patches - split out support for Int in callbacks - sort of test that callbacks work in OCaml (see comment in patch 5) - rename API to nbd_pread_structured - expose error as explicit parameter to callback Eric Blake (5): generator: Allow Int in callbacks states: Wire in a read callback states: Add nbd_pread_structured API states: Add tests for
2019 Jun 29
19
[libnbd PATCH 0/6] new APIs: aio_in_flight, aio_FOO_notify
I still need to wire in the use of *_notify functions into nbdkit to prove whether it makes the code any faster or easier to maintain, but at least the added example shows one good use case for the new API. Eric Blake (6): api: Add nbd_aio_in_flight generator: Allow DEAD state actions to run generator: Allow Int64 in callbacks states: Prepare for aio notify callback api: Add new
2019 Aug 15
13
[PATCH libnbd v2 00/10] Callbacks and OCaml and Python persistent buffers.
This is a combination of these two earlier series: https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html https://www.redhat.com/archives/libguestfs/2019-August/msg00240.html plus changes to allow .callback = NULL / .free != NULL, and to reduce the complexity of freeing callbacks. Although it's rather long there's nothing complex here. We might consider squashing some