search for: backend_get_size

Displaying 20 results from an estimated 27 matches for "backend_get_size".

2019 Aug 30
0
[nbdkit PATCH 5/9] server: Cache per-connection size
...size; uint16_t eflags; bool readonly; bool can_flush; diff --git a/server/backend.c b/server/backend.c index b2054aa2..374d8540 100644 --- a/server/backend.c +++ b/server/backend.c @@ -132,10 +132,13 @@ backend_set_handle (struct backend *b, struct connection *conn, void *handle) int64_t backend_get_size (struct backend *b, struct connection *conn) { + struct b_conn_handle *h = &conn->handles[b->i]; + debug ("%s: get_size", b->name); - /* TODO caching */ - return b->get_size (b, conn); + if (h->exportsize == -1) + h->exportsize = b->get_size (b, conn);...
2019 Sep 19
0
[PATCH nbdkit v2 2/4] filters: Implement next_ops .reopen call.
.../* Wrappers for all callbacks in a filter's struct nbdkit_next_ops. */ +int +backend_reopen (struct backend *b, struct connection *conn, int readonly) +{ + debug ("%s: reopen", b->name); + + backend_close (b, conn); + return backend_open (b, conn, readonly); +} + int64_t backend_get_size (struct backend *b, struct connection *conn) { diff --git a/server/filters.c b/server/filters.c index 1091c2d..78e32bc 100644 --- a/server/filters.c +++ b/server/filters.c @@ -237,6 +237,13 @@ filter_close (struct backend *b, struct connection *conn) * single ‘void *nxdata’ struct pointer (‘b_co...
2019 Sep 19
0
[PATCH nbdkit v3 1/3] filters: Implement next_ops .reopen call.
..._reopen (struct backend *b, struct connection *conn, int readonly) +{ + struct b_conn_handle *h = &conn->handles[b->i]; + + debug ("%s: reopen", b->name); + + if (h->handle != NULL) + backend_close (b, conn); + return backend_open (b, conn, readonly); +} + int64_t backend_get_size (struct backend *b, struct connection *conn) { diff --git a/server/filters.c b/server/filters.c index 1091c2d..78e32bc 100644 --- a/server/filters.c +++ b/server/filters.c @@ -237,6 +237,13 @@ filter_close (struct backend *b, struct connection *conn) * single ‘void *nxdata’ struct pointer (‘b_co...
2020 Feb 12
5
[PATCH nbdkit 1/3] server: Rename global backend pointer to "top".
..._FLAG_HAS_FLAGS; int fl; - if (backend_open (backend, read_only) == -1) + if (backend_open (top, read_only) == -1) return -1; /* Prepare (for filters), called just after open. */ - if (backend_prepare (backend) == -1) + if (backend_prepare (top) == -1) return -1; - size = backend_get_size (backend); + size = backend_get_size (top); if (size == -1) return -1; if (size < 0) { @@ -98,57 +98,57 @@ protocol_common_open (uint64_t *exportsize, uint16_t *flags) /* Check all flags even if they won't be advertised, to prime the * cache and make later request validati...
2020 Feb 12
2
Re: [PATCH nbdkit 3/3] server: filters: Remove struct b_h.
On 2/12/20 7:40 AM, Richard W.M. Jones wrote: > This was previously used as ‘nxdata’ and stored a tuple of ’b->next’ > and the real filter handle. However after recent changes we don't > need it. We can use ‘b->next’ as nxdata, and the handle is passed to > us by the calling functions. > > Inspired by Eric Blakes observations in this email: Blake's >
2020 Feb 12
0
[PATCH nbdkit 3/3] server: filters: Remove struct b_h.
...int next_reopen (void *nxdata, int readonly) { - struct b_h *b_h = nxdata; - return backend_reopen (b_h->b, readonly); + struct backend *b_next = nxdata; + return backend_reopen (b_next, readonly); } static int64_t next_get_size (void *nxdata) { - struct b_h *b_h = nxdata; - return backend_get_size (b_h->b); + struct backend *b_next = nxdata; + return backend_get_size (b_next); } static int next_can_write (void *nxdata) { - struct b_h *b_h = nxdata; - return backend_can_write (b_h->b); + struct backend *b_next = nxdata; + return backend_can_write (b_next); } static int...
2020 Feb 11
0
[PATCH nbdkit 3/3] server: Remove explicit connection parameter, use TLS instead.
...uint64_t offset, uint32_t count) - __attribute__((__nonnull__ (1, 2))); + __attribute__((__nonnull__ (1))); -extern int backend_reopen (struct backend *b, struct connection *conn, - int readonly) - __attribute__((__nonnull__ (1, 2))); -extern int64_t backend_get_size (struct backend *b, struct connection *conn) - __attribute__((__nonnull__ (1, 2))); -extern int backend_can_write (struct backend *b, struct connection *conn) - __attribute__((__nonnull__ (1, 2))); -extern int backend_can_flush (struct backend *b, struct connection *conn) - __attribute__((__nonn...
2020 Feb 11
4
[PATCH nbdkit v2 0/3] server: Remove explicit connection parameter.
v1 was here: https://www.redhat.com/archives/libguestfs/2020-February/msg00081.html v2 replaces struct connection *conn = GET_CONN; with GET_CONN; which sets conn implicitly and asserts that it is non-NULL. If we actually want to test if conn is non-NULL or behave differently, then you must use threadlocal_get_conn() instead, and some existing uses do that. Rich.
2020 Feb 11
5
[PATCH nbdkit 0/3] server: Remove explicit connection parameter.
The third patch is a large but mechanical change which gets rid of passing around struct connection * entirely within the server, preferring instead to reference the connection through thread-local storage. I hope this is a gateway to simplifying other parts of the code. Rich.
2020 Feb 12
0
Re: [PATCH nbdkit 3/3] server: filters: Remove struct b_h.
...it would require > recompilation, we already state that filter recompilation is par for > the course (since only plugins promise API compatibility). Yes my original version had stuff like: static struct nbdkit_next_ops next_ops = { .reopen = (void *) backend_reopen, .get_size = (void *) backend_get_size, but that wasn't very safe, and exporting struct backend, even opaquely, to the public header didn't sound like a good idea either. (Are C structs always treated the same by name? That could cause a problem for a filter which used "struct backend" for some internal reason I thin...
2019 Aug 30
15
[nbdkit PATCH 0/9] can_FOO caching, more filter validation
It's easy to use the sh script to demonstrate that nbdkit is inefficiently calling into .get_size, .can_fua, and friends more than necessary. We've also commented on the list in the past that it would be nice to ensure that when filters call into next_ops, they are not violating constraints (as we've have to fix several bugs in the past where we did not have such checking to protect
2020 Feb 12
2
[nbdkit PATCH] filters: Remove most next_* wrappers
...a is a pointer to the next backend in the linked list. - */ - -static int -next_reopen (void *nxdata, int readonly) -{ - struct backend *b_next = nxdata; - return backend_reopen (b_next, readonly); -} - -static int64_t -next_get_size (void *nxdata) -{ - struct backend *b_next = nxdata; - return backend_get_size (b_next); -} - -static int -next_can_write (void *nxdata) -{ - struct backend *b_next = nxdata; - return backend_can_write (b_next); -} - -static int -next_can_flush (void *nxdata) -{ - struct backend *b_next = nxdata; - return backend_can_flush (b_next); -} - -static int -next_is_rotational (v...
2019 Aug 30
3
[nbdkit PATCH v2 0/2] caching .can_write
This is a subset of the last half of the larger 9-patch series. The uncontroversial first half of that series is pushed, but here, I tried to reduce the size of the patches by splitting out some of the more complex changes, so that the rest of the changes remaining in the series are more mechanical. In turn, it forced me to write timing tests, which let me spot another spot where we are wasting
2020 Sep 21
0
[nbdkit PATCH v3 06/14] api: Add .export_description
...nore over-length strings. XXX Also ignore non-UTF8? */ + if (s && strnlen (s, NBD_MAX_STRING + 1) > NBD_MAX_STRING) { + controlpath_debug ("%s: export_description: ignoring invalid string", + b->name); + s = NULL; + } + return s; +} + int64_t backend_get_size (struct backend *b) { diff --git a/server/filters.c b/server/filters.c index dd4417be..54abf9a4 100644 --- a/server/filters.c +++ b/server/filters.c @@ -291,6 +291,7 @@ filter_close (struct backend *b, void *handle) static struct nbdkit_next_ops next_ops = { .reopen = backend_reopen, + .expo...
2020 Feb 12
0
[PATCH nbdkit 2/3] server: Rename ‘struct b_conn_handle’ to plain ‘struct handle’.
...struct b_conn_handle *h = &conn->handles[b->i]; + struct handle *h = get_handle (conn, b->i); assert (h->exportsize <= INT64_MAX); /* Guaranteed by negotiation phase */ return count > 0 && offset <= h->exportsize && @@ -291,7 +291,7 @@ int64_t backend_get_size (struct backend *b) { GET_CONN; - struct b_conn_handle *h = &conn->handles[b->i]; + struct handle *h = get_handle (conn, b->i); controlpath_debug ("%s: get_size", b->name); @@ -305,7 +305,7 @@ int backend_can_write (struct backend *b) { GET_CONN; - struc...
2019 Aug 30
0
[nbdkit PATCH 9/9] server: Move command validation from protocol.c to backend.c
...c b/server/protocol.c index 03862f5f..db40cca3 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -47,50 +47,43 @@ #include "minmax.h" #include "protocol.h" -static bool -valid_range (struct connection *conn, uint64_t offset, uint32_t count) -{ - uint64_t exportsize = backend_get_size (backend, conn); - - assert (exportsize <= INT64_MAX); /* Guaranteed by negotiation phase */ - return count > 0 && offset <= exportsize && offset + count <= exportsize; -} - static bool validate_request (struct connection *conn, uint16_t cmd, uint1...
2019 Sep 19
6
[PATCH nbdkit 0/2] Add new retry filter.
This is a retry filter implementation as outlined here: https://www.redhat.com/archives/libguestfs/2019-September/msg00167.html It is only lightly tested. One way to test it is to try an SSH copy (see the commit message for patch 2/2), and in the middle of the copy kill the per-connection sshd on the remote machine. You will see that the copy recovers after a few seconds. Add the nbdkit -v
2019 Sep 19
7
[PATCH nbdkit v2 0/4] Add new retry filter.
v1 was here: https://www.redhat.com/archives/libguestfs/2019-September/msg00199.html v2: - Adds a fairly simple yet comprehensive test using sh plugin. - Rebase and retest. Patch 1 is a misc patch not really related to the series. Rich.
2020 Feb 11
1
[nbdkit PATCH] filters: Make nxdata persistent
..._conn *nxdata = handle; + assert (nxdata->b == b->next && nxdata->conn == conn); if (f->filter.get_size) - return f->filter.get_size (&next_ops, &nxdata, handle); + return f->filter.get_size (&next_ops, nxdata, nxdata->handle); else return backend_get_size (b->next, conn); } @@ -458,10 +481,11 @@ static int filter_can_write (struct backend *b, struct connection *conn, void *handle) { struct backend_filter *f = container_of (b, struct backend_filter, backend); - struct b_conn nxdata = { .b = b->next, .conn = conn }; + struct b_conn *nxda...
2019 Sep 19
7
[PATCH nbdkit v3 0/3] Add new retry filter.
v2 was here: https://www.redhat.com/archives/libguestfs/2019-September/msg00221.html I think this is more like "the one". It handles reopen failing correctly, and there is a second test for that. I also ran my sshd tests locally and it worked in all scenarios I could think up (except of course sshd not being available at the start, but we want that to fail). Rich.