search for: libnbd_aio_direction_read

Displaying 20 results from an estimated 24 matches for "libnbd_aio_direction_read".

2019 Jun 04
0
[PATCH libnbd v2 1/4] examples, tests: Remove want_to_send / ready logic, increase limit on cmds 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 multiple in-flight requests. It doesn't matter - * he...
2019 May 31
4
[libnbd] Simultaneous read and write
...call nbd_aio_get_direction frequently. A typical loop using poll might look like: fd = nbd_aio_get_fd (nbd); for (;;) { /* <-- If you need to issue more commands, do that here. */ dir = nbd_aio_get_direction (nbd); pollfd[0].fd = fd; pollfd[0].events = 0; if (dir & LIBNBD_AIO_DIRECTION_READ) pollfd[0].events |= POLLIN; if (dir & LIBNBD_AIO_DIRECTION_WRITE) pollfd[0].events |= POLLOUT; poll (pollfd, 1, -1); if (pollfd[0].revents & LIBNBD_AIO_DIRECTION_READ) nbd_aio_notify_read (); else if (pollfd[0].revents & LIBNBD_AIO_DIRECTION_WRITE) nbd_aio_n...
2019 May 31
0
[libnbd] Simultaneous read and write
...A typical loop using poll might look like: > > fd = nbd_aio_get_fd (nbd); > for (;;) { > /* <-- If you need to issue more commands, do that here. */ > dir = nbd_aio_get_direction (nbd); > pollfd[0].fd = fd; > pollfd[0].events = 0; > if (dir & LIBNBD_AIO_DIRECTION_READ) pollfd[0].events |= POLLIN; > if (dir & LIBNBD_AIO_DIRECTION_WRITE) pollfd[0].events |= POLLOUT; > poll (pollfd, 1, -1); > if (pollfd[0].revents & LIBNBD_AIO_DIRECTION_READ) Rather, if (pollfd[0].revents & POLLIN && dir & LIBNBD_AIO_DIRECTION_READ) &g...
2019 Jun 18
0
[nbdkit PATCH] Experiment: nbd: Use ppoll() instead of pipe-to-self
...- [1].fd = h->fds[0], - [1].events = POLLIN, - }; + struct pollfd fd; struct transaction *trans, **prev; int dir; - char c; + fd.fd = h->fd; dir = nbd_aio_get_direction (h->nbd); nbdkit_debug ("polling, dir=%d", dir); if (dir & LIBNBD_AIO_DIRECTION_READ) - fds[0].events |= POLLIN; + fd.events |= POLLIN; if (dir & LIBNBD_AIO_DIRECTION_WRITE) - fds[0].events |= POLLOUT; - if (poll (fds, 2, -1) == -1) { - nbdkit_error ("poll: %m"); + fd.events |= POLLOUT; + if (ppoll (&fd, 1, NULL, &origmask)...
2019 May 21
0
[libnbd] tmp patch adding deadlock test
...bd_aio_is_dead (conn) || nbd_aio_is_closed (conn)) { + fprintf (stderr, "connection is dead or closed\n"); + goto error; + } + + fds[0].fd = nbd_aio_get_fd (conn); + fds[0].events = 0; + fds[0].revents = 0; + dir = nbd_aio_get_direction (conn); + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0) + fds[0].events |= POLLIN; + if ((dir & LIBNBD_AIO_DIRECTION_WRITE) != 0) + fds[0].events |= POLLOUT; + + if (poll (fds, 1, -1) == -1) { + perror ("poll"); + goto error; + } + + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0 && + (...
2019 May 22
0
[libnbd PATCH v3 7/7] examples: Add example to demonstrate just-fixed deadlock scenario
...bd_aio_is_dead (conn) || nbd_aio_is_closed (conn)) { + fprintf (stderr, "connection is dead or closed\n"); + goto error; + } + + fds[0].fd = nbd_aio_get_fd (conn); + fds[0].events = 0; + fds[0].revents = 0; + dir = nbd_aio_get_direction (conn); + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0) + fds[0].events |= POLLIN; + if ((dir & LIBNBD_AIO_DIRECTION_WRITE) != 0) + fds[0].events |= POLLOUT; + + if (poll (fds, 1, -1) == -1) { + perror ("poll"); + goto error; + } + + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0 && + (...
2019 Jul 15
0
[PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...ntf (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; + + /* When the NBD handle moves out of the created state (which mea...
2019 Jul 17
0
[PATCH libnbd v2] examples: Include an example of integrating with the glib main loop.
...ntf (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; + int new_fd; + int events; + + /* The poll file descriptor can ch...
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 Jul 17
2
[PATCH libnbd v2] examples: Include an example of integrating with glib main loop.
This is working now, and incorporates all of the changes in Eric's review, *except* that it still doesn't retire commands (although this seems to make no obvious difference, except possibly a performance and memory impact). Rich.
2019 Jun 04
0
[PATCH libnbd v2 4/4] examples: Add concurrent writer example.
...rrent writer is always writable, we don't have to + * test the socket in poll. Since calling nbd_aio_notify_write + * can change the state, after doing it we must restart the + * loop. + */ + nbd_aio_notify_write (nbd); + continue; + } + + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0) + fds[0].events |= POLLIN; + + if (poll (fds, 1, -1) == -1) { + perror ("poll"); + goto error; + } + + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0 && + (fds[0].revents & POLLIN) != 0) + nbd_aio_notify_read (nbd); + + /* If a com...
2019 Jun 03
0
[PATCH libnbd discussion only 5/5] examples: Add concurrent writer example.
...rrent writer is always writable, we don't have to + * test the socket in poll. Since calling nbd_aio_notify_write + * can change the state, after doing it we must restart the + * loop. + */ + nbd_aio_notify_write (nbd); + continue; + } + + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0) + fds[0].events |= POLLIN; + + if (poll (fds, 1, -1) == -1) { + perror ("poll"); + goto error; + } + + if ((dir & LIBNBD_AIO_DIRECTION_READ) != 0 && + (fds[0].revents & POLLIN) != 0) + nbd_aio_notify_read (nbd); + + /* If we ca...
2019 Jul 15
2
[PATCH libnbd] examples: Include an example of integrating with the glibc main loop.
** NOT WORKING ** This patch shows how to integrate libnbd and the glib main loop. Posted mainly as a point of discussion as it doesn't quite work yet. Rich.
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 Jun 03
10
[PATCH libnbd discussion only 0/5] api: Implement concurrent writer.
This works, but there's no time saving and I'm still investigating whether it does what I think it does. Nevertheless I thought I would post it because it (probably) implements the idea I had last night outlined in: https://www.redhat.com/archives/libguestfs/2019-June/msg00010.html The meat of the change is patch 4. Patch 5 is an example which I would probably fold into patch 4 for
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
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 30
0
[nbdkit PATCH 3/4] nbd: Use libnbd 0.1
...t pollfd fds[2] = { + [0].fd = h->fd, + [1].fd = h->fds[0], + [1].events = POLLIN, + }; + struct transaction *trans, **prev; + int dir; + char c; + + dir = nbd_aio_get_direction (h->nbd); + nbdkit_debug ("polling, dir=%d", dir); + if (dir & LIBNBD_AIO_DIRECTION_READ) + fds[0].events |= POLLIN; + if (dir & LIBNBD_AIO_DIRECTION_WRITE) + fds[0].events |= POLLOUT; + if (poll (fds, 2, -1) == -1) { + nbdkit_error ("poll: %m"); + break; + } + + if (dir & LIBNBD_AIO_DIRECTION_READ && fds[0].revents & POLLIN...
2019 Jun 12
0
[nbdkit PATCH v3 3/5] nbd: Use libnbd 0.1.3+
...t pollfd fds[2] = { + [0].fd = h->fd, + [1].fd = h->fds[0], + [1].events = POLLIN, + }; + struct transaction *trans, **prev; + int dir; + char c; + + dir = nbd_aio_get_direction (h->nbd); + nbdkit_debug ("polling, dir=%d", dir); + if (dir & LIBNBD_AIO_DIRECTION_READ) + fds[0].events |= POLLIN; + if (dir & LIBNBD_AIO_DIRECTION_WRITE) + fds[0].events |= POLLOUT; + if (poll (fds, 2, -1) == -1) { + nbdkit_error ("poll: %m"); + break; + } + + if (dir & LIBNBD_AIO_DIRECTION_READ && fds[0].revents & POLLIN...
2020 Jul 01
15
[PATCH nbdkit 0/9] nbd: Implement command= and socket-fd= parameters.
I fixed the deadlock - turned out to be an actual bug in the nbd plugin (see patch 8). I changed the command syntax so it's now: nbdkit nbd command=qemu arg=-f arg=qcow2 arg=/path/to/disk.qcow2 Nir wrote: 18:08 < nsoffer> rwmjones: regarding the nbd proxy patches, did you have specific flow that help us? 18:08 < nsoffer> rwmjones: or this is just a way to support qcow2 in the