search for: read_full

Displaying 20 results from an estimated 26 matches for "read_full".

2019 Apr 23
0
[nbdkit PATCH 6/7] nbd: Implement NBD_OPT_GO client request
...fd) return err ? -1 : 0; } +static int +nbd_newstyle_recv_option_reply (struct handle *h, uint32_t option, + struct fixed_new_option_reply *reply, + char **payload) +{ + char *buffer; + + if (payload) + *payload = NULL; + if (read_full (h->fd, reply, sizeof *reply)) { + nbdkit_error ("unable to read option reply: %m"); + return -1; + } + reply->magic = be64toh (reply->magic); + reply->option = be32toh (reply->option); + reply->reply = be32toh (reply->reply); + reply->replylen = be32toh...
2019 Apr 23
0
[nbdkit PATCH 7/7] nbd: Implement structured replies
...uint32_t count; + int error = NBD_SUCCESS; + bool more = false; + uint64_t offset = 0; /* absolute offset of structured read chunk from buf */ + uint32_t len = 0; /* 0 except for structured reads */ + bool zero = false; /* Whether to read or memset on structured read */ *fd = -1; - if (read_full (h->fd, &rep, sizeof rep) < 0) + /* magic and handle overlap between simple and structured replies */ + if (read_full (h->fd, &rep, sizeof rep.simple)) return nbd_mark_dead (h); - if (be32toh (rep.magic) != NBD_SIMPLE_REPLY_MAGIC) + switch (be32toh (rep.simple.magic)) { +...
2017 Dec 02
1
[nbdkit PATCH v2] nbd: Fix memory leak
...nbd.c b/plugins/nbd/nbd.c index b844bf5..e79042c 100644 --- a/plugins/nbd/nbd.c +++ b/plugins/nbd/nbd.c @@ -311,6 +311,8 @@ nbd_reply_raw (struct handle *h, int *fd) struct reply rep; struct transaction **ptr; struct transaction *trans; + void *buf; + uint32_t count; *fd = -1; if (read_full (h->fd, &rep, sizeof rep) < 0) @@ -334,9 +336,12 @@ nbd_reply_raw (struct handle *h, int *fd) } *fd = trans->u.fds[1]; + buf = trans->buf; + count = trans->count; + free (trans); switch (be32toh (rep.error)) { case NBD_SUCCESS: - if (trans->buf && re...
2017 Nov 12
6
[nbdkit PATCH] nbd: Add new nbd forwarding plugin
...; Export name to connect to (default "").\n" \ + +/* The per-connection handle. */ +struct handle { + int fd; + int flags; + int64_t size; + uint64_t cookie; + bool dead; +}; + +/* Read an entire buffer, returning 0 on success or -1 with errno set */ +static int read_full (int fd, void *buf, size_t len) +{ + ssize_t r; + + while (len) { + r = read (fd, buf, len); + if (r < 0) { + if (errno == EINTR || errno == EAGAIN) + continue; + return -1; + } + if (!r) { + /* Unexpected EOF */ + errno = EBADMSG; + return -1; + } +...
2019 Apr 25
6
[nbdkit PATCH v2 0/5] structured replies/.extents for nbd plugin
Updated based on other changes that have happened in the meantime: - rely more on cleanup.h (throughout) - split structured read for easier review (patch 2 and 3 were combined in v1) - rely on nbdkit not leaking a server's partial answer (patch 3) - add tests (patch 5) - other bug fixes I found while testing it - drop EOVERFLOW patch for now; it will be separate once upstream NBD protocol
2019 Apr 23
12
[nbdkit PATCH 0/7] Implement structured replies in nbd plugin
I'm hoping to implement .extents for the nbd plugin; this is a prerequisite. I'm not sure about patch 3 - if we like it, I'll squash it to 2, if we don't, I think we are okay just dropping it. I'm also wondering if we have to worry about malicious plugins that don't populate the entire .pread buffer in an effort to get nbdkit to expose portions of the heap; my patch 7 loses
2017 Nov 14
0
[nbdkit PATCH v2 1/2] nbd: Add new nbd forwarding plugin
...per-connection handle */ +struct handle { + int fd; + int flags; + int64_t size; + /* Our choice of THREAD_MODEL means at most one outstanding transaction */ + struct transaction trans; + bool dead; +}; + +/* Read an entire buffer, returning 0 on success or -1 with errno set. */ +static int +read_full (int fd, void *buf, size_t len) +{ + ssize_t r; + + while (len) { + r = read (fd, buf, len); + if (r < 0) { + if (errno == EINTR || errno == EAGAIN) + continue; + return -1; + } + if (!r) { + /* Unexpected EOF */ + errno = EBADMSG; + return -1; +...
2019 May 30
0
[nbdkit PATCH 3/4] nbd: Use libnbd 0.1
...trans; /* List of pending transactions */ }; /* Connect to server via absolute name of Unix socket */ @@ -218,451 +210,74 @@ nbdplug_config_complete (void) #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL -/* Read an entire buffer, returning 0 on success or -1 with errno set. */ -static int -read_full (int fd, void *buf, size_t len) -{ - ssize_t r; - - while (len) { - r = read (fd, buf, len); - if (r < 0) { - if (errno == EINTR || errno == EAGAIN) - continue; - return -1; - } - if (!r) { - /* Unexpected EOF */ - errno = EBADMSG; - return -1; -...
2019 Jun 12
0
[nbdkit PATCH v3 3/5] nbd: Use libnbd 0.1.3+
...< 0) { - nbdkit_error ("asprintf: %m"); - return -1; - } } if (!export) @@ -221,451 +198,74 @@ nbdplug_config_complete (void) #define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL -/* Read an entire buffer, returning 0 on success or -1 with errno set. */ -static int -read_full (int fd, void *buf, size_t len) -{ - ssize_t r; - - while (len) { - r = read (fd, buf, len); - if (r < 0) { - if (errno == EINTR || errno == EAGAIN) - continue; - return -1; - } - if (!r) { - /* Unexpected EOF */ - errno = EBADMSG; - return -1; -...
2020 Mar 19
1
[nbdkit PATCH] nbd: Drop nbd-standalone fallback
...e to share one server connection among all clients,\n" \ - " rather than a connection per client (default false).\n" \ - -#define THREAD_MODEL NBDKIT_THREAD_MODEL_PARALLEL - -/* Read an entire buffer, returning 0 on success or -1 with errno set. */ -static int -read_full (int fd, void *buf, size_t len) -{ - ssize_t r; - - while (len) { - r = read (fd, buf, len); - if (r < 0) { - if (errno == EINTR || errno == EAGAIN) - continue; - return -1; - } - if (!r) { - /* Unexpected EOF */ - errno = EBADMSG; - return -1; -...
2019 May 30
5
[nbdkit PATCH 0/4] Play with libnbd for nbdkit-add
Patch 1 played with an early draft of Rich's Fedora 30 libnbd package: https://bugzilla.redhat.com/show_bug.cgi?id=1713767#c17 Note that comment 21 provides a newer package 0.1.1-1 with a different API; and that libnbd has more unreleased API changes in the pipeline (whether that will be called 0.2 or 0.1.2); so we'll have to tweak things based on what is actually available in distros.
2019 Jun 02
5
[nbdkit PATCH v2 0/5] Play with libnbd for nbdkit-nbd
libnbd-0.1.2-1 is now available in Fedora 29/30 updates-testing, although it was not compiled against libxml2 so it lacks uri support (I ended up testing patch 4 with a self-built libnbd). Diffs since v1 - rebase to master, bump from libnbd 0.1 to 0.1.2, add URI support, better timing results Still not done - patch 5 needs associated tests Eric Blake (5): nbd: Check for libnbd nbd:
2017 Nov 21
6
[nbdkit PATCH v2 0/4] enable parallel nbd forwarding
With this, I am finally able to get the nbd plugin to do out-of-order responses to the client. Once this series goes in, we should be ready for Rich to cut a release. Eric Blake (4): nbd: Split reading into separate thread nbd: Protect writes with mutex nbd: Enable parallel handling tests: Test parallel nbd behavior plugins/nbd/nbd.c | 217
2019 Jun 12
8
[nbdkit PATCH v3 0/5] Play with libnbd for nbdkit-nbd
libnbd-0.1.4-1 is now available in Fedora 29/30 updates testing. Diffs since v2 - rebase to master, bump from libnbd 0.1.2 to 0.1.3+, add tests to TLS usage which flushed out the need to turn relative pathnames into absolute, doc tweaks Now that the testsuite covers TLS and libnbd has been fixed to provide the things I found lacking when developing v2, I'm leaning towards pushing this on
2017 Nov 14
8
[nbdkit PATCH v2 0/2] add nbd plugin
I'm still working on the interleaving (and Rich reminded me on IRC that we still don't have THREAD_MODEL_PARALLEL working anywhere yet, anyways). Since nbdkit doesn't really have a parallel plugin yet, my testing on that front will have to use qemu-nbd as the original server, as well as qemu-io as the driver (qemu-io's aio_read and aio_write commands can be used to trigger
2017 Nov 12
0
Re: [nbdkit PATCH] nbd: Add new nbd forwarding plugin
...ve > on a named Unix socket, and the transactions are serialized > rather than interleaved; further enhancements could be made to > also permit TCP servers or more efficient transmission. > > +/* Read an entire buffer, returning 0 on success or -1 with errno set */ > +static int read_full (int fd, void *buf, size_t len) > +{ > + ssize_t r; > + > + while (len) { > + r = read (fd, buf, len); > + if (r < 0) { > + if (errno == EINTR || errno == EAGAIN) > + continue; > + return -1; Hmm, emacs picked TAB indentation, but it looks like we pr...
2019 May 25
3
[RFC nbdkit PATCH 0/2] Add 'nbdkit nbd shared=1' mode
I got annoyed by qemu-nbd's default of only allowing a single connection; combine that with nbdkit's nbd plugin, and even 'qemu-nbd --list' of nbdkit counts as the single connection and immediately hangs up. If we introduce a shared mode, then 'qemu-nbd --list' can connect as many times as it wants without killing the original qemu-nbd wrapped by nbdkit. But this in turn
2019 Mar 08
0
Re: [PATCH nbdkit] Minimal implementation of NBD Structured Replies.
...tatic int > nbd_reply_raw (struct handle *h, int *fd) > { > - struct reply rep; > + struct simple_reply rep; > struct transaction *trans; > void *buf; > uint32_t count; > @@ -353,7 +353,7 @@ nbd_reply_raw (struct handle *h, int *fd) > *fd = -1; > if (read_full (h->fd, &rep, sizeof rep) < 0) > return nbd_mark_dead (h); > - if (be32toh (rep.magic) != NBD_REPLY_MAGIC) > + if (be32toh (rep.magic) != NBD_SIMPLE_REPLY_MAGIC) > return nbd_mark_dead (h); > nbdkit_debug ("received reply for cookie %#" PRIx64 &quot...
2019 Apr 23
1
Re: [nbdkit PATCH 7/7] nbd: Implement structured replies
...+++++++++++---- > 1 file changed, 212 insertions(+), 20 deletions(-) > > + case NBD_STRUCTURED_REPLY_MAGIC: > + if (!h->structured) { > + nbdkit_error ("structured response without negotiation"); > + return nbd_mark_dead (h); > + } > + if (read_full (h->fd, sizeof rep.simple + (char *) &rep, > + sizeof rep - sizeof rep.simple)) > + return nbd_mark_dead (h); > + rep.structured.flags = be16toh (rep.structured.flags); > + rep.structured.type = be16toh (rep.structured.type); > + rep.structured....
2019 Mar 08
2
[PATCH nbdkit] Minimal implementation of NBD Structured Replies.
...uint16_t flags, uint16_t type, uint64_t offset, static int nbd_reply_raw (struct handle *h, int *fd) { - struct reply rep; + struct simple_reply rep; struct transaction *trans; void *buf; uint32_t count; @@ -353,7 +353,7 @@ nbd_reply_raw (struct handle *h, int *fd) *fd = -1; if (read_full (h->fd, &rep, sizeof rep) < 0) return nbd_mark_dead (h); - if (be32toh (rep.magic) != NBD_REPLY_MAGIC) + if (be32toh (rep.magic) != NBD_SIMPLE_REPLY_MAGIC) return nbd_mark_dead (h); nbdkit_debug ("received reply for cookie %#" PRIx64 ", status %s",...