Displaying 20 results from an estimated 23 matches for "gsdest".
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 Jul 17
1
Re: [PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...; +
> +/* The rest of this file is an example showing how to use the GSource
> + * defined above to control two nbdkit subprocesses, copying from one
> + * to the other in parallel.
> + */
> +
> +/* Source and destination nbdkit instances. */
> +static struct NBDSource *gssrc, *gsdest;
> +
> +#define SIZE (1024*1024*1024)
> +
> +static const char *src_args[] = {
> + "nbdkit", "-s", "-r", "pattern", "size=1G", NULL
> +};
> +
> +static const char *dest_args[] = {
> + "nbdkit", "-s",...
2019 Jul 15
0
[PATCH libnbd] examples: Include an example of integrating with the glib main loop.
...----------------------------------*/
+
+/* The rest of this file is an example showing how to use the GSource
+ * defined above to control two nbdkit subprocesses, copying from one
+ * to the other in parallel.
+ */
+
+/* Source and destination nbdkit instances. */
+static struct NBDSource *gssrc, *gsdest;
+
+#define SIZE (1024*1024*1024)
+
+static const char *src_args[] = {
+ "nbdkit", "-s", "-r", "pattern", "size=1G", NULL
+};
+
+static const char *dest_args[] = {
+ "nbdkit", "-s", "memory", "size=1G", NULL...
2019 Jul 17
0
[PATCH libnbd v2] examples: Include an example of integrating with the glib main loop.
...----------------------------------*/
+
+/* The rest of this file is an example showing how to use the GSource
+ * defined above to control two nbdkit subprocesses, copying from one
+ * to the other in parallel.
+ */
+
+/* Source and destination nbdkit instances. */
+static struct NBDSource *gssrc, *gsdest;
+
+#define SIZE (1024*1024*1024)
+
+static const char *src_args[] = {
+ "nbdkit", "-s", "--exit-with-parent", "-r", "pattern", "size=1G", NULL
+};
+
+static const char *dest_args[] = {
+ "nbdkit", "-s", "--exit-...
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 Jul 30
0
[PATCH libnbd] examples: Fix theoretical cookie race in example.
.../
- g_idle_add (write_data, NULL);
+ g_idle_add (write_data, buffer);
return 1;
}
@@ -432,31 +421,19 @@ finished_read (unsigned valid_flag, void *vp, int64_t rcookie, int *error)
static gboolean
write_data (gpointer user_data)
{
- size_t i;
+ struct buffer *buffer = user_data;
if (gsdest == NULL)
return FALSE;
- /* Find the first read-completed buffer and schedule it to be
- * written.
- */
- for (i = 0; i < nr_buffers; ++i) {
- if (buffers[i].state == BUFFER_READ_COMPLETED)
- goto found;
- }
- /* This should never happen. */
- abort ();
-
- found:
- buf...
2019 Jul 30
4
[PATCH libnbd] examples: Fix theoretical cookie race in example.
Previously discussed here:
https://www.redhat.com/archives/libguestfs/2019-July/msg00213.html
It turns out that deferring callbacks is a PITA. (It would be a bit
easier if C has closures.) However by rewriting the example we can
avoid the need to use the cookie at all and make it run a bit more
efficiently, so let's do that instead.
Rich.
2019 Aug 14
2
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...r_data = &buffers[i] },
> + 0) == -1) {
> fprintf (stderr, "%s\n", nbd_get_error ());
> exit (EXIT_FAILURE);
> }
> @@ -428,7 +429,8 @@ write_data (gpointer user_data)
> buffer->state = BUFFER_WRITING;
> if (nbd_aio_pwrite (gsdest->nbd, buffer->data,
> BUFFER_SIZE, buffer->offset,
> - finished_write, buffer, 0) == -1) {
> + (nbd_completion_callback) { .callback = finished_write, .user_data = buffer },
Worth splitting the long lines?
> +++...
2019 Aug 14
0
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...t; + 0) == -1) {
> > fprintf (stderr, "%s\n", nbd_get_error ());
> > exit (EXIT_FAILURE);
> > }
> > @@ -428,7 +429,8 @@ write_data (gpointer user_data)
> > buffer->state = BUFFER_WRITING;
> > if (nbd_aio_pwrite (gsdest->nbd, buffer->data,
> > BUFFER_SIZE, buffer->offset,
> > - finished_write, buffer, 0) == -1) {
> > + (nbd_completion_callback) { .callback = finished_write, .user_data = buffer },
>
> Worth splitting...
2019 Aug 14
1
Re: [PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...th a generic generator fix, or an open-coded
one-liner, the rest of your patch changes via:
s/NBD_NULL_CALLBACK(completion)/NBD_NULL_COMPLETION/
>>> @@ -428,7 +429,8 @@ write_data (gpointer user_data)
>>> buffer->state = BUFFER_WRITING;
>>> if (nbd_aio_pwrite (gsdest->nbd, buffer->data,
>>> BUFFER_SIZE, buffer->offset,
>>> - finished_write, buffer, 0) == -1) {
>>> + (nbd_completion_callback) { .callback = finished_write, .user_data = buffer },
>>
>>...
2019 Aug 13
0
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
..., &buffers[i], 0) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
@@ -426,9 +426,9 @@ write_data (gpointer user_data)
assert (buffer->state == BUFFER_READ_COMPLETED);
buffer->state = BUFFER_WRITING;
- if (nbd_aio_pwrite_callback (gsdest->nbd, buffer->data,
- BUFFER_SIZE, buffer->offset,
- finished_write, buffer, 0) == -1) {
+ if (nbd_aio_pwrite (gsdest->nbd, buffer->data,
+ BUFFER_SIZE, buffer->offset,
+ finishe...
2019 Aug 13
2
[PATCH libnbd] api: Rename nbd_aio_*_callback to nbd_aio_*.
This applies on top of the OClosure v2 series posted a few
minutes ago.
Rich.
2019 Aug 12
0
[PATCH libnbd 7/7] api: Remove the valid_flag from all callbacks.
.../* This callback is called from libnbd when any write command finishes. */
static int
-finished_write (unsigned valid_flag, void *vp, int *error)
+finished_write (void *vp, int *error)
{
struct buffer *buffer = vp;
- if (!(valid_flag & LIBNBD_CALLBACK_VALID))
- return 0;
-
if (gsdest == NULL)
return 0;
diff --git a/examples/strict-structured-reads.c b/examples/strict-structured-reads.c
index b3880b7..701b216 100644
--- a/examples/strict-structured-reads.c
+++ b/examples/strict-structured-reads.c
@@ -51,16 +51,13 @@ static int64_t total_bytes;
static int total_success;...
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 Jul 24
0
[PATCH libnbd 2/3] lib: Implement closure lifetimes.
...callback is called from libnbd when any write command finishes. */
static int
-finished_write (void *vp, int64_t wcookie, int *error)
+finished_write (int valid_flag, void *vp, int64_t wcookie, int *error)
{
size_t i;
+ if (!(valid_flag & LIBNBD_CALLBACK_VALID))
+ return 0;
+
if (gsdest == NULL)
return 0;
diff --git a/examples/strict-structured-reads.c b/examples/strict-structured-reads.c
index a50f662..c154b08 100644
--- a/examples/strict-structured-reads.c
+++ b/examples/strict-structured-reads.c
@@ -51,12 +51,16 @@ static int64_t total_bytes;
static int total_success;...
2019 Aug 13
0
[PATCH libnbd 2/4] api: Add free function and remove valid_flag parameter.
.../* This callback is called from libnbd when any write command finishes. */
static int
-finished_write (unsigned valid_flag, void *vp, int *error)
+finished_write (void *vp, int *error)
{
struct buffer *buffer = vp;
- if (!(valid_flag & LIBNBD_CALLBACK_VALID))
- return 0;
-
if (gsdest == NULL)
return 0;
diff --git a/examples/strict-structured-reads.c b/examples/strict-structured-reads.c
index d7c3e1b..6ea1700 100644
--- a/examples/strict-structured-reads.c
+++ b/examples/strict-structured-reads.c
@@ -51,16 +51,13 @@ static int64_t total_bytes;
static int total_success;...
2019 Jul 24
0
[PATCH libnbd v2 2/5] lib: Implement closure lifetimes.
...back is called from libnbd when any write command finishes. */
static int
-finished_write (void *vp, int64_t wcookie, int *error)
+finished_write (unsigned valid_flag, void *vp, int64_t wcookie, int *error)
{
size_t i;
+ if (!(valid_flag & LIBNBD_CALLBACK_VALID))
+ return 0;
+
if (gsdest == NULL)
return 0;
diff --git a/examples/strict-structured-reads.c b/examples/strict-structured-reads.c
index a50f662..a996a67 100644
--- a/examples/strict-structured-reads.c
+++ b/examples/strict-structured-reads.c
@@ -51,12 +51,16 @@ static int64_t total_bytes;
static int total_success;...
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
...) { .callback = finished_read, .user_data = &buffers[i] },
+ 0) == -1) {
fprintf (stderr, "%s\n", nbd_get_error ());
exit (EXIT_FAILURE);
}
@@ -428,7 +429,8 @@ write_data (gpointer user_data)
buffer->state = BUFFER_WRITING;
if (nbd_aio_pwrite (gsdest->nbd, buffer->data,
BUFFER_SIZE, buffer->offset,
- finished_write, buffer, 0) == -1) {
+ (nbd_completion_callback) { .callback = finished_write, .user_data = buffer },
+ 0) == -1) {
fprintf (stderr,...
2019 Jul 25
0
[PATCH libnbd v3 1/2] lib: Implement closure lifetimes.
...back is called from libnbd when any write command finishes. */
static int
-finished_write (void *vp, int64_t wcookie, int *error)
+finished_write (unsigned valid_flag, void *vp, int64_t wcookie, int *error)
{
size_t i;
+ if (!(valid_flag & LIBNBD_CALLBACK_VALID))
+ return 0;
+
if (gsdest == NULL)
return 0;
diff --git a/examples/strict-structured-reads.c b/examples/strict-structured-reads.c
index 1a551a0..511dd7c 100644
--- a/examples/strict-structured-reads.c
+++ b/examples/strict-structured-reads.c
@@ -51,12 +51,16 @@ static int64_t total_bytes;
static int total_success;...
2019 Jul 25
4
[PATCH libnbd v3 0/2] lib: Implement closure lifetimes.
I think I've addressed everything that was raised in review.
Some of the highlights:
- Callbacks should be freed reliably along all exit paths.
- There's a simple test of closure lifetimes.
- I've tried to use VALID|FREE in all the places where I'm confident
that it's safe and correct to do. There may be more places. Note
this is an optimization and shouldn't