search for: bs_entri

Displaying 20 results from an estimated 45 matches for "bs_entri".

Did you mean: bs_entries
2019 Jun 04
0
[libnbd PATCH 2/2] api: Recover from block status callback failure
...vailable. The C<metacontext> parameter is a string diff --git a/generator/states-reply-structured.c b/generator/states-reply-structured.c index c7ba892..5791360 100644 --- a/generator/states-reply-structured.c +++ b/generator/states-reply-structured.c @@ -357,34 +357,37 @@ assert (h->bs_entries); assert (length >= 12); - /* Need to byte-swap the entries returned, but apart from that we - * don't validate them. - */ - for (i = 0; i < length/4; ++i) - h->bs_entries[i] = be32toh (h->bs_entries[i]); - - /* Look up the context ID. */ - context_i...
2023 Aug 04
2
[libnbd PATCH v4 01/25] block_status: Add some sanity checking of server lengths
...anged, 58 insertions(+), 20 deletions(-) > > 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_...
2019 Jun 27
1
[libnbd PATCH] block-status: Make callback usage consistent with pread_structured
...ret = RInt64; permitted_states = [ Connected ]; diff --git a/generator/states-reply-structured.c b/generator/states-reply-structured.c index fa11dd6..91c6215 100644 --- a/generator/states-reply-structured.c +++ b/generator/states-reply-structured.c @@ -478,37 +478,33 @@ assert (h->bs_entries); assert (length >= 12); - if (cmd->error) + /* Need to byte-swap the entries returned, but apart from that we + * don't validate them. + */ + for (i = 0; i < length/4; ++i) + h->bs_entries[i] = be32toh (h->bs_entries[i]); + + /* Look up the conte...
2019 Jun 04
3
[libnbd PATCH 0/2] Better handling of failed block_status callback
Rather than moving the connection to DEAD, we can just ignore further contexts to the existing command handle, and fail the overall command with the same errno as the failed callback. Eric Blake (2): states: Track cmd->error as errno, not wire value api: Recover from block status callback failure generator/generator | 5 ++- generator/states-reply-simple.c | 2 +-
2019 Jun 18
0
[libnbd PATCH 4/8] states: Prepare for read callback
...(0, "not expecting NBD_REPLY_TYPE_BLOCK_STATUS here"); return -1; @@ -375,7 +375,7 @@ length = be32toh (h->sbuf.sr.structured_reply.length); assert (cmd); /* guaranteed by CHECK */ - assert (cmd->extent_fn); + assert (cmd->cb.fn.extent); assert (h->bs_entries); assert (length >= 12); @@ -401,8 +401,8 @@ if (meta_context) { /* Call the caller's extent function. */ errno = 0; - if (cmd->extent_fn (cmd->data, meta_context->name, cmd->offset, - &h->bs_entries[1], (l...
2019 Jun 04
1
Re: [PATCH libnbd v2 2/4] generator: Callback returns int instead of void.
...d == meta_context->context_id) > break; > > - if (meta_context) > + if (meta_context) { > /* Call the caller's extent function. */ > - cmd->extent_fn (cmd->data, meta_context->name, cmd->offset, > - &h->bs_entries[1], (length-4) / 4); > + if (cmd->extent_fn (cmd->data, meta_context->name, cmd->offset, > + &h->bs_entries[1], (length-4) / 4) == -1) { > + SET_NEXT_STATE (%.DEAD); /* XXX We should be able to recover. */ > + if (errno ==...
2019 Jul 25
4
Re: [PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...error = cmd->error; > > - if (cmd->cb.fn.extent (cmd->cb.fn_user_data, > + if (cmd->cb.fn.extent (LIBNBD_CALLBACK_VALID, cmd->cb.fn_user_data, > meta_context->name, cmd->offset, > &h->bs_entries[1], (length-4) / 4, &error) == -1) > if (cmd->error == 0) Hmm - no change to the FINISH state, which means you are relying on command retirement to free chunk/extent instead. As long as that happens, we should be okay, though. > diff --git a/generator/states-reply.c b/gen...
2019 Aug 13
0
[PATCH libnbd 4/4] lib: Add CALL_CALLBACK macro.
...error = cmd->error; uint16_t flags = be16toh (h->sbuf.sr.structured_reply.flags); - if (cmd->cb.fn.extent.callback (cmd->cb.fn.extent.user_data, - meta_context->name, cmd->offset, - &h->bs_entries[1], (length-4) / 4, - &error) == -1) + if (CALL_CALLBACK (cmd->cb.fn.extent, + meta_context->name, cmd->offset, + &h->bs_entries[1], (length-4) / 4, + &error)...
2019 Aug 12
0
[PATCH libnbd 4/7] lib: Allow closure user_data to be associated with a free callback.
...D_CALLBACK_FREE) { cmd->cb.fn.chunk = NULL; /* because we've freed it */ + nbd_internal_free_callback (h, cmd->cb.fn_user_data); + } } SET_NEXT_STATE(%FINISH); @@ -527,8 +533,10 @@ valid_flags (struct nbd_handle *h) &h->bs_entries[1], (length-4) / 4, &error) == -1) if (cmd->error == 0) cmd->error = error ? error : EPROTO; - if (valid & LIBNBD_CALLBACK_FREE) + if (valid & LIBNBD_CALLBACK_FREE) { cmd->cb.fn.extent = NULL; /* because we've freed it */ + nb...
2019 May 23
2
[PATCH libnbd] api: Get rid of nbd_connection.
This isn't quite finished because not all of the tests or examples have been updated, but it demonstrates an idea: Should we forget about the concept of having multiple connections managed under a single handle? In this patch there is a single ‘struct nbd_handle *’ which manages a single state machine and connection (and therefore no nbd_connection). To connect to a multi-conn server you must
2019 Jun 04
0
[PATCH libnbd v2 2/4] generator: Callback returns int instead of void.
...,10 +369,16 @@ if (context_id == meta_context->context_id) break; - if (meta_context) + if (meta_context) { /* Call the caller's extent function. */ - cmd->extent_fn (cmd->data, meta_context->name, cmd->offset, - &h->bs_entries[1], (length-4) / 4); + if (cmd->extent_fn (cmd->data, meta_context->name, cmd->offset, + &h->bs_entries[1], (length-4) / 4) == -1) { + SET_NEXT_STATE (%.DEAD); /* XXX We should be able to recover. */ + if (errno == 0) errno = EPROTO;...
2019 Jul 25
0
Re: [PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...or; >> >> - if (cmd->cb.fn.extent (cmd->cb.fn_user_data, >> + if (cmd->cb.fn.extent (LIBNBD_CALLBACK_VALID, cmd->cb.fn_user_data, >> meta_context->name, cmd->offset, >> &h->bs_entries[1], (length-4) / 4, &error) == -1) >> if (cmd->error == 0) > > Hmm - no change to the FINISH state, which means you are relying on > command retirement to free chunk/extent instead. As long as that > happens, we should be okay, though. Another thought: if a us...
2019 Jul 25
0
Re: [PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...gt; > > > - if (cmd->cb.fn.extent (cmd->cb.fn_user_data, > > + if (cmd->cb.fn.extent (LIBNBD_CALLBACK_VALID, cmd->cb.fn_user_data, > > meta_context->name, cmd->offset, > > &h->bs_entries[1], (length-4) / 4, &error) == -1) > > if (cmd->error == 0) > > Hmm - no change to the FINISH state, which means you are relying on > command retirement to free chunk/extent instead. As long as that > happens, we should be okay, though. I didn't understand...
2019 Aug 13
0
[PATCH libnbd v2 3/3] api: Add nbd_clear_debug_callback.
...113,9 +113,7 @@ nbd_close (struct nbd_handle *h) return; /* Free user callbacks first. */ - if (h->debug_callback) - h->debug_callback (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); - h->debug_callback = NULL; + nbd_unlocked_clear_debug_callback (h); free (h->bs_entries); for (m = h->meta_contexts; m != NULL; m = m_next) { -- 2.22.0
2019 Jul 25
0
[libnbd PATCH] lib: Reduce number of read/block_status callbacks
...; + unsigned valid = valid_flags (h); - if (cmd->cb.fn.extent (LIBNBD_CALLBACK_VALID, cmd->cb.fn_user_data, + if (cmd->cb.fn.extent (valid, cmd->cb.fn_user_data, meta_context->name, cmd->offset, &h->bs_entries[1], (length-4) / 4, &error) == -1) if (cmd->error == 0) cmd->error = error ? error : EPROTO; + if (valid & LIBNBD_CALLBACK_FREE) + cmd->cb.fn.extent = NULL; /* because we've freed it */ } else /* Emit a debug message, but ignor...
2019 Jul 25
0
[PATCH libnbd v3 2/2] lib: Remove nbd_add_close_callback.
...@@ nbd_close (struct nbd_handle *h) if (h->debug_fn) h->debug_fn (LIBNBD_CALLBACK_FREE, h->debug_data, NULL, NULL); - for (cc = h->close_callbacks; cc != NULL; cc = cc_next) { - cc_next = cc->next; - cc->cb (cc->user_data); - free (cc); - } - free (h->bs_entries); for (m = h->meta_contexts; m != NULL; m = m_next) { m_next = m->next; @@ -202,34 +195,6 @@ nbd_unlocked_add_meta_context (struct nbd_handle *h, const char *name) return 0; } -/* This is not generated because we don't want to offer it to other - * programming languages. -...
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.
...t;error; if (CALL_CALLBACK (cmd->cb.fn.chunk, @@ -479,7 +480,7 @@ assert (cmd); /* guaranteed by CHECK */ assert (cmd->type == NBD_CMD_BLOCK_STATUS); - assert (cmd->cb.fn.extent.callback); + 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;...
2019 Jun 18
0
[libnbd PATCH 2/8] states: Consolidate search for current reply's command
...s in flight. */ - for (cmd = h->cmds_in_flight; cmd != NULL; cmd = cmd->next) { - if (cmd->handle == handle) - break; - } assert (cmd); /* guaranteed by CHECK */ if (cmd->type != NBD_CMD_READ) { @@ -394,8 +361,7 @@ return 0; REPLY.STRUCTURED_REPLY.RECV_BS_ENTRIES: - struct command_in_flight *cmd; - uint64_t handle; + struct command_in_flight *cmd = h->reply_cmd; uint32_t length; size_t i; uint32_t context_id; @@ -404,16 +370,9 @@ switch (recv_into_rbuf (h)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; case 0: - handle = be64to...
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 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...it */ } SET_NEXT_STATE(%FINISH); @@ -499,7 +500,7 @@ valid_flags (struct nbd_handle *h) assert (cmd); /* guaranteed by CHECK */ assert (cmd->type == NBD_CMD_BLOCK_STATUS); - assert (cmd->cb.fn.extent); + assert (cmd->cb.fn.extent.callback); assert (h->bs_entries); assert (length >= 12); @@ -522,13 +523,14 @@ valid_flags (struct nbd_handle *h) int error = cmd->error; unsigned valid = valid_flags (h); - if (cmd->cb.fn.extent (valid, cmd->cb.fn_user_data, - meta_context->name, cmd->of...