search for: save_reply_state

Displaying 20 results from an estimated 35 matches for "save_reply_state".

2019 Jun 25
0
Re: [libnbd PATCH] states: Never block state machine inside REPLY
...generator/states-reply-simple.c > index ddc91ce..3b63d07 100644 > --- a/generator/states-reply-simple.c > +++ b/generator/states-reply-simple.c > @@ -53,6 +53,10 @@ > > switch (recv_into_rbuf (h)) { > case -1: SET_NEXT_STATE (%.DEAD); return -1; > + case 1: > + save_reply_state (h); > + SET_NEXT_STATE (%.READY); > + return 0; > case 0: > /* guaranteed by START */ > assert (cmd); > diff --git a/generator/states-reply-structured.c b/generator/states-reply-structured.c > index 00659de..594525e 100644 > --- a/generator/states-reply-s...
2019 Jun 19
4
[libnbd PATCH] states: Never block state machine inside REPLY
...ff --git a/generator/states-reply-simple.c b/generator/states-reply-simple.c index ddc91ce..3b63d07 100644 --- a/generator/states-reply-simple.c +++ b/generator/states-reply-simple.c @@ -53,6 +53,10 @@ switch (recv_into_rbuf (h)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; + case 1: + save_reply_state (h); + SET_NEXT_STATE (%.READY); + return 0; case 0: /* guaranteed by START */ assert (cmd); diff --git a/generator/states-reply-structured.c b/generator/states-reply-structured.c index 00659de..594525e 100644 --- a/generator/states-reply-structured.c +++ b/generator/states-reply...
2019 Jun 29
0
[libnbd PATCH 2/6] generator: Allow DEAD state actions to run
...f 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..9a8677d 100644 --- a/generator/states-reply-structured.c +++ b/generator/states-reply-structured.c @@ -37,7 +37,7 @@ REPLY.STRUCTURED_REPLY.RECV_REMAINING:...
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 Jul 18
3
[libnbd PATCH 0/2] in_flight improvements
Noticed while thinking about the recent threads wondering if we need a more efficient lookup from cookie back to command. Both of these fix bugs, but are tricky enough that I'm posting for review. Eric Blake (2): lib: Decrement in_flight at response, not retirement lib: Do O(1) rather than O(n) queue insertion generator/states-issue-command.c | 2 ++ generator/states-reply.c |
2019 Jul 23
4
[libnbd PATCH] api: Allow completion callbacks to auto-retire
...y a low-level completion callback +returning C<1>) is lost. =head1 GETTING THE LATEST ERROR MESSAGE IN THE THREAD diff --git a/generator/states-reply.c b/generator/states-reply.c index 1a0c149..6ea43d5 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -149,6 +149,7 @@ save_reply_state (struct nbd_handle *h) REPLY.FINISH_COMMAND: 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_ha...
2019 Aug 12
0
[PATCH libnbd 2/7] lib: Allow retired commands to use free_callback on their buffer.
...ndle.c | 10 +++++----- lib/internal.h | 3 ++- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/generator/states-reply.c b/generator/states-reply.c index 09adfed..389317e 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -194,7 +194,7 @@ save_reply_state (struct nbd_handle *h) h->cmds_in_flight = cmd->next; cmd->next = NULL; if (retire) - nbd_internal_retire_and_free_command (cmd); + nbd_internal_retire_and_free_command (h, cmd); else { if (h->cmds_done_tail != NULL) h->cmds_done_tail = h->cmds_done...
2019 Aug 14
2
[libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...G_DONE) SET_NEXT_STATE (%^FINISH_COMMAND); - } else { h->reply_cmd = NULL; SET_NEXT_STATE (%.READY); diff --git a/generator/states-reply.c b/generator/states-reply.c index 41dcf8d..575a6d1 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -174,7 +174,6 @@ save_reply_state (struct nbd_handle *h) assert (cmd->type != NBD_CMD_DISC); r = CALL_CALLBACK (cmd->cb.completion, &error); - FREE_CALLBACK (cmd->cb.completion); switch (r) { case -1: if (error) diff --git a/generator/states.c b/generator/states.c index 263f60e..cfa9957 1...
2019 Aug 13
0
[PATCH libnbd 4/4] lib: Add CALL_CALLBACK macro.
...if (cmd->error == 0) cmd->error = error ? error : EPROTO; if (flags & NBD_REPLY_FLAG_DONE) diff --git a/generator/states-reply.c b/generator/states-reply.c index b8bf0ce..41dcf8d 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -173,7 +173,7 @@ save_reply_state (struct nbd_handle *h) int r; assert (cmd->type != NBD_CMD_DISC); - r = cmd->cb.completion.callback (cmd->cb.completion.user_data, &error); + r = CALL_CALLBACK (cmd->cb.completion, &error); FREE_CALLBACK (cmd->cb.completion); switch (r) { case...
2019 Jun 29
0
[libnbd PATCH 4/6] states: Prepare for aio notify callback
....h | 2 ++ tests/server-death.c | 17 ++++++++++++++--- 4 files changed, 53 insertions(+), 3 deletions(-) diff --git a/generator/states-reply.c b/generator/states-reply.c index 88274bc..c5cd790 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -180,6 +180,14 @@ save_reply_state (struct nbd_handle *h) else h->cmds_done = cmd; + /* Notify the user */ + if (cmd->cb.notify) { + int error = cmd->error; + + if (cmd->cb.notify (cmd->cb.opaque, handle, &error) == -1 && error) + cmd->error = error; + } + SET_NEXT_STATE (%.REA...
2019 Aug 12
0
[PATCH libnbd 4/7] lib: Allow closure user_data to be associated with a free callback.
...allback (h, cmd->cb.fn_user_data); + } cmd->cb.fn.chunk = NULL; SET_NEXT_STATE (%^FINISH_COMMAND); } diff --git a/generator/states-reply.c b/generator/states-reply.c index 389317e..d5cba1a 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -175,6 +175,7 @@ save_reply_state (struct nbd_handle *h) assert (cmd->type != NBD_CMD_DISC); r = cmd->cb.completion (LIBNBD_CALLBACK_VALID|LIBNBD_CALLBACK_FREE, cmd->cb.user_data, &error); + nbd_internal_free_callback (h, cmd->cb.user_data); cmd->cb.completion = NULL...
2019 Aug 15
0
[PATCH libnbd v2 02/10] lib: Add macros to check if a callback is "null" or not, and set it to null.
...assert (CALLBACK_IS_NOT_NULL (cmd->cb.fn.extent)); assert (h->bs_entries); assert (length >= 12); diff --git a/generator/states-reply.c b/generator/states-reply.c index 575a6d1..14bb010 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -168,7 +168,7 @@ save_reply_state (struct nbd_handle *h) retire = cmd->type == NBD_CMD_DISC; /* Notify the user */ - if (cmd->cb.completion.callback) { + if (CALLBACK_IS_NOT_NULL (cmd->cb.completion)) { int error = cmd->error; int r; diff --git a/generator/states.c b/generator/states.c index cfa995...
2019 Jul 18
0
[libnbd PATCH 2/2] lib: Do O(1) rather than O(n) queue insertion
...o_issue_tail = NULL; cmd->next = h->cmds_in_flight; h->cmds_in_flight = cmd; SET_NEXT_STATE (%.READY); diff --git a/generator/states-reply.c b/generator/states-reply.c index 4b22c39..1a0c149 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -171,14 +171,12 @@ save_reply_state (struct nbd_handle *h) else h->cmds_in_flight = cmd->next; cmd->next = NULL; - if (h->cmds_done) { - prev_cmd = h->cmds_done; - while (prev_cmd->next) - prev_cmd = prev_cmd->next; - prev_cmd->next = cmd; + if (h->cmds_done_tail != NULL) + 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 Aug 13
0
[PATCH libnbd 3/4] lib: Add FREE_CALLBACK macro.
...t;type == NBD_CMD_READ) + FREE_CALLBACK (cmd->cb.fn.chunk); SET_NEXT_STATE (%^FINISH_COMMAND); } else { diff --git a/generator/states-reply.c b/generator/states-reply.c index d6bd7be..b8bf0ce 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -174,9 +174,7 @@ save_reply_state (struct nbd_handle *h) assert (cmd->type != NBD_CMD_DISC); r = cmd->cb.completion.callback (cmd->cb.completion.user_data, &error); - if (cmd->cb.completion.free) - cmd->cb.completion.free (cmd->cb.completion.user_data); - cmd->cb.completion.callback =...
2019 Jul 25
4
Re: [PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...d retirement to free chunk/extent instead. As long as that happens, we should be okay, though. > diff --git a/generator/states-reply.c b/generator/states-reply.c > index 6ea43d5..8f62923 100644 > --- a/generator/states-reply.c > +++ b/generator/states-reply.c > @@ -170,9 +170,13 @@ save_reply_state (struct nbd_handle *h) > /* Notify the user */ > if (cmd->cb.callback) { > int error = cmd->error; > + int r; > > assert (cmd->type != NBD_CMD_DISC); > - switch (cmd->cb.callback (cmd->cb.user_data, cookie, &error)) { > + r = cmd...
2019 Aug 15
0
Re: [libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...); > - } > else { > h->reply_cmd = NULL; > SET_NEXT_STATE (%.READY); > diff --git a/generator/states-reply.c b/generator/states-reply.c > index 41dcf8d..575a6d1 100644 > --- a/generator/states-reply.c > +++ b/generator/states-reply.c > @@ -174,7 +174,6 @@ save_reply_state (struct nbd_handle *h) > > assert (cmd->type != NBD_CMD_DISC); > r = CALL_CALLBACK (cmd->cb.completion, &error); > - FREE_CALLBACK (cmd->cb.completion); > switch (r) { > case -1: > if (error) > diff --git a/generator/states.c b/gen...
2019 Jul 25
4
[PATCH libnbd v3 0/2] lib: Implement closure lifetimes.
I think I've addressed everything that was raised in review. Some of the highlights: - Callbacks should be freed reliably along all exit paths. - There's a simple test of closure lifetimes. - I've tried to use VALID|FREE in all the places where I'm confident that it's safe and correct to do. There may be more places. Note this is an optimization and shouldn't
2019 Jul 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...ly can still do VALID|FREE at once). But if we do that... > if (cmd->error == 0) > diff --git a/generator/states-reply.c b/generator/states-reply.c > index 1a0c149..b11479c 100644 > --- a/generator/states-reply.c > +++ b/generator/states-reply.c > @@ -184,7 +184,8 @@ save_reply_state (struct nbd_handle *h) > if (cmd->cb.callback) { > int error = cmd->error; > > - if (cmd->cb.callback (cmd->cb.user_data, cookie, &error) == -1 && error) > + if (cmd->cb.callback (LIBNBD_CALLBACK_VALID, > + cmd-&g...
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...&h->bs_entries[1], (length-4) / 4, &error) == -1) if (cmd->error == 0) diff --git a/generator/states-reply.c b/generator/states-reply.c index 6ea43d5..8f62923 100644 --- a/generator/states-reply.c +++ b/generator/states-reply.c @@ -170,9 +170,13 @@ save_reply_state (struct nbd_handle *h) /* Notify the user */ if (cmd->cb.callback) { int error = cmd->error; + int r; assert (cmd->type != NBD_CMD_DISC); - switch (cmd->cb.callback (cmd->cb.user_data, cookie, &error)) { + r = cmd->cb.callback (LIBNBD_CALLBACK_VALID|...