search for: nbd_internal_socket_create

Displaying 18 results from an estimated 18 matches for "nbd_internal_socket_create".

2023 Mar 23
1
[libnbd PATCH v3 14/19] CONNECT_COMMAND.START: plug child process leak on error
...mage we execute in the child handle that signal properly, etc). Instead, rearrange the steps in the CONNECT_COMMAND.START handler so that fork() be the last operation in the parent process, on the construction path. If fork() succeeds, let the entire handler succeed. For this, move the fcntl() and nbd_internal_socket_create() calls above fork(). (The hoisting of the fcntl() calls is where we rely on the earlier observation that O_NONBLOCK only applies to the parent-side end of the socket pair, so it is safe to do before forking.) The trouble in turn is that nbd_internal_socket_create() takes ownership of the parent-...
2023 Mar 23
20
[libnbd PATCH v3 00/19] pass LISTEN_FDNAMES with systemd socket activation
V3 was here: <http://mid.mail-archive.com/20230215141158.2426855-1-lersek at redhat.com>. See the Notes section on each patch for the v4 updates. The series is nearly ready for merging: every patch has at least one R-b tag, except "socket activation: avoid manipulating the sign bit". The series builds, and passes "make check" and "make check-valgrind", at
2019 Jun 18
0
[libnbd PATCH 4/8] states: Prepare for read callback
...uint16_t flags, uint16_t type, uint64_t offset, uint64_t count, - void *data, extent_fn extent); + void *data, struct command_cb *cb); /* socket.c */ struct socket *nbd_internal_socket_create (int fd); diff --git a/lib/rw.c b/lib/rw.c index ad9c8a0..dc81c57 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -143,7 +143,7 @@ int64_t nbd_internal_command_common (struct nbd_handle *h, uint16_t flags, uint16_t type, uint64_t offset, uint64_t...
2019 May 22
0
[libnbd PATCH v2 1/5] lib: Refactor state event into command_common
...d_common (struct nbd_connection *conn, + uint16_t flags, uint16_t type, + uint64_t offset, + uint64_t count, void *data); + /* socket.c */ struct socket *nbd_internal_socket_create (int fd); diff --git a/lib/rw.c b/lib/rw.c index 9dfce97..a7587e9 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -241,7 +241,7 @@ nbd_unlocked_block_status (struct nbd_handle *h, return r == -1 ? -1 : 0; } -static struct command_in_flight * +struct command_in_flight * command_common (struct nbd_con...
2019 May 25
2
[PATCH libnbd] states: connect_command: Don't set O_NONBLOCK on socket passed to child.
...nly in the parent, + * because the child may not be expecting a non-blocking socket. + */ + flags = fcntl (sv[0], F_GETFL, 0); + if (flags == -1 || + fcntl (sv[0], F_SETFL, flags|O_NONBLOCK) == -1) { + SET_NEXT_STATE (%.DEAD); + close (sv[0]); + return -1; + } + h->sock = nbd_internal_socket_create (sv[0]); if (!h->sock) { SET_NEXT_STATE (%.DEAD); + close (sv[0]); return -1; } - close (sv[1]); /* The sockets are connected already, we can jump directly to * receiving the server magic. -- 2.21.0
2019 Jun 29
0
[libnbd PATCH 2/6] generator: Allow DEAD state actions to run
...tes-connect.c index c6a4ae7..9e2e1d4 100644 --- a/generator/states-connect.c +++ b/generator/states-connect.c @@ -55,12 +55,12 @@ disable_nagle (int sock) if (fd == -1) { SET_NEXT_STATE (%.DEAD); set_error (errno, "socket"); - return -1; + return 0; } h->sock = nbd_internal_socket_create (fd); if (!h->sock) { SET_NEXT_STATE (%.DEAD); - return -1; + return 0; } disable_nagle (fd); @@ -70,7 +70,7 @@ disable_nagle (int sock) if (errno != EINPROGRESS) { SET_NEXT_STATE (%.DEAD); set_error (errno, "connect"); - return -1; + r...
2020 Sep 11
0
[libnbd PATCH v2 5/5] api: Add STRICT_BOUNDS/ZERO_SIZE to nbd_set_strict_mode
...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 --- a/generator/API.ml +++ b/generator/API.ml @@ -189,6 +189,8 @@ let strict_flags = { flags = [ "COMMANDS", 1 lsl 0; "FLAGS", 1 lsl 1; + "BOUNDS",...
2019 May 22
0
[libnbd PATCH v3 1/7] lib: Refactor command_common() to do more common work
...uint16_t flags, uint16_t type, + uint64_t offset, uint64_t count, + void *data, int64_t id, + extent_fn extent); + /* socket.c */ struct socket *nbd_internal_socket_create (int fd); diff --git a/lib/rw.c b/lib/rw.c index 861ab67..8f6227d 100644 --- a/lib/rw.c +++ b/lib/rw.c @@ -241,10 +241,11 @@ nbd_unlocked_block_status (struct nbd_handle *h, return r == -1 ? -1 : 0; } -static struct command_in_flight * -command_common (struct nbd_connection *conn, -...
2019 Oct 04
0
[PATCH libnbd 3/4] api: Add nbd_connect_socket.
...l: set O_NONBLOCK"); + close (sock); + return -1; + } + + flags = fcntl (sock, F_GETFD, 0); + if (flags == -1 || + fcntl (sock, F_SETFD, flags|FD_CLOEXEC) == -1) { + set_error (errno, "fcntl: set FD_CLOEXEC"); + close (sock); + return -1; + } + + h->sock = nbd_internal_socket_create (sock); + if (!h->sock) { + close (sock); + return -1; + } + + /* This jumps straight to %MAGIC.START (to start the handshake) + * because the socket is already connected. + */ + return nbd_internal_run (h, cmd_connect_socket); +} + int nbd_unlocked_aio_connect_command (struct nb...
2020 Sep 11
3
[libnbd PATCH] api: Add LIBNBD_SHUTDOWN_IMMEDIATE flag
..., 221 insertions(+), 11 deletions(-) create mode 100644 tests/shutdown-flags.c diff --git a/lib/internal.h b/lib/internal.h index b2637bd..96699b5 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -435,6 +435,8 @@ extern int64_t nbd_internal_command_common (struct nbd_handle *h, struct socket *nbd_internal_socket_create (int fd); /* states.c */ +extern void nbd_internal_abort_commands (struct nbd_handle *h, + struct command **list); extern int nbd_internal_run (struct nbd_handle *h, enum external_event ev); extern const char *nbd_internal_state_short_string (enum state s...
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
2020 Sep 17
0
Re: [libnbd PATCH] api: Add LIBNBD_SHUTDOWN_IMMEDIATE flag
...; create mode 100644 tests/shutdown-flags.c > > diff --git a/lib/internal.h b/lib/internal.h > index b2637bd..96699b5 100644 > --- a/lib/internal.h > +++ b/lib/internal.h > @@ -435,6 +435,8 @@ extern int64_t nbd_internal_command_common (struct nbd_handle *h, > struct socket *nbd_internal_socket_create (int fd); > > /* states.c */ > +extern void nbd_internal_abort_commands (struct nbd_handle *h, > + struct command **list); > extern int nbd_internal_run (struct nbd_handle *h, enum external_event ev); > extern const char *nbd_internal_st...
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 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 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 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 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
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