Displaying 20 results from an estimated 34 matches for "libnbd_read_hol".
Did you mean:
libnbd_read_hole
2019 Aug 13
0
[PATCH libnbd 4/4] lib: Add CALL_CALLBACK macro.
...flags = be16toh (h->sbuf.sr.structured_reply.flags);
- if (cmd->cb.fn.chunk.callback (cmd->cb.fn.chunk.user_data,
- cmd->data + offset, length,
- cmd->offset + offset,
- LIBNBD_READ_HOLE, &error) == -1)
+ if (CALL_CALLBACK (cmd->cb.fn.chunk,
+ cmd->data + offset, length,
+ cmd->offset + offset,
+ LIBNBD_READ_HOLE, &error) == -1)
if (cmd->error == 0)
cmd->error =...
2019 Jun 21
0
[libnbd PATCH v2 3/5] states: Add nbd_pread_structured API
...he C<error> parameter is controlled by
+the C<status> parameter, which is one of
+
+=over 4
+
+=item C<LIBNBD_READ_DATA> = 1
+
+C<subbuf> was populated with C<count> bytes of data. C<error> is the
+errno value of any earlier detected error, or zero.
+
+=item C<LIBNBD_READ_HOLE> = 2
+
+C<subbuf> represents a hole, and contains C<count> NUL bytes. C<error>
+is the errno value of any earlier detected error, or zero.
+
+=item C<LIBNBD_READ_ERROR> = 3
+
+C<count> is 0, so C<subbuf> is unusable. C<error> is the errno value
+reporte...
2019 Jul 25
0
[libnbd PATCH] lib: Reduce number of read/block_status callbacks
...valid_flags (h);
- if (cmd->cb.fn.read (LIBNBD_CALLBACK_VALID, cmd->cb.fn_user_data,
+ if (cmd->cb.fn.read (valid, cmd->cb.fn_user_data,
cmd->data + offset, length,
cmd->offset + offset,
LIBNBD_READ_HOLE, &error) == -1)
if (cmd->error == 0)
cmd->error = error ? error : EPROTO;
+ if (valid & LIBNBD_CALLBACK_FREE)
+ cmd->cb.fn.read = NULL; /* because we've freed it */
}
SET_NEXT_STATE(%FINISH);
@@ -498,12 +520,15 @@
if (meta_contex...
2019 Jun 21
9
[libnbd PATCH v2 0/5] nbd_pread_structured
Since v1:
- rebase to applied patches
- split out support for Int in callbacks
- sort of test that callbacks work in OCaml (see comment in patch 5)
- rename API to nbd_pread_structured
- expose error as explicit parameter to callback
Eric Blake (5):
generator: Allow Int in callbacks
states: Wire in a read callback
states: Add nbd_pread_structured API
states: Add tests for
2019 Aug 14
2
[libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...;
if (cmd->cb.fn.chunk.callback) {
int error = cmd->error;
- uint16_t flags = be16toh (h->sbuf.sr.structured_reply.flags);
if (CALL_CALLBACK (cmd->cb.fn.chunk,
cmd->data + offset, length,
@@ -462,8 +455,6 @@
LIBNBD_READ_HOLE, &error) == -1)
if (cmd->error == 0)
cmd->error = error ? error : EPROTO;
- if (flags & NBD_REPLY_FLAG_DONE)
- FREE_CALLBACK (cmd->cb.fn.chunk);
}
SET_NEXT_STATE(%FINISH);
@@ -509,7 +500,6 @@
if (meta_context) {
/* Call the ca...
2019 Jun 25
1
[libnbd PATCH] pread_structured: Change callback type to use Mutable error
...f> was populated with C<count> bytes of data. C<error> is the
-errno value of any earlier detected error, or zero.
+C<subbuf> was populated with C<count> bytes of data. On input, C<error>
+contains the errno value of any earlier detected error, or zero.
=item C<LIBNBD_READ_HOLE> = 2
-C<subbuf> represents a hole, and contains C<count> NUL bytes. C<error>
-is the errno value of any earlier detected error, or zero.
+C<subbuf> represents a hole, and contains C<count> NUL bytes. On input,
+C<error> contains the errno value of any earlie...
2019 Jun 18
0
[libnbd PATCH 5/8] states: Wire in a read callback
...EXT_STATE (%FINISH);
}
return 0;
@@ -357,6 +389,13 @@
}
memset (cmd->data + offset, 0, length);
+ if (cmd->cb.fn.read) {
+ errno = 0;
+ if (cmd->cb.fn.read (cmd->cb.opaque, cmd->data + offset, length,
+ cmd->offset + offset, LIBNBD_READ_HOLE) == -1)
+ if (cmd->error == 0)
+ cmd->error = errno ? errno : EPROTO;
+ }
SET_NEXT_STATE(%FINISH);
}
diff --git a/lib/internal.h b/lib/internal.h
index cb0e170..a1e27df 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -233,12 +233,14 @@ struct socket {
typede...
2019 Aug 12
0
[PATCH libnbd 4/7] lib: Allow closure user_data to be associated with a free callback.
...& LIBNBD_CALLBACK_FREE) {
cmd->cb.fn.chunk = NULL; /* because we've freed it */
+ nbd_internal_free_callback (h, cmd->cb.fn_user_data);
+ }
}
SET_NEXT_STATE (%FINISH);
@@ -473,8 +477,10 @@ valid_flags (struct nbd_handle *h)
LIBNBD_READ_HOLE, &error) == -1)
if (cmd->error == 0)
cmd->error = error ? error : EPROTO;
- if (valid & LIBNBD_CALLBACK_FREE)
+ if (valid & LIBNBD_CALLBACK_FREE) {
cmd->cb.fn.chunk = NULL; /* because we've freed it */
+ nbd_internal_free_callb...
2019 Jun 21
0
[libnbd PATCH v2 2/5] states: Wire in a read callback
...hen length == 0.
*/
memset (cmd->data + offset, 0, length);
+ if (cmd->cb.fn.read) {
+ errno = 0;
+ if (cmd->cb.fn.read (cmd->cb.opaque, cmd->data + offset, length,
+ cmd->offset + offset, cmd->error,
+ LIBNBD_READ_HOLE) == -1)
+ if (cmd->error == 0)
+ cmd->error = errno ? errno : EPROTO;
+ }
SET_NEXT_STATE(%FINISH);
}
diff --git a/lib/internal.h b/lib/internal.h
index 3756fac..b79c7a9 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -233,12 +233,14 @@ struct socket {
typede...
2019 Aug 13
0
[PATCH libnbd 3/4] lib: Add FREE_CALLBACK macro.
...b.fn.chunk.user_data);
- cmd->cb.fn.chunk.callback = NULL; /* because we've freed it */
- }
+ if (flags & NBD_REPLY_FLAG_DONE)
+ FREE_CALLBACK (cmd->cb.fn.chunk);
}
SET_NEXT_STATE (%FINISH);
@@ -469,11 +463,8 @@
LIBNBD_READ_HOLE, &error) == -1)
if (cmd->error == 0)
cmd->error = error ? error : EPROTO;
- if (flags & NBD_REPLY_FLAG_DONE) {
- if (cmd->cb.fn.chunk.free)
- cmd->cb.fn.chunk.free (cmd->cb.fn.chunk.user_data);
- cmd->cb.fn.chunk.callback =...
2019 Aug 15
0
Re: [libnbd PATCH] lib: Consolidate free callbacks to just happen at retire time
...back) {
> int error = cmd->error;
> - uint16_t flags = be16toh (h->sbuf.sr.structured_reply.flags);
>
> if (CALL_CALLBACK (cmd->cb.fn.chunk,
> cmd->data + offset, length,
> @@ -462,8 +455,6 @@
> LIBNBD_READ_HOLE, &error) == -1)
> if (cmd->error == 0)
> cmd->error = error ? error : EPROTO;
> - if (flags & NBD_REPLY_FLAG_DONE)
> - FREE_CALLBACK (cmd->cb.fn.chunk);
> }
>
> SET_NEXT_STATE(%FINISH);
> @@ -509,7 +500,6 @@
>...
2019 Jun 21
0
[libnbd PATCH v2 5/5] states: Add DF flag support for pread
...511) == 0);
+ }
+ else {
+ assert (buf == rbuf + 512);
+ assert (count == 512);
+ assert (offset == 2048 + 512);
+ assert (buf[0] == 1 && memcmp (buf, buf + 1, 511) == 0);
+ }
assert (!data->seen_data);
data->seen_data = true;
break;
case LIBNBD_READ_HOLE:
+ assert (!data->df); /* Relies on qemu-nbd's behavior */
assert (buf == rbuf);
assert (count == 512);
assert (offset == 2048);
@@ -134,7 +143,15 @@ main (int argc, char *argv[])
}
assert (data.seen_data && data.seen_hole);
- // XXX Repeat with DF flag
+...
2019 Aug 03
1
[PATCH libnbd] generator: Generate typedefs automatically for Closure arguments.
...->cb.fn.chunk) {
int error = cmd->error;
unsigned valid = valid_flags (h);
- if (cmd->cb.fn.read (valid, cmd->cb.fn_user_data,
- cmd->data + offset, length,
- cmd->offset + offset,
- LIBNBD_READ_HOLE, &error) == -1)
+ if (cmd->cb.fn.chunk (valid, cmd->cb.fn_user_data,
+ cmd->data + offset, length,
+ cmd->offset + offset,
+ LIBNBD_READ_HOLE, &error) == -1)
if (cmd->error == 0)...
2019 Jun 29
0
[libnbd PATCH 6/6] examples: New example for strict read validations
...+ struct range *r, **prev;
+
+ /* libnbd guarantees this: */
+ assert (offset >= data->offset);
+ assert (offset + count <= data->offset + data->count);
+
+ switch (status) {
+ case LIBNBD_READ_DATA:
+ total_data_chunks++;
+ total_data_bytes += count;
+ break;
+ case LIBNBD_READ_HOLE:
+ total_hole_chunks++;
+ total_hole_bytes += count;
+ break;
+ case LIBNBD_READ_ERROR:
+ assert (count == 0);
+ count = 1; /* Ensure no further chunks visit that offset */
+ break;
+ default:
+ goto error;
+ }
+ data->chunks++;
+ if (count == 0) {
+ fprintf (stderr...
2019 Jun 20
1
Re: [libnbd PATCH 6/8] states: Add nbd_pread_callback API
...overall idea looks sound to me.
> +of C<buf> within the original buffer). The C<status> parameter is
> +one of
> +
> +=over 4
> +
> +=item C<LIBNBD_READ_DATA> = 1
> +
> +C<buf> was populated with C<count> bytes of data.
> +
> +=item C<LIBNBD_READ_HOLE> = 2
> +
> +C<buf> represents a hole, and contains C<count> NUL bytes.
> +
> +=item C<LIBNBD_READ_ERR> = 3
> +
> +C<count> is 0, and C<buf> represents the offset of where an error
> +occurred. The error is visible in C<errno> or by callin...
2019 Jun 18
0
[libnbd PATCH 6/8] states: Add nbd_pread_callback API
...ch C<buf>
+begins within the image (note that this is not the relative offset
+of C<buf> within the original buffer). The C<status> parameter is
+one of
+
+=over 4
+
+=item C<LIBNBD_READ_DATA> = 1
+
+C<buf> was populated with C<count> bytes of data.
+
+=item C<LIBNBD_READ_HOLE> = 2
+
+C<buf> represents a hole, and contains C<count> NUL bytes.
+
+=item C<LIBNBD_READ_ERR> = 3
+
+C<count> is 0, and C<buf> represents the offset of where an error
+occurred. The error is visible in C<errno> or by calling
+C<nbd_get_errno>.
+
+=back...
2019 Aug 13
8
[PATCH libnbd 0/4] Add free function to callbacks.
Patches 1 & 2 are rather complex, but the end result is that we pass
closures + user_data + free function in single struct parameters as I
described previously in this email:
https://www.redhat.com/archives/libguestfs/2019-August/msg00210.html
Patch 3 adds a convenient FREE_CALLBACK macro which seems a worthwhile
simplification if you buy into 1 & 2.
Patch 4 adds another macro which is
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...unk.callback) {
int error = cmd->error;
unsigned valid = valid_flags (h);
- if (cmd->cb.fn.chunk (valid, cmd->cb.fn_user_data,
- cmd->data + offset, length,
- cmd->offset + offset,
- LIBNBD_READ_HOLE, &error) == -1)
+ if (cmd->cb.fn.chunk.callback (valid, cmd->cb.fn.chunk.user_data,
+ cmd->data + offset, length,
+ cmd->offset + offset,
+ LIBNBD_READ_HOLE, &error)...
2019 Jun 18
17
[libnbd PATCH 0/8] Add nbd_pread_callback
I've mentioned this topic before (in fact, the idea of adding
NBD_CMD_FLAG_DF was first mentioned at [1]), but finally finished
enough of an implementation to feel confident in posting it.
I'd still like to add something under examples/ that uses the new API
to implement strict checking of a server's structured replies read
implementation (ensure that a server never sends data after
2019 Jul 16
2
[PATCH libnbd] generator: Define new Closure type
** INCOMPLETE **
This is the generator change as discussed on the list already.
The Python and OCaml bindings are not yet done.
It passes all [C only] tests and valgrind.
Note that nbd_add_close_callback is inconsistent with other closure
types because it passes the user_data parameter after the function.
(This is not caused by the current patch, it was already
inconsistent). We decided that