Displaying 20 results from an estimated 23 matches for "nbd_mark_dead".
2019 Apr 23
0
[nbdkit PATCH 7/7] nbd: Implement structured replies
...uint64_t offset;
uint32_t count;
+ uint32_t err;
struct transaction *next;
};
@@ -137,6 +139,7 @@ struct handle {
int fd;
int flags;
int64_t size;
+ bool structured;
pthread_t reader;
/* Prevents concurrent threads from interleaving writes to server */
@@ -230,9 +233,10 @@ nbd_mark_dead (struct handle *h)
return -1;
}
-/* Find and remove the transaction corresponding to cookie from the list. */
+/* Find and possibly remove the transaction corresponding to cookie
+ from the list. */
static struct transaction *
-find_trans_by_cookie (struct handle *h, uint64_t cookie)
+find_...
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 2/2] nbd: Split reading into separate thread
...truct handle *h)
+{
+ int r = pthread_mutex_unlock (&h->lock);
+ assert (!r);
+}
+
/* Called during transmission phases when there is no hope of
* resynchronizing with the server, and all further requests from the
* client will fail. Returns -1 for convenience. */
@@ -187,6 +205,7 @@ nbd_mark_dead (struct handle *h)
{
int err = errno;
+ nbd_lock (h);
if (!h->dead) {
nbdkit_debug ("permanent failure while talking to server %s: %m",
sockname);
@@ -194,6 +213,7 @@ nbd_mark_dead (struct handle *h)
}
else if (!err)
errno = ESHUTDOWN;
+ nbd...
2019 Apr 23
1
Re: [nbdkit PATCH 7/7] nbd: Implement structured replies
...d/nbd.c | 232 ++++++++++++++++++++++++++++++++++++++++++----
> 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.st...
2017 Dec 04
1
[nbdkit PATCH] nbd: Fix sporadic use-after-free
...;trans' between threads?
plugins/nbd/nbd.c | 43 ++++++++++++++++++++++++++++++-------------
1 file changed, 30 insertions(+), 13 deletions(-)
diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c
index e79042c..9d40e87 100644
--- a/plugins/nbd/nbd.c
+++ b/plugins/nbd/nbd.c
@@ -227,6 +227,26 @@ nbd_mark_dead (struct handle *h)
return -1;
}
+/* Find and remove the transaction corresponding to cookie from the list. */
+static struct transaction *
+find_trans_by_cookie (struct handle *h, uint64_t cookie)
+{
+ struct transaction **ptr;
+ struct transaction *trans;
+
+ nbd_lock (h);
+ ptr = &h-...
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
2020 Mar 19
1
[nbdkit PATCH] nbd: Drop nbd-standalone fallback
...)
- continue;
- return -1;
- }
- buf += r;
- len -= r;
- }
- return 0;
-}
-
-/* Called during transmission phases when there is no hope of
- * resynchronizing with the server, and all further requests from the
- * client will fail. Returns -1 for convenience. */
-static int
-nbd_mark_dead (struct handle *h)
-{
- int err = errno;
-
- ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&h->trans_lock);
- if (!h->dead) {
- nbdkit_debug ("permanent failure while talking to server %s: %m",
- servname);
- h->dead = true;
- }
- else if (!err)
- errno = ESH...
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:
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 14
0
[nbdkit PATCH v2 1/2] nbd: Add new nbd forwarding plugin
...)
+ continue;
+ return -1;
+ }
+ buf += r;
+ len -= r;
+ }
+ return 0;
+}
+
+/* Called during transmission phases when there is no hope of
+ * resynchronizing with the server, and all further requests from the
+ * client will fail. Returns -1 for convenience. */
+static int
+nbd_mark_dead (struct handle *h)
+{
+ int err = errno;
+
+ if (!h->dead) {
+ nbdkit_debug ("permanent failure while talking to server %s: %m",
+ sockname);
+ h->dead = true;
+ }
+ else if (!err)
+ errno = ESHUTDOWN;
+ /* NBD only accepts a limited set of errno value...
2018 Dec 07
0
[nbdkit PATCH 6/5] nbd: More debug details
...x, cookie %#" PRIx64, type, name_of_nbd_cmd(type),
+ flags, offset, count, cookie);
r = write_full (h->fd, &req, sizeof req);
if (buf && !r)
r = write_full (h->fd, buf, count);
@@ -353,7 +354,8 @@ nbd_reply_raw (struct handle *h, int *fd)
return nbd_mark_dead (h);
if (be32toh (rep.magic) != NBD_REPLY_MAGIC)
return nbd_mark_dead (h);
- nbdkit_debug ("received reply for cookie %#" PRIx64, rep.handle);
+ nbdkit_debug ("received reply for cookie %#" PRIx64 ", status %s",
+ rep.handle, name_of_nbd_error(...
2019 May 25
1
[nbdkit PATCH] nbd: Rewrite thread passing to use semaphore rather than pipe
...return trans;
trans = find_trans_by_cookie (h, cookie, true);
err:
err = errno;
- if (trans) {
- close (trans->u.fds[0]);
- close (trans->u.fds[1]);
- free (trans);
- }
- else
- close (fd);
+ if (sem_destroy (&trans->sem))
+ abort ();
+ free (trans);
+ nbd_mark_dead (h);
errno = err;
- return nbd_mark_dead (h);
+ return NULL;
}
/* Shorthand for nbd_request_full when no extra buffers are involved. */
-static int
+static struct transaction *
nbd_request (struct handle *h, uint16_t flags, uint16_t type, uint64_t offset,
uint32_t count)
{...
2019 Mar 08
0
Re: [PATCH nbdkit] Minimal implementation of NBD Structured Replies.
...t; - 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",
> rep.handle, name_of_nbd_error(...
2018 Dec 07
1
Re: [nbdkit PATCH 6/5] nbd: More debug details
...e, name_of_nbd_cmd(type),
> + flags, offset, count, cookie);
> r = write_full (h->fd, &req, sizeof req);
> if (buf && !r)
> r = write_full (h->fd, buf, count);
> @@ -353,7 +354,8 @@ nbd_reply_raw (struct handle *h, int *fd)
> return nbd_mark_dead (h);
> if (be32toh (rep.magic) != NBD_REPLY_MAGIC)
> return nbd_mark_dead (h);
> - nbdkit_debug ("received reply for cookie %#" PRIx64, rep.handle);
> + nbdkit_debug ("received reply for cookie %#" PRIx64 ", status %s",
> + rep.h...
2019 Mar 08
2
[PATCH nbdkit] Minimal implementation of NBD Structured Replies.
...d_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",
rep.handle, name_of_nbd_error(be32toh (rep.error)));
di...
2018 Dec 06
10
[PATCH nbdkit 0/5] protocol: Generate map functions from NBD protocol flags to printable strings.
With some crufty sed scripts we can generate functions that map from
NBD protocol flags (eg. NBD_CMD_READ) to strings ("NBD_CMD_READ").
This works on GNU sed and with FreeBSD, also with GNU sed's --posix
option, so I guess the sed code is POSIX-compatible.
Rich.
2017 Dec 02
1
[nbdkit PATCH v2] nbd: Fix memory leak
...;
+ buf = trans->buf;
+ count = trans->count;
+ free (trans);
switch (be32toh (rep.error)) {
case NBD_SUCCESS:
- if (trans->buf && read_full (h->fd, trans->buf, trans->count) < 0)
+ if (buf && read_full (h->fd, buf, count) < 0)
return nbd_mark_dead (h);
return 0;
case NBD_EPERM:
@@ -399,6 +404,7 @@ nbd_reader (void *handle)
abort ();
}
close (trans->u.fds[1]);
+ free (trans);
}
return NULL;
}
--
2.14.3