[Libguestfs] [PATCH nbdkit v2 02/11] blocksize: Implement filtering of .can_multi_conn (forcing it to false).

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


I examined each filter to see which ones implement a cache and do not
properly consider consistency across clients for flush requests.  For
these filters we should force .can_multi_conn to return false.

I believe only one filter (blocksize) needs to be updated and all the
other ones are safe.
---
 filters/blocksize/blocksize.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/filters/blocksize/blocksize.c b/filters/blocksize/blocksize.c
index 34f58c9..9e0e713 100644
--- a/filters/blocksize/blocksize.c
+++ b/filters/blocksize/blocksize.c
@@ -164,6 +164,17 @@ blocksize_get_size (struct nbdkit_next_ops *next_ops, void *nxdata,
   return size == -1 ? size : size & ~(minblock - 1);
 }
 
+static int
+blocksize_can_multi_conn (struct nbdkit_next_ops *next_ops, void *nxdata,
+                          void *handle)
+{
+  /* Although we are serializing all requests anyway so this likely
+   * doesn't make a difference, return false because the bounce buffer
+   * is not consistent for flush.
+   */
+  return 0;
+}
+
 static int
 blocksize_pread (struct nbdkit_next_ops *next_ops, void *nxdata,
                  void *handle, void *b, uint32_t count, uint64_t offs,
@@ -370,6 +381,7 @@ static struct nbdkit_filter filter = {
   .config_help       = blocksize_config_help,
   .prepare           = blocksize_prepare,
   .get_size          = blocksize_get_size,
+  .can_multi_conn    = blocksize_can_multi_conn,
   .pread             = blocksize_pread,
   .pwrite            = blocksize_pwrite,
   .trim              = blocksize_trim,
-- 
2.19.2




More information about the Libguestfs mailing list