search for: nbd_aio_get_direct

Displaying 20 results from an estimated 48 matches for "nbd_aio_get_direct".

2019 Jun 20
0
Re: [libnbd PATCH] docs: Improve nbd_aio_get_direction documentation
On 6/20/19 6:50 AM, Eric Blake wrote: > Mention things to remember for avoiding the deadlock of polling for a > POLLIN from a server that has no replies to send. > > Perhaps we could split the READY state into two - one for when there > are no commands in flight (and get_direction returns 0 to state that > polling is pointless, although a multi-threaded reader can still poll
2019 Jun 20
2
[libnbd PATCH] docs: Improve nbd_aio_get_direction documentation
Mention things to remember for avoiding the deadlock of polling for a POLLIN from a server that has no replies to send. Perhaps we could split the READY state into two - one for when there are no commands in flight (and get_direction returns 0 to state that polling is pointless, although a multi-threaded reader can still poll for POLLIN), and the other when there ARE commands in flight. Such a
2019 Jul 25
2
[libnbd PATCH] generator: Let nbd_aio_get_direction return unsigned
The return value is a bitmask, and is already documented as never failing, hence it makes sense to return an unsigned value to make it easier to do bitwise operations without worrying about potential undefined C semantics on a signed value. --- I'm not sure if we want this, or even if we do if my OCaml was the most concise, but it matches the sentiment of our recent effort to let the
2019 May 31
4
[libnbd] Simultaneous read and write
...tate and h->rstate. ---------------------------------------------------------------------- It's worth also saying how the current API works, although we might want to change it. You grab the underlying file descriptor using nbd_aio_get_fd, which is what you poll on. You also have to call nbd_aio_get_direction which returns READ, WRITE or BOTH (== READ|WRITE). You then set up some events mechanism (eg. poll, epoll, etc.), poll until the file descriptor is ready, and call one of nbd_aio_notify_read or nbd_aio_notify_write. The direction can change any time the handle state changes, which includes whe...
2019 Jul 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...; > + comma := true; > + if types then pr "int "; > + pr "valid_flag"; Should this be 'unsigned int valid_flag', as bitmasks over signed values have awkward semantics if you touch the sign bit? But I'm okay with int for now, as it matches 'int nbd_aio_get_direction(...)' and nbd_pread_structured using 'int status' in its callback. > @@ -3228,10 +3218,10 @@ let rec print_arg_list ?(handle = false) ?(user_data = false) > pr "%s, " n; > if types then pr "size_t "; > pr "%s"...
2019 Aug 14
3
[libnbd PATCH 0/2] Drop generated file from git
Rich recently patched things to generate one man page per function rather than libnbd-api.3 (nice), but in doing so got stumped by a problem with a fresh git clone (automake fails for any 'include' directive that does not already exist). I've figured out how to hack around it, but the hack requires GNU make. We already use GNU make constructs elsewhere (such as $(wildcard)), but
2023 Jul 09
1
Libnbd asynchronous API with epoll
...39;s say the server is slow to send the magic string. The call to recv_into_rbuf -> h->sock->ops->recv -> recv returns EWOULDBLOCK (recv_into_rbuf returns 1). Then we stay in the same state (MAGIC.RECV_MAGIC), and return to the main program. At this point if the main program calls nbd_aio_get_direction it would return AIO_DIRECTION_READ. We are expecting to read the socket next. A write on the socket is not possible in this state (so we will not return AIO_DIRECTION_BOTH). I hope that's a bit clearer. I'm not sure about the epoll question. I haven't thought about it deeply, but...
2019 Jun 04
0
[PATCH libnbd v2 1/4] examples, tests: Remove want_to_send / ready logic, increase limit on cmds in flight.
...= handle; + i--; + in_flight++; + if (in_flight > status->most_in_flight) + status->most_in_flight = in_flight; + } fds[0].fd = nbd_aio_get_fd (nbd); - fds[0].events = want_to_send ? POLLOUT : 0; + fds[0].events = 0; fds[0].revents = 0; dir = nbd_aio_get_direction (nbd); if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0) @@ -266,30 +277,6 @@ start_thread (void *arg) (fds[0].revents & POLLOUT) != 0) nbd_aio_notify_write (nbd); - /* If we can issue another request, do so. Note that we reuse the - * same buffer for multip...
2019 May 31
0
[libnbd] Simultaneous read and write
...---------------------------------------------------------------- > > It's worth also saying how the current API works, although we might > want to change it. > > You grab the underlying file descriptor using nbd_aio_get_fd, which is > what you poll on. You also have to call nbd_aio_get_direction which > returns READ, WRITE or BOTH (== READ|WRITE). You then set up some > events mechanism (eg. poll, epoll, etc.), poll until the file > descriptor is ready, and call one of nbd_aio_notify_read or > nbd_aio_notify_write. > > The direction can change any time the handle sta...
2019 Jun 28
3
[libnbd PATCH] tests: Enhance errors test
...write command so large that we block on POLLIN, then queue + * multiple disconnects. XXX The last one should fail. + */ + if (nbd_aio_pwrite (nbd, buf, 2 * 1024 * 1024, 0, 0) == -1) { + fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ()); + exit (EXIT_FAILURE); + } + if ((nbd_aio_get_direction (nbd) & LIBNBD_AIO_DIRECTION_WRITE) == 0) { + fprintf (stderr, "%s: test failed: " + "expect to be blocked on write\n", + argv[0]); + exit (EXIT_FAILURE); + } + if (nbd_aio_disconnect (nbd, 0) == -1) { + fprintf (stderr, "%s: %s\n&q...
2019 Jul 24
0
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...; > + if types then pr "int "; > > + pr "valid_flag"; > > Should this be 'unsigned int valid_flag', as bitmasks over signed values > have awkward semantics if you touch the sign bit? But I'm okay with int > for now, as it matches 'int nbd_aio_get_direction(...)' and > nbd_pread_structured using 'int status' in its callback. Yes I can change it to unsigned - using a signed type was a mistake. I think we can change nbd_pread_structured (and friends) to use either unsigned or uint32_t which is consistent with other flag parameters. H...
2019 Jun 04
9
[PATCH libnbd v2 0/4] api: Implement concurrent writer.
v1: https://www.redhat.com/archives/libguestfs/2019-June/msg00014.html I pushed a few bits which are uncontroversial. The main changes since v1 are: An extra patch removes the want_to_send / check for nbd_aio_is_ready in examples/threaded-reads-and-writes.c. This logic was wrong since commit 6af72b87 as was pointed out by Eric in his review. Comments and structure of
2019 Jun 03
1
Re: [PATCH libnbd discussion only 4/5] api: Implement concurrent writer.
...with the C<errno>. > + > +You have a choice of whether to implement one thread per nbd_handle or > +one thread shared between all handles. > + > +=item 4. Modify main loop > + > +Finally your main loop can unconditionally call > +C<nbd_aio_notify_write> when C<nbd_aio_get_direction> returns C<WRITE> > +or C<BOTH> (since the concurrent thread can always enqueue more data > +and so is always "ready to write"). Will we ever actually reach a state that is blocked on a write completion for aio_get_direction to ever even request a WRITE or BOTH? O...
2019 Jun 27
1
Re: [libnbd PATCH 2/2] poll: Improve our interface
...23 insertions(+), 8 deletions(-) > > +++ b/lib/poll.c > @@ -57,21 +57,28 @@ nbd_unlocked_poll (struct nbd_handle *h, int timeout) > set_error (errno, "poll"); > return -1; > } I also need to squash in this, to fix our use of an uninitialized variable when nbd_aio_get_direction returns 0 (such as when we are already DEAD): diff --git i/lib/poll.c w/lib/poll.c index d356afe..fc6aae5 100644 --- i/lib/poll.c +++ w/lib/poll.c @@ -45,6 +45,8 @@ nbd_unlocked_poll (struct nbd_handle *h, int timeout) case LIBNBD_AIO_DIRECTION_BOTH: fds[0].events = POLLIN|POLLOUT;...
2019 Jun 30
0
Re: [libnbd PATCH] tests: Enhance errors test
...k on POLLIN, then queue > + * multiple disconnects. XXX The last one should fail. > + */ > + if (nbd_aio_pwrite (nbd, buf, 2 * 1024 * 1024, 0, 0) == -1) { > + fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ()); > + exit (EXIT_FAILURE); > + } > + if ((nbd_aio_get_direction (nbd) & LIBNBD_AIO_DIRECTION_WRITE) == 0) { > + fprintf (stderr, "%s: test failed: " > + "expect to be blocked on write\n", > + argv[0]); > + exit (EXIT_FAILURE); > + } This test fails when run under valgrind. An abbreviated...
2019 Jul 15
0
[PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...g) \ + fprintf (stderr, "glib: debug: " fs "\n", ## __VA_ARGS__); \ + } while (0) + +/* These are the GSource functions for libnbd handles. */ +static inline int +events_from_nbd (struct nbd_handle *nbd) +{ + int dir = nbd_aio_get_direction (nbd); + int r = 0; + + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0) + r |= G_IO_IN; + if ((dir & LIBNBD_AIO_DIRECTION_WRITE) != 0) + r |= G_IO_OUT; + return r; +} + +static gboolean +prepare (GSource *sp, gint *timeout_) +{ + struct NBDSource *source = (struct NBDSource *) sp;...
2019 Jul 17
0
[PATCH libnbd v2] examples: Include an example of integrating with the glib main loop.
...g) \ + fprintf (stderr, "glib: debug: " fs "\n", ## __VA_ARGS__); \ + } while (0) + +/* These are the GSource functions for libnbd handles. */ +static inline int +events_from_nbd (struct nbd_handle *nbd) +{ + int dir = nbd_aio_get_direction (nbd); + int r = 0; + + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0) + r |= G_IO_IN; + if ((dir & LIBNBD_AIO_DIRECTION_WRITE) != 0) + r |= G_IO_OUT; + return r; +} + +static gboolean +prepare (GSource *sp, gint *timeout_) +{ + struct NBDSource *source = (struct NBDSource *) sp;...
2019 Aug 14
0
[libnbd PATCH 2/2] docs: Drop docs/Makefile.inc from git
...aio_connect_uri \ - nbd_aio_connect_unix \ - nbd_aio_connect_tcp \ - nbd_aio_connect_command \ - nbd_aio_pread \ - nbd_aio_pread_structured \ - nbd_aio_pwrite \ - nbd_aio_disconnect \ - nbd_aio_flush \ - nbd_aio_trim \ - nbd_aio_cache \ - nbd_aio_zero \ - nbd_aio_block_status \ - nbd_aio_get_fd \ - nbd_aio_get_direction \ - nbd_aio_notify_read \ - nbd_aio_notify_write \ - nbd_aio_is_created \ - nbd_aio_is_connecting \ - nbd_aio_is_ready \ - nbd_aio_is_processing \ - nbd_aio_is_dead \ - nbd_aio_is_closed \ - nbd_aio_command_completed \ - nbd_aio_peek_command_completed \ - nbd_aio_in_flight \ - nbd_connection_sta...
2019 Jul 02
1
Re: [libnbd PATCH] tests: Enhance errors test
...> + * multiple disconnects. XXX The last one should fail. >> + */ >> + if (nbd_aio_pwrite (nbd, buf, 2 * 1024 * 1024, 0, 0) == -1) { >> + fprintf (stderr, "%s: %s\n", argv[0], nbd_get_error ()); >> + exit (EXIT_FAILURE); >> + } >> + if ((nbd_aio_get_direction (nbd) & LIBNBD_AIO_DIRECTION_WRITE) == 0) { >> + fprintf (stderr, "%s: test failed: " >> + "expect to be blocked on write\n", >> + argv[0]); >> + exit (EXIT_FAILURE); >> + } > > This test fails when run u...
2023 Jul 07
2
Libnbd asynchronous API with epoll
On 7/6/2023 7:06 PM, Nir Soffer wrote: > > - After calling for example aio_notify_read(3), can I know that the > next reading from the file descriptor would block? > > No, you have to call again aio_get_direction() and poll again until > the event happens. > Well, what I mean is: After calling aio_notify_read, if aio_get_direction returns AIO_DIRECTION_READ or