Displaying 3 results from an estimated 3 matches for "sparse_array_is_zero".
2020 Feb 10
2
[nbdkit PATCH 04/10] plugins: Wire up in-memory plugin support for NBD_INFO_INIT_STATE
...eturn 0;
}
+
+void
+sparse_array_set_size (struct sparse_array *sa, uint64_t size)
+{
+ assert (size <= INT64_MAX);
+ sa->max_pages = DIV_ROUND_UP (size, PAGE_SIZE);
+}
+
+int
+sparse_array_is_sparse (struct sparse_array *sa)
+{
+ return sa->used_pages < sa->max_pages;
+}
+
+int
+sparse_array_is_zero (struct sparse_array *sa)
+{
+ return !sa->used_pages;
+}
diff --git a/common/sparse/sparse.h b/common/sparse/sparse.h
index 704ba32..6234ffe 100644
--- a/common/sparse/sparse.h
+++ b/common/sparse/sparse.h
@@ -1,5 +1,5 @@
/* nbdkit
- * Copyright (C) 2017-2019 Red Hat Inc.
+ * Copyright (C) 20...
2020 Feb 11
0
Re: [nbdkit PATCH 04/10] plugins: Wire up in-memory plugin support for NBD_INFO_INIT_STATE
...+{
> + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lock);
> + return sparse_array_is_sparse (sa);
> +}
> +
> +/* Does current client start with all zeroes. */
> +static int
> +memory_init_zero (void *handle)
> +{
> + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&lock);
> + return sparse_array_is_zero (sa);
> +}
I was going to say these are always true, but then I remembered that
NBD_INIT_* records the state at the start of the *connection*, not the
start of the *server* instance, and if there's been a previous
connection then the RAM disk might indeed contain non-zero non-sparse
data....
2020 Feb 10
17
Cross-project NBD extension proposal: NBD_INFO_INIT_STATE
I will be following up to this email with four separate threads each
addressed to the appropriate single list, with proposed changes to:
- the NBD protocol
- qemu: both server and client
- libnbd: client
- nbdkit: server
The feature in question adds a new optional NBD_INFO_ packet to the
NBD_OPT_GO portion of handshake, adding up to 16 bits of information
that the server can advertise to the