search for: nbd_unlocked_shutdown

Displaying 20 results from an estimated 20 matches for "nbd_unlocked_shutdown".

2019 Jun 28
1
[libnbd PATCH] disconnect: Prevent any further commands
....c | 6 ++++-- lib/internal.h | 2 ++ lib/rw.c | 5 +++++ tests/errors.c | 9 ++++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/disconnect.c b/lib/disconnect.c index 95e9a37..53de386 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -29,8 +29,9 @@ int nbd_unlocked_shutdown (struct nbd_handle *h) { - if (nbd_internal_is_state_ready (get_next_state (h)) || - nbd_internal_is_state_processing (get_next_state (h))) { + if (!h->disconnect_request && + (nbd_internal_is_state_ready (get_next_state (h)) || + nbd_internal_is_state_processing (get_...
2019 May 22
0
[libnbd PATCH v3 4/7] disconnect: Allow shutdown during processing
...on, even if it is still up to receive replies to previous in-flight commands. --- lib/disconnect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/disconnect.c b/lib/disconnect.c index 9706835..0b8fea0 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -31,7 +31,8 @@ nbd_unlocked_shutdown (struct nbd_handle *h) size_t i; for (i = 0; i < h->multi_conn; ++i) { - if (nbd_unlocked_aio_is_ready (h->conns[i])) { + if (nbd_unlocked_aio_is_ready (h->conns[i]) || + nbd_unlocked_aio_is_processing (h->conns[i])) { if (nbd_unlocked_aio_disconnect (h-&gt...
2019 Jun 05
9
[PATCH libnbd 0/4] lib: Atomically update h->state.
I need to think about this patch series a bit more, but it does at least pass the tests. Rich.
2019 Jun 05
1
Re: [PATCH libnbd 2/4] lib: Split nbd_aio_is_* functions into internal.
...return -1; > } > > - if (nbd_unlocked_aio_is_dead (h)) > + if (nbd_internal_is_state_dead (h->state)) error_unless_ready() is called while lock is held, so multiple reads of h->state are fine here. > +++ b/lib/disconnect.c > @@ -29,15 +29,14 @@ > int > nbd_unlocked_shutdown (struct nbd_handle *h) > { > - > - if (nbd_unlocked_aio_is_ready (h) || > - nbd_unlocked_aio_is_processing (h)) { > + if (nbd_internal_is_state_ready (h->state) || > + nbd_internal_is_state_processing (h->state)) { Likewise safe for multiple h->state reads....
2019 Jun 05
0
[PATCH libnbd 3/4] lib: Add set_state / get_state macros.
...ting (h->state)) { + while (nbd_internal_is_state_connecting (get_state (h))) { if (nbd_unlocked_poll (h, -1) == -1) return -1; } diff --git a/lib/disconnect.c b/lib/disconnect.c index 355a1c9..423edaf 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -29,14 +29,14 @@ int nbd_unlocked_shutdown (struct nbd_handle *h) { - if (nbd_internal_is_state_ready (h->state) || - nbd_internal_is_state_processing (h->state)) { + if (nbd_internal_is_state_ready (get_state (h)) || + nbd_internal_is_state_processing (get_state (h))) { if (nbd_unlocked_aio_disconnect (h, 0) == -1)...
2019 Jun 05
0
[PATCH libnbd 2/4] lib: Split nbd_aio_is_* functions into internal.
...io_is_connecting (h)) { + while (nbd_internal_is_state_connecting (h->state)) { if (nbd_unlocked_poll (h, -1) == -1) return -1; } diff --git a/lib/disconnect.c b/lib/disconnect.c index 6695e59..355a1c9 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -29,15 +29,14 @@ int nbd_unlocked_shutdown (struct nbd_handle *h) { - - if (nbd_unlocked_aio_is_ready (h) || - nbd_unlocked_aio_is_processing (h)) { + if (nbd_internal_is_state_ready (h->state) || + nbd_internal_is_state_processing (h->state)) { if (nbd_unlocked_aio_disconnect (h, 0) == -1) return -1; } -...
2019 Jun 05
0
[PATCH libnbd 4/4] lib: Atomically update h->state when leaving the locked region.
...et_state (h))) { + while (nbd_internal_is_state_connecting (get_next_state (h))) { if (nbd_unlocked_poll (h, -1) == -1) return -1; } diff --git a/lib/disconnect.c b/lib/disconnect.c index 423edaf..95e9a37 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -29,14 +29,14 @@ int nbd_unlocked_shutdown (struct nbd_handle *h) { - if (nbd_internal_is_state_ready (get_state (h)) || - nbd_internal_is_state_processing (get_state (h))) { + if (nbd_internal_is_state_ready (get_next_state (h)) || + nbd_internal_is_state_processing (get_next_state (h))) { if (nbd_unlocked_aio_disconnect...
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
0
[libnbd PATCH v3 1/7] lib: Refactor command_common() to do more common work
...lib/internal.h | 7 ++++ lib/rw.c | 103 +++++++++++++---------------------------------- 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,...
2020 Sep 11
3
[libnbd PATCH] api: Add LIBNBD_SHUTDOWN_IMMEDIATE flag
...k); diff --git a/lib/disconnect.c b/lib/disconnect.c index dcb95d8..b8356b7 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -23,17 +23,31 @@ #include <stdbool.h> #include <errno.h> #include <inttypes.h> +#include <assert.h> #include "internal.h" int nbd_unlocked_shutdown (struct nbd_handle *h, uint32_t flags) { - if (flags != 0) { + if ((flags & ~LIBNBD_SHUTDOWN_IMMEDIATE) != 0) { set_error (EINVAL, "invalid flag: %" PRIu32, flags); return -1; } + /* If IMMEDIATE, abort any commands that have not yet had any bytes + * sent to the s...
2019 Jun 08
0
[PATCH libnbd v3] lib: Atomically update h->state when leaving the locked region.
...et_state (h))) { + while (nbd_internal_is_state_connecting (get_next_state (h))) { if (nbd_unlocked_poll (h, -1) == -1) return -1; } diff --git a/lib/disconnect.c b/lib/disconnect.c index 423edaf..95e9a37 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -29,14 +29,14 @@ int nbd_unlocked_shutdown (struct nbd_handle *h) { - if (nbd_internal_is_state_ready (get_state (h)) || - nbd_internal_is_state_processing (get_state (h))) { + if (nbd_internal_is_state_ready (get_next_state (h)) || + nbd_internal_is_state_processing (get_next_state (h))) { if (nbd_unlocked_aio_disconnect...
2020 Sep 17
0
Re: [libnbd PATCH] api: Add LIBNBD_SHUTDOWN_IMMEDIATE flag
...cb95d8..b8356b7 100644 > --- a/lib/disconnect.c > +++ b/lib/disconnect.c > @@ -23,17 +23,31 @@ > #include <stdbool.h> > #include <errno.h> > #include <inttypes.h> > +#include <assert.h> > > #include "internal.h" > > int > nbd_unlocked_shutdown (struct nbd_handle *h, uint32_t flags) > { > - if (flags != 0) { > + if ((flags & ~LIBNBD_SHUTDOWN_IMMEDIATE) != 0) { > set_error (EINVAL, "invalid flag: %" PRIu32, flags); > return -1; > } > > + /* If IMMEDIATE, abort any commands that have n...
2019 Jun 05
1
[PATCH libnbd v2] lib: Atomically update h->state when leaving the locked region.
...et_state (h))) { + while (nbd_internal_is_state_connecting (get_next_state (h))) { if (nbd_unlocked_poll (h, -1) == -1) return -1; } diff --git a/lib/disconnect.c b/lib/disconnect.c index 423edaf..95e9a37 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -29,14 +29,14 @@ int nbd_unlocked_shutdown (struct nbd_handle *h) { - if (nbd_internal_is_state_ready (get_state (h)) || - nbd_internal_is_state_processing (get_state (h))) { + if (nbd_internal_is_state_ready (get_next_state (h)) || + nbd_internal_is_state_processing (get_next_state (h))) { if (nbd_unlocked_aio_disconnect...
2020 Sep 04
0
[libnbd PATCH 1/2] api: Add nbd_set_strict_mode
...nnect.c @@ -1,5 +1,5 @@ /* NBD client library in userspace - * Copyright (C) 2013-2019 Red Hat Inc. + * Copyright (C) 2013-2020 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -29,9 +29,11 @@ int nbd_unlocked_shutdown (struct nbd_handle *h, uint32_t flags) { - if (flags != 0) { - set_error (EINVAL, "invalid flag: %" PRIu32, flags); - return -1; + if (h->strict & LIBNBD_STRICT_COMMANDS) { + if (flags != 0) { + set_error (EINVAL, "invalid flag: %" PRIu32, flags); +...
2020 Sep 11
0
[libnbd PATCH v2 2/5] generator: Refactor filtering of accepted OFlags
...OFlags (n, _, _) -> n, Some "0", None ) optargs in let args = args @ optargs in pr " def %s(" name; diff --git a/lib/disconnect.c b/lib/disconnect.c index b8356b7..9de1e34 100644 --- a/lib/disconnect.c +++ b/lib/disconnect.c @@ -30,11 +30,6 @@ int nbd_unlocked_shutdown (struct nbd_handle *h, uint32_t flags) { - if ((flags & ~LIBNBD_SHUTDOWN_IMMEDIATE) != 0) { - set_error (EINVAL, "invalid flag: %" PRIu32, flags); - return -1; - } - /* If IMMEDIATE, abort any commands that have not yet had any bytes * sent to the server, so that NBD_C...
2019 Jun 08
4
[PATCH libnbd v3] lib: Atomically update h->state when leaving the locked region.
v1 was here: https://www.redhat.com/archives/libguestfs/2019-June/thread.html#00055 v2 was here: https://www.redhat.com/archives/libguestfs/2019-June/thread.html#00067 v3: - Fix atomicly -> atomically in commit message. - Fix a comment. - Fix TOCTTOU: There is now an inline function generated called <name>_is_permitted_state, and this is called twice, first outside the
2019 May 28
6
[RFC libnbd PATCH 0/4] Add CMD_FLAG_DF support
RFC because this is an API break, but we haven't declared stable API yet. If we like it, I'm working on using libnbd to implement the nbdkit-nbd plugin; knowing whether it is API version 0.1 or 0.2 will be useful. I also dabbled with allowing optional parameters in python, although my OCaml is weak enough that there may be cleaner ways to approach that. Eric Blake (4): api: Add flags
2020 Sep 04
4
[RFC libnbd PATCH 0/2] Add knobs for client- vs. server-side validation
We have been inconsistent on how much we reject client-side without even consulting the server, vs. how much we depend on the server to detect failure (even if our request can be deemed undefined per NBD protocol). I'd like to change it so that by default, we reject as much as we can client-side for less traffic, but where the user can also change things on the fly for server-side integration
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
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