[Libguestfs] [PATCH nbdkit v2 10/11] data, memory: Return NBD_FLAG_CAN_MULTI_CONN.

Richard W.M. Jones rjones at redhat.com
Sat Jan 5 14:50:52 UTC 2019


These plugins use NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS because
of their use of the global sparse array.  However since they are both
RAM disks, and thus (a) flush is a no-op, and (b) the locked part of
each request is short, it is both safe and there may be some
performance benefit to using NBD_FLAG_CAN_MULTI_CONN.
---
 plugins/data/data.c     | 8 ++++++++
 plugins/memory/memory.c | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/plugins/data/data.c b/plugins/data/data.c
index f8e91be..11a7b69 100644
--- a/plugins/data/data.c
+++ b/plugins/data/data.c
@@ -324,6 +324,13 @@ data_get_size (void *handle)
   return size;
 }
 
+/* Serves the same data over multiple connections. */
+static int
+data_can_multi_conn (void *handle)
+{
+  return 1;
+}
+
 /* Read data. */
 static int
 data_pread (void *handle, void *buf, uint32_t count, uint64_t offset)
@@ -366,6 +373,7 @@ static struct nbdkit_plugin plugin = {
   .dump_plugin       = data_dump_plugin,
   .open              = data_open,
   .get_size          = data_get_size,
+  .can_multi_conn    = data_can_multi_conn,
   .pread             = data_pread,
   .pwrite            = data_pwrite,
   .zero              = data_zero,
diff --git a/plugins/memory/memory.c b/plugins/memory/memory.c
index 4013087..0084401 100644
--- a/plugins/memory/memory.c
+++ b/plugins/memory/memory.c
@@ -115,6 +115,13 @@ memory_get_size (void *handle)
   return (int64_t) size;
 }
 
+/* Serves the same data over multiple connections. */
+static int
+memory_can_multi_conn (void *handle)
+{
+  return 1;
+}
+
 /* Read data. */
 static int
 memory_pread (void *handle, void *buf, uint32_t count, uint64_t offset)
@@ -156,6 +163,7 @@ static struct nbdkit_plugin plugin = {
   .config_help       = memory_config_help,
   .open              = memory_open,
   .get_size          = memory_get_size,
+  .can_multi_conn    = memory_can_multi_conn,
   .pread             = memory_pread,
   .pwrite            = memory_pwrite,
   .zero              = memory_zero,
-- 
2.19.2




More information about the Libguestfs mailing list