search for: nbd_connect

Displaying 20 results from an estimated 34 matches for "nbd_connect".

2019 May 22
0
[libnbd PATCH v3 1/7] lib: Refactor command_common() to do more common work
...-------------- 3 files changed, 39 insertions(+), 91 deletions(-) diff --git a/lib/disconnect.c b/lib/disconnect.c index bc43b4c..9706835 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -60,27 +60,17 @@ nbd_unlocked_shutdown (struct nbd_handle *h) int nbd_unlocked_aio_disconnect (struct nbd_connection *conn) { - struct command_in_flight *cmd; + int64_t id; - cmd = malloc (sizeof *cmd); - if (cmd == NULL) { - set_error (errno, "malloc"); + id = nbd_internal_command_common (conn, 0, NBD_CMD_DISC, 0, 0, NULL, + 0, NULL); + if (id == -1)...
2019 May 22
0
[libnbd PATCH v2 1/5] lib: Refactor state event into command_common
...ternal.h | 6 ++++++ lib/rw.c | 19 +++---------------- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/lib/disconnect.c b/lib/disconnect.c index bc43b4c..26d7298 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -62,25 +62,14 @@ nbd_unlocked_aio_disconnect (struct nbd_connection *conn) { struct command_in_flight *cmd; - cmd = malloc (sizeof *cmd); - if (cmd == NULL) { - set_error (errno, "malloc"); + cmd = command_common (conn, 0, NBD_CMD_DISC, 0, 0, NULL); + if (cmd == NULL) return -1; - } - cmd->flags = 0; - cmd->type = NBD_CMD_DISC...
2019 May 23
2
[PATCH libnbd] api: Get rid of nbd_connection.
...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 do something like: - Connect once, check if the server supports multi-conn. - If it does, either disconnect and connect mulitple times "for real", or else open further handles as required. An example of use of the new API can be foun...
2019 May 22
12
[libnbd PATCH v3 0/7] Avoid deadlock with in-flight commands
Since v2: - rebase to Rich's new API calls - more refactoring in patch 1 (retitled) - new patches 3 and 4 - fix data corruption in patch 6 (was 4) - more tweaks to the reproducer example (including using new API from 3) Eric Blake (7): lib: Refactor command_common() to do more common work commands: Allow for a command queue commands: Expose FIFO ordering of server completions
2019 May 22
10
[libnbd PATCH v2 0/5] Avoid deadlock with in-flight commands
On v1, we discussed whether cmds_to_issue needed to be a list, since it never had more than one element. I played with the idea of making it a list, and allowing the client to queue up new commands regardless of whether the state machine is currently in READY. I also polished up the tmp demo into a bit more full-fledged example file, worth including since it also let me discover a hard-to-hit race
2019 May 22
0
[libnbd PATCH v2 2/5] commands: Allow for a command queue
...ernal.h | 3 +++ lib/rw.c | 24 ++++++++++++++++++++---- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/generator/states.c b/generator/states.c index 202c305..a4eecbd 100644 --- a/generator/states.c +++ b/generator/states.c @@ -110,6 +110,12 @@ send_from_wbuf (struct nbd_connection *conn) /*----- End of prologue. -----*/ /* STATE MACHINE */ { + READY: + conn->reached_ready = true; + if (conn->cmds_to_issue) + SET_NEXT_STATE (%ISSUE_COMMAND.START); + return 0; + DEAD: if (conn->sock) { conn->sock->ops->close (conn->sock); diff --git a...
2019 May 22
8
[PATCH libnbd v2 0/6] Test connection states.
Patch 1/6 was posted before and I didn't change it: https://www.redhat.com/archives/libguestfs/2019-May/thread.html#00134 That doesn't necessarily mean I shouldn't change it, I'm posting it again because the other patches depend on it. The main change in this series is we add three new API functions: nbd_aio_is_created - connection has just been created
2019 May 22
0
[libnbd PATCH v3 2/7] commands: Allow for a command queue
...c | 5 +++++ lib/rw.c | 32 +++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/generator/states.c b/generator/states.c index 202c305..22ce853 100644 --- a/generator/states.c +++ b/generator/states.c @@ -110,6 +110,11 @@ send_from_wbuf (struct nbd_connection *conn) /*----- End of prologue. -----*/ /* STATE MACHINE */ { + READY: + if (conn->cmds_to_issue) + SET_NEXT_STATE (%ISSUE_COMMAND.START); + return 0; + DEAD: if (conn->sock) { conn->sock->ops->close (conn->sock); diff --git a/lib/rw.c b/lib/rw.c index 8f6227d...
2019 May 21
0
[libnbd PATCH 1/3] commands: Preserve FIFO ordering
...>next) + prev_cmd = prev_cmd->next; + prev_cmd->next = cmd; + } + else + conn->cmds_done = cmd; SET_NEXT_STATE (%.READY); return 0; diff --git a/lib/rw.c b/lib/rw.c index 9dfce97..fa7dc52 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -246,7 +246,7 @@ command_common (struct nbd_connection *conn, uint16_t flags, uint16_t type, uint64_t offset, uint64_t count, void *data) { - struct command_in_flight *cmd; + struct command_in_flight *cmd, *prev_cmd; switch (type) { /* Commands which send or receive data are limited to MAX_REQUEST_SIZE....
2019 May 22
0
[libnbd PATCH v3 3/7] commands: Expose FIFO ordering of server completions
...= prev_cmd->next; + prev_cmd->next = cmd; + } + else + conn->cmds_done = cmd; SET_NEXT_STATE (%.READY); return 0; diff --git a/lib/aio.c b/lib/aio.c index c7764f8..105651f 100644 --- a/lib/aio.c +++ b/lib/aio.c @@ -158,3 +158,16 @@ nbd_unlocked_aio_command_completed (struct nbd_connection *conn, nbd_internal_name_of_nbd_cmd (type), strerror (error)); return -1; } + +int64_t +nbd_unlocked_aio_peek_command_completed (struct nbd_connection *conn) +{ + if (conn->cmds_done != NULL) + return conn->cmds_done->handle; + + if (conn->cmds_in_flight != NUL...
2020 Jul 20
2
Re: [PATCH libnbd PROPOSAL] Add APIs for listing exports from an NBD server.
...ol type. > + > + /* Connect to the NBD server over a > + * Unix domain socket. A side effect of > + * connecting is to list the exports. > + * This operation can fail normally, so > + * we need to check the return value and > + * error code. > + */ > + r = nbd_connect_unix (nbd, argv[1]); > + if (r == -1 && nbd_get_errno () == ENOTSUP) { > + fprintf (stderr, "%s\n", nbd_get_error ()); > + exit (EXIT_FAILURE); > + } > + > + if (nbd_get_nr_list_exports (nbd) == 0) { > + fprintf (stderr, "Server does not suppo...
2019 May 22
1
Re: [libnbd PATCH v2 2/5] commands: Allow for a command queue
...nlocked_aio_is_processing (conn)) { // can't call nbd_internal_run because we're in the // wrong state, but we can enqueue the command and it // will be processed next time we get to READY } else { // this is an error } > @@ -296,9 +297,24 @@ command_common (struct nbd_connection *conn, > if (conn->structured_replies && cmd->data && type == NBD_CMD_READ) > memset (cmd->data, 0, cmd->count); > > - cmd->next = conn->cmds_to_issue; > - conn->cmds_to_issue = cmd; > - if (nbd_internal_run (conn->h, conn, cm...
2019 May 21
9
[libnbd PATCH 0/3] Avoid deadlock with in-flight commands
This might not be the final solution, but it certainly seems to solve a deadlock for me that I could trigger by using 'nbdkit --filter=noparallel memory 512k' and calling nbd_aio_pread for a request larger than 256k (enough for the Linux kernel to block the server until libnbd read()s), immediately followed by nbd_aio_pwrite for a request larger than 256k (enough to block libnbd until the
2019 May 23
0
[PATCH libnbd 2/3] states: Prevent multi-conn connection unless the server advertizes it.
...nnection +will fail. Instead you should connect with multi-conn +set to C<1> (the default), check this setting, then if +multi-conn is found to be supported you can call +C<nbd_set_multi_conn> with a larger value to increase +the number of connection objects, then call one of the +C<nbd_connect*> functions again on the handle to connect +the remaining connections."; }; "can_cache", { diff --git a/lib/flags.c b/lib/flags.c index 825b326..1956db6 100644 --- a/lib/flags.c +++ b/lib/flags.c @@ -42,6 +42,16 @@ nbd_internal_set_size_and_flags (struct nbd_handle *h,...
2019 May 23
5
[PATCH libnbd 0/3] Prevent some misuse of multi-conn.
Per recent discussion here: https://www.redhat.com/archives/libguestfs/2019-May/thread.html#00175
2019 Oct 04
4
[PATCH libnbd 1/4] generator: Allow long ‘name - shortdesc’ in man pages.
For commands with long names and/or short descriptors, you can end up going over 72 characters in the first line of the man page (causing podwrapper to complain). Wrap these lines. --- generator/generator | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/generator/generator b/generator/generator index 7d3f656..ad1cb6b 100755 --- a/generator/generator +++ b/generator/generator
2019 May 21
0
[libnbd PATCH 3/3] states: Allow in-flight read while writing next command
...+ if (conn->cmds_to_issue) + SET_NEXT_STATE (%^ISSUE_COMMAND.START); + else + SET_NEXT_STATE (%.READY); return 0; } /* END STATE MACHINE */ diff --git a/lib/internal.h b/lib/internal.h index 3f2b729..466af9d 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -182,6 +182,7 @@ struct nbd_connection { * acknowledge them. */ struct command_in_flight *cmds_to_issue, *cmds_in_flight, *cmds_done; + bool in_write_payload; }; struct meta_context { -- 2.20.1
2019 May 22
0
[libnbd PATCH v2 4/5] states: Allow in-flight read while writing next command
...t *cmd; + assert (!conn->wlen); assert (conn->cmds_to_issue != NULL); cmd = conn->cmds_to_issue; conn->cmds_to_issue = cmd->next; diff --git a/lib/internal.h b/lib/internal.h index 2d6ad9d..91c056c 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -185,6 +185,7 @@ struct nbd_connection { * acknowledge them. */ struct command_in_flight *cmds_to_issue, *cmds_in_flight, *cmds_done; + bool in_write_payload; }; struct meta_context { -- 2.20.1
2019 Sep 17
0
[PATCH libnbd 5/5] interop: Add tests of nbdkit + LIBNBD_TLS_ALLOW.
...d-tls-certs diff --git a/TODO b/TODO index 21feb2f..642d39f 100644 --- a/TODO +++ b/TODO @@ -17,9 +17,6 @@ NBD_INFO_BLOCK_SIZE. TLS should properly shut down the session (calling gnutls_bye). -LIBNBD_TLS_ALLOW is not tested. Related to this, -nbd_get_tls_negotiated is not tested. - Implement nbd_connect + systemd socket activation. Improve function trace output so that: diff --git a/interop/Makefile.am b/interop/Makefile.am index 8a5b787..43350a8 100644 --- a/interop/Makefile.am +++ b/interop/Makefile.am @@ -145,17 +145,25 @@ if HAVE_GNUTLS if HAVE_CERTTOOL check_PROGRAMS += \ interop-nbdki...
2020 Aug 14
0
[libnbd PATCH v2 11/13] api: Add nbd_aio_opt_list
..., *desc; + int i; + const char *name; int64_t size; + struct export_list list = { 0 }; if (argc != 2) { fprintf (stderr, "%s socket\n", argv[0]); @@ -63,8 +97,7 @@ main (int argc, char *argv[]) * end up in option mode, then a * listing is not possible. */ - r = nbd_connect_unix (nbd, argv[1]); - if (r == -1) { + if (nbd_connect_unix (nbd, argv[1]) == -1) { fprintf (stderr, "%s\n", nbd_get_error ()); exit (EXIT_FAILURE); } @@ -74,24 +107,16 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } - /* Grab the export list. */ - if (n...