From 7f6c9b5ea1286720c937cf8a091677aa6952c884 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 5 Aug 2021 09:13:39 +0100 Subject: [PATCH] New upstream stable version 1.26.3. resolves: rhbz#1950632 Add Python .cleanup() method. Fix data corruption in zero and trim on unaligned tail. resolves: rhbz#1990134 --- ...-cache-Reduce-verbosity-of-debugging.patch | 2 +- ...l_shutdown-when-unloading-the-plugin.patch | 76 ----- ...e-cow-Add-blk_read_multiple-function.patch | 6 +- ...nding-by-only-ignoring-caml_stat_all.patch | 39 --- ...cow-Use-full-pread-pwrite-operations.patch | 2 +- ...ally-call-.get_ready-method-in-test-.patch | 28 -- ...4-cache-Implement-cache-on-read-PATH.patch | 6 +- 0004-ocaml-Rearrange-the-callbacks.patch | 315 ------------------ ...e-Add-cache-min-block-size-parameter.patch | 6 +- ...l-Fix-comment-on-plugin-.pread-field.patch | 29 -- ...-cow-Use-a-64K-block-size-by-default.patch | 6 +- 0006-docs-Correct-selinux-label-example.patch | 40 --- ...tor-printing-state-into-new-function.patch | 2 +- ...ow-Fix-assert-failure-in-cow_extents.patch | 148 -------- ...x-misleading-LRU-diagram-and-comment.patch | 79 ----- ...t-cache-on-read-option-really-caches.patch | 2 +- ...ch => 0009-cow-Implement-cow-on-read.patch | 10 +- ...umentation-of-.can_cache-and-.cache-.patch | 104 ------ ...documentation-of-cow-on-cache-option.patch | 37 -- ...delay-Add-delay-open-and-delay-close.patch | 2 +- 0011-python-Implement-.cleanup-method.patch | 90 +++++ ...cache-Simplify-test-cache-on-read.sh.patch | 40 --- nbdkit.spec | 43 ++- sources | 4 +- 24 files changed, 134 insertions(+), 982 deletions(-) rename 0012-cache-Reduce-verbosity-of-debugging.patch => 0001-cache-Reduce-verbosity-of-debugging.patch (98%) delete mode 100644 0001-ocaml-Call-caml_shutdown-when-unloading-the-plugin.patch rename 0013-cache-cow-Add-blk_read_multiple-function.patch => 0002-cache-cow-Add-blk_read_multiple-function.patch (99%) delete mode 100644 0002-ocaml-Fix-valgrinding-by-only-ignoring-caml_stat_all.patch rename 0014-cache-cow-Use-full-pread-pwrite-operations.patch => 0003-cache-cow-Use-full-pread-pwrite-operations.patch (99%) delete mode 100644 0003-ocaml-tests-Actually-call-.get_ready-method-in-test-.patch rename 0015-cache-Implement-cache-on-read-PATH.patch => 0004-cache-Implement-cache-on-read-PATH.patch (97%) delete mode 100644 0004-ocaml-Rearrange-the-callbacks.patch rename 0016-cache-Add-cache-min-block-size-parameter.patch => 0005-cache-Add-cache-min-block-size-parameter.patch (98%) delete mode 100644 0005-ocaml-Fix-comment-on-plugin-.pread-field.patch rename 0017-cache-cow-Use-a-64K-block-size-by-default.patch => 0006-cache-cow-Use-a-64K-block-size-by-default.patch (97%) delete mode 100644 0006-docs-Correct-selinux-label-example.patch rename 0018-cache-Refactor-printing-state-into-new-function.patch => 0007-cache-Refactor-printing-state-into-new-function.patch (95%) delete mode 100644 0007-cow-Fix-assert-failure-in-cow_extents.patch delete mode 100644 0008-cache-Fix-misleading-LRU-diagram-and-comment.patch rename 0019-tests-cache-Test-cache-on-read-option-really-caches.patch => 0008-tests-cache-Test-cache-on-read-option-really-caches.patch (98%) rename 0020-cow-Implement-cow-on-read.patch => 0009-cow-Implement-cow-on-read.patch (98%) delete mode 100644 0009-docs-Improve-documentation-of-.can_cache-and-.cache-.patch delete mode 100644 0010-cow-Improve-documentation-of-cow-on-cache-option.patch rename 0021-delay-Add-delay-open-and-delay-close.patch => 0010-delay-Add-delay-open-and-delay-close.patch (98%) create mode 100644 0011-python-Implement-.cleanup-method.patch delete mode 100644 0011-tests-cache-Simplify-test-cache-on-read.sh.patch diff --git a/0012-cache-Reduce-verbosity-of-debugging.patch b/0001-cache-Reduce-verbosity-of-debugging.patch similarity index 98% rename from 0012-cache-Reduce-verbosity-of-debugging.patch rename to 0001-cache-Reduce-verbosity-of-debugging.patch index a19c780..4d6f23c 100644 --- a/0012-cache-Reduce-verbosity-of-debugging.patch +++ b/0001-cache-Reduce-verbosity-of-debugging.patch @@ -1,4 +1,4 @@ -From 37844f524c01b54b28755b77b68b7c1ec2b79512 Mon Sep 17 00:00:00 2001 +From 8785f90134fa912e31e72190d217db9c39754fcf Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 26 Jul 2021 11:59:43 +0100 Subject: [PATCH] cache: Reduce verbosity of debugging diff --git a/0001-ocaml-Call-caml_shutdown-when-unloading-the-plugin.patch b/0001-ocaml-Call-caml_shutdown-when-unloading-the-plugin.patch deleted file mode 100644 index 7c916ed..0000000 --- a/0001-ocaml-Call-caml_shutdown-when-unloading-the-plugin.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 5a23c7cf3c5eccac6e6de775722bc1136a66be83 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Mon, 5 Jul 2021 17:54:45 +0100 -Subject: [PATCH] ocaml: Call caml_shutdown when unloading the plugin - -This has several useful effects (taken from the OCaml documentation): - -* Running the functions that were registered with "Stdlib.at_exit". - -* Triggering finalization of allocated custom blocks. For example, - "Stdlib.in_channel" and "Stdlib.out_channel" are represented by - custom blocks that enclose file descriptors, which are to be - released. - -* Unloading the dependent shared libraries that were loaded by the runtime, - including "dynlink" plugins. - -* Freeing the memory blocks that were allocated by the runtime with - "malloc". - -If the function is not present (for OCaml < 4.05) then we just skip -this step. - -(cherry picked from commit 99140272a0675b3d123d2c42cb0a5ab73b09fba2) ---- - configure.ac | 18 ++++++++++++++++++ - plugins/ocaml/plugin.c | 4 ++++ - 2 files changed, 22 insertions(+) - -diff --git a/configure.ac b/configure.ac -index 9b171b7e..a7c4c8d3 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -857,6 +857,24 @@ EOF - rm -f conftest.c conftest.o - ]) - -+dnl Check if OCaml has caml_shutdown (added 2014). -+AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \ -+ test "x$enable_ocaml" = "xyes"],[ -+ AC_MSG_CHECKING([for caml_shutdown]) -+ cat >conftest.c <<'EOF' -+#include -+int main () { char *p = (void *) caml_shutdown; return 0; } -+EOF -+ AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[ -+ AC_MSG_RESULT([yes]) -+ AC_DEFINE([HAVE_CAML_SHUTDOWN],[1], -+ [caml_shutdown found at compile time.]) -+ ],[ -+ AC_MSG_RESULT([no]) -+ ]) -+ rm -f conftest.c conftest.o -+]) -+ - dnl For developing plugins in Rust, optional. - AC_CHECK_PROG([CARGO],[cargo],[cargo],[no]) - AC_ARG_ENABLE([rust], -diff --git a/plugins/ocaml/plugin.c b/plugins/ocaml/plugin.c -index 00959cb6..9d7d72ad 100644 ---- a/plugins/ocaml/plugin.c -+++ b/plugins/ocaml/plugin.c -@@ -131,6 +131,10 @@ unload_wrapper (void) - free ((char *) plugin.config_help); - - remove_roots (); -+ -+#ifdef HAVE_CAML_SHUTDOWN -+ caml_shutdown (); -+#endif - } - - static void --- -2.31.1 - diff --git a/0013-cache-cow-Add-blk_read_multiple-function.patch b/0002-cache-cow-Add-blk_read_multiple-function.patch similarity index 99% rename from 0013-cache-cow-Add-blk_read_multiple-function.patch rename to 0002-cache-cow-Add-blk_read_multiple-function.patch index 0d273b2..b222302 100644 --- a/0013-cache-cow-Add-blk_read_multiple-function.patch +++ b/0002-cache-cow-Add-blk_read_multiple-function.patch @@ -1,4 +1,4 @@ -From a118e05670659b3efd1ab191023cc0bc24cf29e7 Mon Sep 17 00:00:00 2001 +From f6d831cd517851157e822ee96de5894e0b37c22d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 26 Jul 2021 13:55:21 +0100 Subject: [PATCH] cache, cow: Add blk_read_multiple function @@ -181,7 +181,7 @@ index 87c753e2..1ee33ed7 100644 extern int blk_cache (nbdkit_next *next, uint64_t blknum, uint8_t *block, int *err) diff --git a/filters/cache/cache.c b/filters/cache/cache.c -index 499aec68..9c081948 100644 +index 745f552d..14cc03f2 100644 --- a/filters/cache/cache.c +++ b/filters/cache/cache.c @@ -313,7 +313,7 @@ cache_pread (nbdkit_next *next, @@ -354,7 +354,7 @@ index e6fd7417..b066c602 100644 enum cache_mode { BLK_CACHE_IGNORE, /* Do nothing */ diff --git a/filters/cow/cow.c b/filters/cow/cow.c -index 3bd09399..f74c0a34 100644 +index 6cefee36..e939f23f 100644 --- a/filters/cow/cow.c +++ b/filters/cow/cow.c @@ -210,7 +210,7 @@ cow_pread (nbdkit_next *next, diff --git a/0002-ocaml-Fix-valgrinding-by-only-ignoring-caml_stat_all.patch b/0002-ocaml-Fix-valgrinding-by-only-ignoring-caml_stat_all.patch deleted file mode 100644 index 64acf73..0000000 --- a/0002-ocaml-Fix-valgrinding-by-only-ignoring-caml_stat_all.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 397b7b245aee178b2683de8a34847843f658b43d Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Mon, 5 Jul 2021 18:00:28 +0100 -Subject: [PATCH] ocaml: Fix valgrinding by only ignoring caml_stat_alloc* - functions - -These are meant to be "static" so are not freed by design. Other -allocations should all be freed, especially now that we are calling -caml_shutdown. - -(cherry picked from commit 875a5056758dca754225f49516a0f4c8e788ac94) ---- - valgrind/ocaml.suppressions | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/valgrind/ocaml.suppressions b/valgrind/ocaml.suppressions -index f74b0943..a2b7fc60 100644 ---- a/valgrind/ocaml.suppressions -+++ b/valgrind/ocaml.suppressions -@@ -29,11 +29,12 @@ - # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - # SUCH DAMAGE. - --# OCaml, by design, doesn't bother to free the major heap before --# calling exit. Ignore that leak. -+# OCaml caml_stat_* allocations are meant to be "static" so OCaml will -+# never free them by design. See the OCaml manual, chapter -+# "Interfacing C with OCaml". - { -- ocaml_heap_leak -+ ocaml_stat_allocations - Memcheck:Leak - ... -- fun:caml_alloc_for_heap -+ fun:caml_stat_alloc* - } --- -2.31.1 - diff --git a/0014-cache-cow-Use-full-pread-pwrite-operations.patch b/0003-cache-cow-Use-full-pread-pwrite-operations.patch similarity index 99% rename from 0014-cache-cow-Use-full-pread-pwrite-operations.patch rename to 0003-cache-cow-Use-full-pread-pwrite-operations.patch index eab056e..f6fdd51 100644 --- a/0014-cache-cow-Use-full-pread-pwrite-operations.patch +++ b/0003-cache-cow-Use-full-pread-pwrite-operations.patch @@ -1,4 +1,4 @@ -From bf82947dabe08a0d51f87eb14619291900c65574 Mon Sep 17 00:00:00 2001 +From 1b21e41dfd69b0a5f51657bc6f8b1cbc49663ee2 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 26 Jul 2021 15:21:18 +0100 Subject: [PATCH] cache, cow: Use full pread/pwrite operations diff --git a/0003-ocaml-tests-Actually-call-.get_ready-method-in-test-.patch b/0003-ocaml-tests-Actually-call-.get_ready-method-in-test-.patch deleted file mode 100644 index b84017e..0000000 --- a/0003-ocaml-tests-Actually-call-.get_ready-method-in-test-.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 4efeffd80a5e85abf5603f20631910b2ef180317 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 13 Jul 2021 16:50:16 +0100 -Subject: [PATCH] ocaml: tests: Actually call .get_ready method in test plugin - -It was added in a previous commit, but never called. - -Fixes: commit d52d0adf3d395f98f0fb4cd06044cc6dc7aeaef0 -(cherry picked from commit 156aa8337e5d1886c296a94de631b01c10f1bc78) ---- - tests/test_ocaml_plugin.ml | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/tests/test_ocaml_plugin.ml b/tests/test_ocaml_plugin.ml -index 2bbaa218..fee8528e 100644 ---- a/tests/test_ocaml_plugin.ml -+++ b/tests/test_ocaml_plugin.ml -@@ -99,6 +99,7 @@ let plugin = { - version = NBDKit.version (); - - load = Some load; -+ get_ready = Some get_ready; - unload = Some unload; - config = Some config; - config_complete = Some config_complete; --- -2.31.1 - diff --git a/0015-cache-Implement-cache-on-read-PATH.patch b/0004-cache-Implement-cache-on-read-PATH.patch similarity index 97% rename from 0015-cache-Implement-cache-on-read-PATH.patch rename to 0004-cache-Implement-cache-on-read-PATH.patch index 126ff58..d2c5b9e 100644 --- a/0015-cache-Implement-cache-on-read-PATH.patch +++ b/0004-cache-Implement-cache-on-read-PATH.patch @@ -1,4 +1,4 @@ -From b7fe9b7b6c6d317291c76f15910215828bbfd4ff Mon Sep 17 00:00:00 2001 +From dac1245e839d64cc5ee22ae4f804a950e487ff5d Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 26 Jul 2021 16:16:15 +0100 Subject: [PATCH] cache: Implement cache-on-read=/PATH @@ -33,7 +33,7 @@ index 42bd3779..19f79605 100644 nbdkit_debug ("cache: cache-on-read block %" PRIu64 " (offset %" PRIu64 ")", diff --git a/filters/cache/cache.c b/filters/cache/cache.c -index 9c081948..8af52106 100644 +index 14cc03f2..44da0008 100644 --- a/filters/cache/cache.c +++ b/filters/cache/cache.c @@ -74,7 +74,8 @@ unsigned blksize; @@ -118,7 +118,7 @@ index 2b72221f..a559adef 100644 #endif /* NBDKIT_CACHE_H */ diff --git a/filters/cache/nbdkit-cache-filter.pod b/filters/cache/nbdkit-cache-filter.pod -index 34fd0b29..2ac307e0 100644 +index ebcf1d10..f20cb9ce 100644 --- a/filters/cache/nbdkit-cache-filter.pod +++ b/filters/cache/nbdkit-cache-filter.pod @@ -8,7 +8,7 @@ nbdkit-cache-filter - nbdkit caching filter diff --git a/0004-ocaml-Rearrange-the-callbacks.patch b/0004-ocaml-Rearrange-the-callbacks.patch deleted file mode 100644 index 7b3738e..0000000 --- a/0004-ocaml-Rearrange-the-callbacks.patch +++ /dev/null @@ -1,315 +0,0 @@ -From 1610c0865534819eccefec55fd2d751843bb6d64 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 13 Jul 2021 16:15:45 +0100 -Subject: [PATCH] ocaml: Rearrange the callbacks - -Just refactoring. - -(cherry picked from commit e54e16e81c51dcbb16d70d83c5b0403babdf5f99) ---- - plugins/ocaml/NBDKit.ml | 68 ++++++++++++++++++-------------------- - plugins/ocaml/NBDKit.mli | 31 +++++++++-------- - plugins/ocaml/callbacks.h | 34 +++++++++---------- - tests/test_ocaml_plugin.ml | 9 ++--- - 4 files changed, 72 insertions(+), 70 deletions(-) - -diff --git a/plugins/ocaml/NBDKit.ml b/plugins/ocaml/NBDKit.ml -index cdc3bc58..529618d2 100644 ---- a/plugins/ocaml/NBDKit.ml -+++ b/plugins/ocaml/NBDKit.ml -@@ -65,27 +65,20 @@ type 'a plugin = { - description : string; - - load : (unit -> unit) option; -+ get_ready : (unit -> unit) option; -+ after_fork : (unit -> unit) option; - unload : (unit -> unit) option; - -- dump_plugin : (unit -> unit) option; -- - config : (string -> string -> unit) option; - config_complete : (unit -> unit) option; - config_help : string; - thread_model : (unit -> thread_model) option; - -- get_ready : (unit -> unit) option; -- after_fork : (unit -> unit) option; -- - preconnect : (bool -> unit) option; -- list_exports : (bool -> bool -> export list) option; -- default_export : (bool -> bool -> string) option; - open_connection : (bool -> 'a) option; - close : ('a -> unit) option; - - get_size : ('a -> int64) option; -- export_description : ('a -> string) option; -- - can_cache : ('a -> cache_flag) option; - can_extents : ('a -> bool) option; - can_fast_zero : ('a -> bool) option; -@@ -104,6 +97,11 @@ type 'a plugin = { - zero : ('a -> int32 -> int64 -> flags -> unit) option; - extents : ('a -> int32 -> int64 -> flags -> extent list) option; - cache : ('a -> int32 -> int64 -> flags -> unit) option; -+ -+ dump_plugin : (unit -> unit) option; -+ list_exports : (bool -> bool -> export list) option; -+ default_export : (bool -> bool -> string) option; -+ export_description : ('a -> string) option; - } - - let default_callbacks = { -@@ -113,27 +111,20 @@ let default_callbacks = { - description = ""; - - load = None; -+ get_ready = None; -+ after_fork = None; - unload = None; - -- dump_plugin = None; -- - config = None; - config_complete = None; - config_help = ""; - thread_model = None; - -- get_ready = None; -- after_fork = None; -- - preconnect = None; -- list_exports = None; -- default_export = None; - open_connection = None; - close = None; - - get_size = None; -- export_description = None; -- - can_cache = None; - can_extents = None; - can_fast_zero = None; -@@ -152,6 +143,11 @@ let default_callbacks = { - zero = None; - extents = None; - cache = None; -+ -+ dump_plugin = None; -+ list_exports = None; -+ default_export = None; -+ export_description = None; - } - - external set_name : string -> unit = "ocaml_nbdkit_set_name" "noalloc" -@@ -186,21 +182,8 @@ let register_plugin plugin = - if plugin.config_help <> "" then set_config_help plugin.config_help; - - let may f = function None -> () | Some a -> f a in -- may (set_field "load") plugin.load; -- may (set_field "unload") plugin.unload; -- may (set_field "dump_plugin") plugin.dump_plugin; -- may (set_field "config") plugin.config; -- may (set_field "config_complete") plugin.config_complete; -- may (set_field "thread_model") plugin.thread_model; -- may (set_field "get_ready") plugin.get_ready; - may (set_field "after_fork") plugin.after_fork; -- may (set_field "preconnect") plugin.preconnect; -- may (set_field "list_exports") plugin.list_exports; -- may (set_field "default_export") plugin.default_export; -- may (set_field "open") plugin.open_connection; -- may (set_field "close") plugin.close; -- may (set_field "get_size") plugin.get_size; -- may (set_field "export_description") plugin.export_description; -+ may (set_field "cache") plugin.cache; - may (set_field "can_cache") plugin.can_cache; - may (set_field "can_extents") plugin.can_extents; - may (set_field "can_fast_zero") plugin.can_fast_zero; -@@ -210,14 +193,27 @@ let register_plugin plugin = - may (set_field "can_trim") plugin.can_trim; - may (set_field "can_write") plugin.can_write; - may (set_field "can_zero") plugin.can_zero; -+ may (set_field "close") plugin.close; -+ may (set_field "config") plugin.config; -+ may (set_field "config_complete") plugin.config_complete; -+ may (set_field "default_export") plugin.default_export; -+ may (set_field "dump_plugin") plugin.dump_plugin; -+ may (set_field "export_description") plugin.export_description; -+ may (set_field "extents") plugin.extents; -+ may (set_field "flush") plugin.flush; -+ may (set_field "get_ready") plugin.get_ready; -+ may (set_field "get_size") plugin.get_size; - may (set_field "is_rotational") plugin.is_rotational; -+ may (set_field "list_exports") plugin.list_exports; -+ may (set_field "load") plugin.load; -+ may (set_field "open") plugin.open_connection; - may (set_field "pread") plugin.pread; -+ may (set_field "preconnect") plugin.preconnect; - may (set_field "pwrite") plugin.pwrite; -- may (set_field "flush") plugin.flush; -+ may (set_field "thread_model") plugin.thread_model; - may (set_field "trim") plugin.trim; -- may (set_field "zero") plugin.zero; -- may (set_field "extents") plugin.extents; -- may (set_field "cache") plugin.cache -+ may (set_field "unload") plugin.unload; -+ may (set_field "zero") plugin.zero - - (* Bindings to nbdkit server functions. *) - -diff --git a/plugins/ocaml/NBDKit.mli b/plugins/ocaml/NBDKit.mli -index ac4b0cbc..cda09f44 100644 ---- a/plugins/ocaml/NBDKit.mli -+++ b/plugins/ocaml/NBDKit.mli -@@ -69,33 +69,31 @@ type thread_model = - The ['a] parameter is the handle type returned by your - [open_connection] method and passed back to all connected calls. *) - type 'a plugin = { -- name : string; (* required *) -+ (* Plugin description. *) -+ name : string; (** required field *) - longname : string; - version : string; - description : string; - -+ (* Plugin lifecycle. *) - load : (unit -> unit) option; -+ get_ready : (unit -> unit) option; -+ after_fork : (unit -> unit) option; - unload : (unit -> unit) option; - -- dump_plugin : (unit -> unit) option; -- -+ (* Plugin configuration. *) - config : (string -> string -> unit) option; - config_complete : (unit -> unit) option; - config_help : string; - thread_model : (unit -> thread_model) option; - -- get_ready : (unit -> unit) option; -- after_fork : (unit -> unit) option; -- -+ (* Connection lifecycle. *) - preconnect : (bool -> unit) option; -- list_exports : (bool -> bool -> export list) option; -- default_export : (bool -> bool -> string) option; -- open_connection : (bool -> 'a) option; (* required *) -+ open_connection : (bool -> 'a) option; (** required field *) - close : ('a -> unit) option; - -- get_size : ('a -> int64) option; (* required *) -- export_description : ('a -> string) option; -- -+ (* NBD negotiation. *) -+ get_size : ('a -> int64) option; (** required field *) - can_cache : ('a -> cache_flag) option; - can_extents : ('a -> bool) option; - can_fast_zero : ('a -> bool) option; -@@ -107,13 +105,20 @@ type 'a plugin = { - can_zero : ('a -> bool) option; - is_rotational : ('a -> bool) option; - -- pread : ('a -> int32 -> int64 -> flags -> string) option; (* required *) -+ (* Serving data. *) -+ pread : ('a -> int32 -> int64 -> flags -> string) option; (* required field *) - pwrite : ('a -> string -> int64 -> flags -> unit) option; - flush : ('a -> flags -> unit) option; - trim : ('a -> int32 -> int64 -> flags -> unit) option; - zero : ('a -> int32 -> int64 -> flags -> unit) option; - extents : ('a -> int32 -> int64 -> flags -> extent list) option; - cache : ('a -> int32 -> int64 -> flags -> unit) option; -+ -+ (* Miscellaneous. *) -+ dump_plugin : (unit -> unit) option; -+ list_exports : (bool -> bool -> export list) option; -+ default_export : (bool -> bool -> string) option; -+ export_description : ('a -> string) option; - } - - (** The plugin with all fields set to [None], so you can write -diff --git a/plugins/ocaml/callbacks.h b/plugins/ocaml/callbacks.h -index 7171ef21..4d29fb73 100644 ---- a/plugins/ocaml/callbacks.h -+++ b/plugins/ocaml/callbacks.h -@@ -33,21 +33,8 @@ - /* This is not a header file. It is included at various places in - * plugin.c as a convenient way to define per-callback things. - */ --CB(load) --CB(unload) --CB(dump_plugin) --CB(config) --CB(config_complete) --CB(thread_model) --CB(get_ready) - CB(after_fork) --CB(preconnect) --CB(list_exports) --CB(default_export) --CB(open) --CB(close) --CB(get_size) --CB(export_description) -+CB(cache) - CB(can_cache) - CB(can_extents) - CB(can_fast_zero) -@@ -57,11 +44,24 @@ CB(can_multi_conn) - CB(can_trim) - CB(can_write) - CB(can_zero) -+CB(close) -+CB(config) -+CB(config_complete) -+CB(default_export) -+CB(dump_plugin) -+CB(export_description) -+CB(extents) -+CB(flush) -+CB(get_ready) -+CB(get_size) - CB(is_rotational) -+CB(list_exports) -+CB(load) -+CB(open) - CB(pread) -+CB(preconnect) - CB(pwrite) --CB(flush) -+CB(thread_model) - CB(trim) -+CB(unload) - CB(zero) --CB(extents) --CB(cache) -diff --git a/tests/test_ocaml_plugin.ml b/tests/test_ocaml_plugin.ml -index fee8528e..00a65a75 100644 ---- a/tests/test_ocaml_plugin.ml -+++ b/tests/test_ocaml_plugin.ml -@@ -101,19 +101,20 @@ let plugin = { - load = Some load; - get_ready = Some get_ready; - unload = Some unload; -+ - config = Some config; - config_complete = Some config_complete; -+ thread_model = Some thread_model; - - open_connection = Some open_connection; - close = Some close; -- list_exports = Some list_exports; -- default_export = Some default_export; - get_size = Some get_size; - pread = Some pread; - pwrite = Some pwrite; -- - extents = Some extents; -- thread_model = Some thread_model; -+ -+ list_exports = Some list_exports; -+ default_export = Some default_export; - } - - let () = NBDKit.register_plugin plugin --- -2.31.1 - diff --git a/0016-cache-Add-cache-min-block-size-parameter.patch b/0005-cache-Add-cache-min-block-size-parameter.patch similarity index 98% rename from 0016-cache-Add-cache-min-block-size-parameter.patch rename to 0005-cache-Add-cache-min-block-size-parameter.patch index 0d5bc11..f97cba1 100644 --- a/0016-cache-Add-cache-min-block-size-parameter.patch +++ b/0005-cache-Add-cache-min-block-size-parameter.patch @@ -1,4 +1,4 @@ -From 743b49ed9cd8d302d0274fc16ebc7783978b0c2e Mon Sep 17 00:00:00 2001 +From 9d1d3bb689a6a88bcc376b699d9668a3a623faee Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 26 Jul 2021 16:30:26 +0100 Subject: [PATCH] cache: Add cache-min-block-size parameter @@ -45,7 +45,7 @@ index 19f79605..6276985f 100644 bitmap_init (&bm, blksize, 2 /* bits per block */); diff --git a/filters/cache/cache.c b/filters/cache/cache.c -index 8af52106..48a20c3b 100644 +index 44da0008..109ac89e 100644 --- a/filters/cache/cache.c +++ b/filters/cache/cache.c @@ -40,6 +40,7 @@ @@ -152,7 +152,7 @@ index a559adef..5c32c37c 100644 extern int64_t max_size; extern unsigned hi_thresh, lo_thresh; diff --git a/filters/cache/nbdkit-cache-filter.pod b/filters/cache/nbdkit-cache-filter.pod -index 2ac307e0..9511e91b 100644 +index f20cb9ce..6cbd1c08 100644 --- a/filters/cache/nbdkit-cache-filter.pod +++ b/filters/cache/nbdkit-cache-filter.pod @@ -5,6 +5,7 @@ nbdkit-cache-filter - nbdkit caching filter diff --git a/0005-ocaml-Fix-comment-on-plugin-.pread-field.patch b/0005-ocaml-Fix-comment-on-plugin-.pread-field.patch deleted file mode 100644 index 65f165a..0000000 --- a/0005-ocaml-Fix-comment-on-plugin-.pread-field.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 229f106d65e2a54aa21afde9182b0e110a83b0df Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Thu, 15 Jul 2021 20:41:03 +0100 -Subject: [PATCH] ocaml: Fix comment on plugin .pread field - -Incorrectly updated in earlier commit. - -Fixes: commit e54e16e81c51dcbb16d70d83c5b0403babdf5f99 -(cherry picked from commit b42144fc3eb6869d3a3424036877f206c6c5f2b9) ---- - plugins/ocaml/NBDKit.mli | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/plugins/ocaml/NBDKit.mli b/plugins/ocaml/NBDKit.mli -index cda09f44..0f7b87e9 100644 ---- a/plugins/ocaml/NBDKit.mli -+++ b/plugins/ocaml/NBDKit.mli -@@ -106,7 +106,7 @@ type 'a plugin = { - is_rotational : ('a -> bool) option; - - (* Serving data. *) -- pread : ('a -> int32 -> int64 -> flags -> string) option; (* required field *) -+ pread : ('a -> int32 -> int64 -> flags -> string) option;(** required field *) - pwrite : ('a -> string -> int64 -> flags -> unit) option; - flush : ('a -> flags -> unit) option; - trim : ('a -> int32 -> int64 -> flags -> unit) option; --- -2.31.1 - diff --git a/0017-cache-cow-Use-a-64K-block-size-by-default.patch b/0006-cache-cow-Use-a-64K-block-size-by-default.patch similarity index 97% rename from 0017-cache-cow-Use-a-64K-block-size-by-default.patch rename to 0006-cache-cow-Use-a-64K-block-size-by-default.patch index 44d09b3..ba02c9e 100644 --- a/0017-cache-cow-Use-a-64K-block-size-by-default.patch +++ b/0006-cache-cow-Use-a-64K-block-size-by-default.patch @@ -1,4 +1,4 @@ -From 70e0df6462c34c4946b64e172d163b58121cf424 Mon Sep 17 00:00:00 2001 +From e0f76fe019449c81297de39ddd6a12006d94481a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 26 Jul 2021 17:39:23 +0100 Subject: [PATCH] cache, cow: Use a 64K block size by default @@ -19,7 +19,7 @@ cannot be adjusted. 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/filters/cache/cache.c b/filters/cache/cache.c -index 48a20c3b..f7b01039 100644 +index 109ac89e..c912c5fb 100644 --- a/filters/cache/cache.c +++ b/filters/cache/cache.c @@ -73,7 +73,7 @@ @@ -32,7 +32,7 @@ index 48a20c3b..f7b01039 100644 int64_t max_size = -1; unsigned hi_thresh = 95, lo_thresh = 80; diff --git a/filters/cache/nbdkit-cache-filter.pod b/filters/cache/nbdkit-cache-filter.pod -index 9511e91b..99707373 100644 +index 6cbd1c08..df9c1f99 100644 --- a/filters/cache/nbdkit-cache-filter.pod +++ b/filters/cache/nbdkit-cache-filter.pod @@ -65,8 +65,8 @@ or can cheaply reconstruct. diff --git a/0006-docs-Correct-selinux-label-example.patch b/0006-docs-Correct-selinux-label-example.patch deleted file mode 100644 index abc81a3..0000000 --- a/0006-docs-Correct-selinux-label-example.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 8c86f8bbc326ff1578989a03b3c98b06634f62c1 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Thu, 22 Jul 2021 16:31:34 +0100 -Subject: [PATCH] docs: Correct --selinux-label example - -The actual label you should use for the internal socket is -system_u:object_r:svirt_socket_t:s0 (not svirt_t). - -The filesystem label is different and was not documented before, so -this is added. - -See also: -https://bugzilla.redhat.com/show_bug.cgi?id=1984938 - -(cherry picked from commit 835762d1c68e30f650032bc8d8280e6140d8e46f) ---- - docs/nbdkit.pod | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/docs/nbdkit.pod b/docs/nbdkit.pod -index 68399eca..5b679895 100644 ---- a/docs/nbdkit.pod -+++ b/docs/nbdkit.pod -@@ -377,9 +377,11 @@ socket. - - The common — perhaps only — use of this option is to allow libvirt - guests which are using SELinux and sVirt confinement to access nbdkit --Unix domain sockets: -+Unix domain sockets. The example below shows how to do this. Note -+that the socket and filesystem labels are different. - -- nbdkit --selinux-label system_u:object_r:svirt_t:s0 ... -+ nbdkit -U /tmp/sock --selinux-label=system_u:object_r:svirt_socket_t:s0 ... -+ chcon system_u:object_r:svirt_image_t:s0 /tmp/sock - - =item B<--swap> - --- -2.31.1 - diff --git a/0018-cache-Refactor-printing-state-into-new-function.patch b/0007-cache-Refactor-printing-state-into-new-function.patch similarity index 95% rename from 0018-cache-Refactor-printing-state-into-new-function.patch rename to 0007-cache-Refactor-printing-state-into-new-function.patch index 59401dc..80de09f 100644 --- a/0018-cache-Refactor-printing-state-into-new-function.patch +++ b/0007-cache-Refactor-printing-state-into-new-function.patch @@ -1,4 +1,4 @@ -From 9cf300962b9f453972deaf744c202327c42970db Mon Sep 17 00:00:00 2001 +From 9b4f5045c92f6a666c8d4b08379c34fb8e677dcd Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 27 Jul 2021 21:16:30 +0100 Subject: [PATCH] cache: Refactor printing state into new function diff --git a/0007-cow-Fix-assert-failure-in-cow_extents.patch b/0007-cow-Fix-assert-failure-in-cow_extents.patch deleted file mode 100644 index a13aa16..0000000 --- a/0007-cow-Fix-assert-failure-in-cow_extents.patch +++ /dev/null @@ -1,148 +0,0 @@ -From c0c0728f40466cf4a8ab4868002e331df6d85b1e Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sat, 24 Jul 2021 13:30:55 +0100 -Subject: [PATCH] cow: Fix assert failure in cow_extents - -$ nbdkit sparse-random 4G --filter=cow --run 'nbdinfo --map $uri' -nbdkit: cow.c:591: cow_extents: Assertion `count > 0' failed. - -nbdinfo calls us with count = 0xfffffe00 [1] stored in a 32 bit -quantity. This was rounded up to the next block boundary and so -overflows (count becomes 0, hence the assertion). - -Use a 64 bit variable for count to allow rounding up. This requires -further changes as a further 32 bit variable must not be allowed to -overflow. - -This also adds a regression test. - -[1] UINT32_MAX - 512 + 1 from: -https://gitlab.com/nbdkit/libnbd/-/blob/c55c5d9960809efd27cd044d007a33ea1636f4b0/info/map.c#L64 - -(cherry picked from commit 4d66ab72b29fc56190c7a6368eff3a6ba94c0f9f) ---- - filters/cow/cow.c | 16 +++++++++--- - tests/Makefile.am | 2 ++ - tests/test-cow-extents-large.sh | 46 +++++++++++++++++++++++++++++++++ - 3 files changed, 61 insertions(+), 3 deletions(-) - create mode 100755 tests/test-cow-extents-large.sh - -diff --git a/filters/cow/cow.c b/filters/cow/cow.c -index 83844845..3bd09399 100644 ---- a/filters/cow/cow.c -+++ b/filters/cow/cow.c -@@ -571,19 +571,23 @@ cow_cache (nbdkit_next *next, - /* Extents. */ - static int - cow_extents (nbdkit_next *next, -- void *handle, uint32_t count, uint64_t offset, uint32_t flags, -+ void *handle, uint32_t count32, uint64_t offset, uint32_t flags, - struct nbdkit_extents *extents, int *err) - { - const bool can_extents = next->can_extents (next); - const bool req_one = flags & NBDKIT_FLAG_REQ_ONE; -+ uint64_t count = count32; - uint64_t end; - uint64_t blknum; - -- /* To make this easier, align the requested extents to whole blocks. */ -+ /* To make this easier, align the requested extents to whole blocks. -+ * Note that count is a 64 bit variable containing at most a 32 bit -+ * value so rounding up is safe here. -+ */ - end = offset + count; - offset = ROUND_DOWN (offset, BLKSIZE); - end = ROUND_UP (end, BLKSIZE); -- count = end - offset; -+ count = end - offset; - blknum = offset / BLKSIZE; - - assert (IS_ALIGNED (offset, BLKSIZE)); -@@ -628,6 +632,12 @@ cow_extents (nbdkit_next *next, - * as we can. - */ - for (;;) { -+ /* nbdkit_extents_full cannot read more than a 32 bit range -+ * (range_count), but count is a 64 bit quantity, so don't -+ * overflow range_count here. -+ */ -+ if (range_count >= UINT32_MAX - BLKSIZE + 1) break; -+ - blknum++; - offset += BLKSIZE; - count -= BLKSIZE; -diff --git a/tests/Makefile.am b/tests/Makefile.am -index e0b31ba9..9630205d 100644 ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -1402,6 +1402,7 @@ TESTS += \ - test-cow.sh \ - test-cow-extents1.sh \ - test-cow-extents2.sh \ -+ test-cow-extents-large.sh \ - test-cow-unaligned.sh \ - $(NULL) - endif -@@ -1410,6 +1411,7 @@ EXTRA_DIST += \ - test-cow.sh \ - test-cow-extents1.sh \ - test-cow-extents2.sh \ -+ test-cow-extents-large.sh \ - test-cow-null.sh \ - test-cow-unaligned.sh \ - $(NULL) -diff --git a/tests/test-cow-extents-large.sh b/tests/test-cow-extents-large.sh -new file mode 100755 -index 00000000..ea981dcb ---- /dev/null -+++ b/tests/test-cow-extents-large.sh -@@ -0,0 +1,46 @@ -+#!/usr/bin/env bash -+# nbdkit -+# Copyright (C) 2018-2021 Red Hat Inc. -+# -+# Redistribution and use in source and binary forms, with or without -+# modification, are permitted provided that the following conditions are -+# met: -+# -+# * Redistributions of source code must retain the above copyright -+# notice, this list of conditions and the following disclaimer. -+# -+# * Redistributions in binary form must reproduce the above copyright -+# notice, this list of conditions and the following disclaimer in the -+# documentation and/or other materials provided with the distribution. -+# -+# * Neither the name of Red Hat nor the names of its contributors may be -+# used to endorse or promote products derived from this software without -+# specific prior written permission. -+# -+# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND -+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR -+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -+# SUCH DAMAGE. -+ -+# Regression test of an earlier overflow in cow_extents. -+# https://listman.redhat.com/archives/libguestfs/2021-July/msg00037.html -+ -+source ./functions.sh -+set -e -+set -x -+ -+requires_filter cow -+requires_plugin sparse-random -+requires nbdinfo --version -+ -+for size in 0 3G 4G 5G 8G; do -+ nbdkit -U - sparse-random $size --filter=cow --run 'nbdinfo --map $uri' -+done --- -2.31.1 - diff --git a/0008-cache-Fix-misleading-LRU-diagram-and-comment.patch b/0008-cache-Fix-misleading-LRU-diagram-and-comment.patch deleted file mode 100644 index c694555..0000000 --- a/0008-cache-Fix-misleading-LRU-diagram-and-comment.patch +++ /dev/null @@ -1,79 +0,0 @@ -From b436ca6c69ef7d8d826be609820027f10134274d Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 27 Jul 2021 21:28:48 +0100 -Subject: [PATCH] cache: Fix misleading LRU diagram and comment - -Only comment changes. - -(cherry picked from commit 7b33c86e0910d941dc34bdb481d61806f31cdcef) ---- - filters/cache/lru.c | 32 ++++++++++++++++++++------------ - 1 file changed, 20 insertions(+), 12 deletions(-) - -diff --git a/filters/cache/lru.c b/filters/cache/lru.c -index 1c3c3e10..716b4984 100644 ---- a/filters/cache/lru.c -+++ b/filters/cache/lru.c -@@ -53,12 +53,14 @@ - - /* LRU bitmaps. These bitmaps implement a simple, fast LRU structure. - * -- * bm[0] bm[1] blocks not in either bitmap -- * ┌─────────┬──────────────────┬─────────────────────────────┐ -- * │ │ │ │ -- * └─────────┴──────────────────┴─────────────────────────────┘ -- * ↑ c1 bits set -- * c0 bits set -+ * bm[0] -+ * ┌───────────────────────┐ -+ * │ X XX X XXX │ c0 bits set -+ * └───────────────────────┘ -+ * bm[1] -+ * ┌───────────────────────┐ -+ * │ X XX X X │ c1 bits set -+ * └───────────────────────┘ - * - * The LRU structure keeps track of the [approx] last N distinct - * blocks which have been most recently accessed. It can answer in -@@ -69,8 +71,7 @@ - * - * When a new block is accessed, we set the corresponding bit in bm[0] - * and increment c0 (c0 counts the number of bits set in bm[0]). If -- * c0 == N/2 then we swap the two bitmaps, clear bm[0], and reset c0 -- * to 0. -+ * c0 == N/2 then we move bm[1] <- bm[0], clear bm[0] and set c0 <- 0. - * - * To check if a block has been accessed within the previous N - * distinct accesses, we simply have to check both bitmaps. If it is -@@ -78,9 +79,11 @@ - * reclaimed. - * - * You'll note that in fact we only keep track of between N/2 and N -- * recently accessed blocks. We could make the estimate more accurate -- * by having more bitmaps, but as this is only a heuristic we choose -- * to keep the implementation simple and memory usage low instead. -+ * recently accessed blocks because the same block can appear in both -+ * bitmaps. bm[1] is a last chance to hold on to blocks which are -+ * soon to be reclaimed. We could make the estimate more accurate by -+ * having more bitmaps, but as this is only a heuristic we choose to -+ * keep the implementation simple and memory usage low instead. - */ - static struct bitmap bm[2]; - static unsigned c0 = 0, c1 = 0; -@@ -129,7 +132,12 @@ lru_set_recently_accessed (uint64_t blknum) - bitmap_set_blk (&bm[0], blknum, true); - c0++; - -- /* If we've reached N/2 then we need to swap over the bitmaps. */ -+ /* If we've reached N/2 then we need to swap over the bitmaps. Note -+ * the purpose of swapping here is to ensure that we do not have to -+ * copy the dynamically allocated bm->bitmap field (the pointers are -+ * swapped instead). The bm[0].bitmap field is immediately zeroed -+ * after the swap. -+ */ - if (c0 >= N/2) { - struct bitmap tmp; - --- -2.31.1 - diff --git a/0019-tests-cache-Test-cache-on-read-option-really-caches.patch b/0008-tests-cache-Test-cache-on-read-option-really-caches.patch similarity index 98% rename from 0019-tests-cache-Test-cache-on-read-option-really-caches.patch rename to 0008-tests-cache-Test-cache-on-read-option-really-caches.patch index 1c8f34c..c851232 100644 --- a/0019-tests-cache-Test-cache-on-read-option-really-caches.patch +++ b/0008-tests-cache-Test-cache-on-read-option-really-caches.patch @@ -1,4 +1,4 @@ -From a203296a125ce6a28d1d73d248f0899754c3677c Mon Sep 17 00:00:00 2001 +From fcd113cf7bf5587f8cac6d331ec1e427be0a830f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 29 Jul 2021 20:16:43 +0100 Subject: [PATCH] tests: cache: Test cache-on-read option really caches diff --git a/0020-cow-Implement-cow-on-read.patch b/0009-cow-Implement-cow-on-read.patch similarity index 98% rename from 0020-cow-Implement-cow-on-read.patch rename to 0009-cow-Implement-cow-on-read.patch index 5578f1f..041364c 100644 --- a/0020-cow-Implement-cow-on-read.patch +++ b/0009-cow-Implement-cow-on-read.patch @@ -1,4 +1,4 @@ -From 330a2b99378c5bb6c57ab8ffb8069d21e64d5312 Mon Sep 17 00:00:00 2001 +From e7ff9f833cc11e47db90868a02fee95900f62a84 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 27 Jul 2021 23:01:52 +0100 Subject: [PATCH] cow: Implement cow-on-read @@ -95,7 +95,7 @@ index 1bc85283..b7e6f092 100644 /* Cache mode for blocks not already in overlay */ enum cache_mode { diff --git a/filters/cow/cow.c b/filters/cow/cow.c -index f74c0a34..74fcd61c 100644 +index e939f23f..6ad42eec 100644 --- a/filters/cow/cow.c +++ b/filters/cow/cow.c @@ -38,6 +38,7 @@ @@ -224,7 +224,7 @@ index f74c0a34..74fcd61c 100644 - r = blk_read (next, blknum, block, err); + r = blk_read (next, blknum, block, cow_on_read (), err); if (r != -1) { - memset (&block[count], 0, BLKSIZE - count); + memset (block, 0, count); r = blk_write (blknum, block, err); @@ -455,7 +491,7 @@ cow_trim (nbdkit_next *next, * Hold the lock over the whole operation. @@ -242,10 +242,10 @@ index f74c0a34..74fcd61c 100644 - r = blk_read (next, blknum, block, err); + r = blk_read (next, blknum, block, cow_on_read (), err); if (r != -1) { - memset (&block[count], 0, BLKSIZE - count); + memset (block, 0, count); r = blk_write (blknum, block, err); diff --git a/filters/cow/nbdkit-cow-filter.pod b/filters/cow/nbdkit-cow-filter.pod -index 2a693ebe..6366d8a8 100644 +index 571189e7..01261429 100644 --- a/filters/cow/nbdkit-cow-filter.pod +++ b/filters/cow/nbdkit-cow-filter.pod @@ -62,6 +62,23 @@ the data from the plugin into the overlay. diff --git a/0009-docs-Improve-documentation-of-.can_cache-and-.cache-.patch b/0009-docs-Improve-documentation-of-.can_cache-and-.cache-.patch deleted file mode 100644 index ad9a6b8..0000000 --- a/0009-docs-Improve-documentation-of-.can_cache-and-.cache-.patch +++ /dev/null @@ -1,104 +0,0 @@ -From b6e1d14a052caf65dcc7e8fec2bf0d079e1f8a38 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 27 Jul 2021 22:42:52 +0100 -Subject: [PATCH] docs: Improve documentation of .can_cache and .cache methods - -(cherry picked from commit 0a6be5ae01a6079767e1fabd70cca73fc8520b1d) ---- - docs/nbdkit-plugin.pod | 71 +++++++++++++++++++++++++----------------- - 1 file changed, 43 insertions(+), 28 deletions(-) - -diff --git a/docs/nbdkit-plugin.pod b/docs/nbdkit-plugin.pod -index 7a1fae8c..5e085e12 100644 ---- a/docs/nbdkit-plugin.pod -+++ b/docs/nbdkit-plugin.pod -@@ -1047,19 +1047,29 @@ This callback is not required. If omitted, then we return false. - int can_cache (void *handle); - - This is called during the option negotiation phase to find out if the --plugin supports a cache operation. The nature of the caching is --unspecified (including whether there are limits on how much can be --cached at once, and whether writes to a cached region have --write-through or write-back semantics), but the command exists to let --clients issue a hint to the server that they will be accessing that --region of the export. -- --If this returns C, cache support is not advertised --to the client; if this returns C, caching is --emulated by the server calling C<.pread> and ignoring the results; if --this returns C, then the C<.cache> callback will --be used. If there is an error, C<.can_cache> should call --C with an error message and return C<-1>. -+plugin supports a cache or prefetch operation. -+ -+This can return: -+ -+=over 4 -+ -+=item C -+ -+Cache support is not advertised to the client. -+ -+=item C -+ -+Caching is emulated by the server calling C<.pread> and discarding the -+result. -+ -+=item C -+ -+The C<.cache> callback will be called. -+ -+=back -+ -+If there is an error, C<.can_cache> should call C with -+an error message and return C<-1>. - - This callback is not required. If omitted, then we return - C if the C<.cache> callback is missing, or -@@ -1284,23 +1294,28 @@ called. C will be set to a suitable value. - - During the data serving phase, this callback is used to give the - plugin a hint that the client intends to make further accesses to the --given region of the export. The nature of caching is not specified --further by the NBD specification (for example, a server may place --limits on how much may be cached at once, and there is no way to --control if writes to a cached area have write-through or write-back --semantics). In fact, the cache command can always fail and still be --compliant, and success might not guarantee a performance gain. If --this callback is omitted, then the results of C<.can_cache> determine --whether nbdkit will reject cache requests, treat them as instant --success, or emulate caching by calling C<.pread> over the same region --and ignoring the results. -+given region of the export. -+ -+The nature of caching/prefetching is not specified further by the NBD -+specification. For example, a server may place limits on how much may -+be cached at once, and there is no way to control if writes to a -+cached area have write-through or write-back semantics. In fact, the -+cache command can always fail and still be compliant, and success -+might not guarantee a performance gain. -+ -+If this callback is omitted, then the results of C<.can_cache> -+determine whether nbdkit will reject cache requests, treat them as -+instant success, or emulate caching by calling C<.pread> over the same -+region and ignoring the results. - - This function will not be called if C<.can_cache> did not return --C. The parameter C exists in case of --future NBD protocol extensions; at this time, it will be 0 on input. A --plugin must fail this function if C includes an unrecognized --flag, as that may indicate a requirement that the plugin comply must --with a specific caching semantic. -+C. -+ -+The C parameter exists in case of future NBD protocol -+extensions; at this time, it will be 0 on input. A plugin must fail -+this function if C includes an unrecognized flag, as that may -+indicate a requirement that the plugin comply must with a specific -+caching semantic. - - If there is an error, C<.cache> should call C with an - error message, and C to record an appropriate error --- -2.31.1 - diff --git a/0010-cow-Improve-documentation-of-cow-on-cache-option.patch b/0010-cow-Improve-documentation-of-cow-on-cache-option.patch deleted file mode 100644 index 2996f0b..0000000 --- a/0010-cow-Improve-documentation-of-cow-on-cache-option.patch +++ /dev/null @@ -1,37 +0,0 @@ -From ef0ee0166b0594b04c73376f84a729c2985ca064 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 27 Jul 2021 23:10:24 +0100 -Subject: [PATCH] cow: Improve documentation of cow-on-cache option - -(cherry picked from commit 9731e80d58c3aed2514d249e7925c2053d6eb0e8) ---- - filters/cow/nbdkit-cow-filter.pod | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) - -diff --git a/filters/cow/nbdkit-cow-filter.pod b/filters/cow/nbdkit-cow-filter.pod -index 64df3fbd..2a693ebe 100644 ---- a/filters/cow/nbdkit-cow-filter.pod -+++ b/filters/cow/nbdkit-cow-filter.pod -@@ -54,12 +54,13 @@ serve the same data to each client. - - =item B - --Treat a client cache request as a shortcut for copying unmodified data --from the plugin to the overlay, rather than the default of passing --cache requests on to the plugin. This parameter defaults to false --(which leaves the overlay as small as possible), but setting it can be --useful for converting cache commands into a form of copy-on-read --behavior, in addition to the filter's normal copy-on-write semantics. -+When the client issues a cache (prefetch) request, preemptively save -+the data from the plugin into the overlay. -+ -+=item B -+ -+Do not save data from cache (prefetch) requests in the overlay. This -+leaves the overlay as small as possible. This is the default. - - =back - --- -2.31.1 - diff --git a/0021-delay-Add-delay-open-and-delay-close.patch b/0010-delay-Add-delay-open-and-delay-close.patch similarity index 98% rename from 0021-delay-Add-delay-open-and-delay-close.patch rename to 0010-delay-Add-delay-open-and-delay-close.patch index 43910a8..f0e34de 100644 --- a/0021-delay-Add-delay-open-and-delay-close.patch +++ b/0010-delay-Add-delay-open-and-delay-close.patch @@ -1,4 +1,4 @@ -From f1fa60f1388bf177ebd83625cc13a164936a187c Mon Sep 17 00:00:00 2001 +From a37d5a2176af0362ad3e4234fe1fc14a47978261 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 30 Jul 2021 10:19:57 +0100 Subject: [PATCH] delay: Add delay-open and delay-close diff --git a/0011-python-Implement-.cleanup-method.patch b/0011-python-Implement-.cleanup-method.patch new file mode 100644 index 0000000..1d37926 --- /dev/null +++ b/0011-python-Implement-.cleanup-method.patch @@ -0,0 +1,90 @@ +From 77310049efc37daaf7bd993298000f8f3638497e Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 3 Aug 2021 14:19:38 +0100 +Subject: [PATCH] python: Implement .cleanup() method + +(cherry picked from commit f2fe99e4b0f54467ab8028eaf2d039cf918b2961) +--- + plugins/python/nbdkit-python-plugin.pod | 20 +++++++++++++++++--- + plugins/python/plugin.c | 19 +++++++++++++++++++ + 2 files changed, 36 insertions(+), 3 deletions(-) + +diff --git a/plugins/python/nbdkit-python-plugin.pod b/plugins/python/nbdkit-python-plugin.pod +index 6f5f2c00..a92a557f 100644 +--- a/plugins/python/nbdkit-python-plugin.pod ++++ b/plugins/python/nbdkit-python-plugin.pod +@@ -257,6 +257,12 @@ There are no arguments or return value. + + There are no arguments or return value. + ++=item C ++ ++(Optional, nbdkit E 1.28) ++ ++There are no arguments or return value. ++ + =item C + + (Optional) +@@ -498,10 +504,18 @@ optionally using C first. + + =over 4 + +-=item Missing: C and C ++=item Missing: C + +-These are not needed because you can just use ordinary Python +-constructs. ++This is not needed since you can use regular Python mechanisms like ++top level statements to run code when the module is loaded. ++ ++=item Missing: C ++ ++This is missing, but in nbdkit E 1.28 you can put code in the ++C function to have it run when nbdkit exits. In earlier ++versions of nbdkit, using a Python ++L handler is ++recommended. + + =item Missing: + C, +diff --git a/plugins/python/plugin.c b/plugins/python/plugin.c +index 64430a1a..f85512b4 100644 +--- a/plugins/python/plugin.c ++++ b/plugins/python/plugin.c +@@ -298,6 +298,24 @@ py_after_fork (void) + return 0; + } + ++static void ++py_cleanup (void) ++{ ++ ACQUIRE_PYTHON_GIL_FOR_CURRENT_SCOPE; ++ PyObject *fn; ++ PyObject *r; ++ ++ if (callback_defined ("cleanup", &fn)) { ++ PyErr_Clear (); ++ ++ r = PyObject_CallObject (fn, NULL); ++ Py_DECREF (fn); ++ if (check_python_failure ("cleanup") == -1) ++ return; ++ Py_DECREF (r); ++ } ++} ++ + static int + py_list_exports (int readonly, int is_tls, struct nbdkit_exports *exports) + { +@@ -1039,6 +1057,7 @@ static struct nbdkit_plugin plugin = { + .thread_model = py_thread_model, + .get_ready = py_get_ready, + .after_fork = py_after_fork, ++ .cleanup = py_cleanup, + .list_exports = py_list_exports, + .default_export = py_default_export, + +-- +2.31.1 + diff --git a/0011-tests-cache-Simplify-test-cache-on-read.sh.patch b/0011-tests-cache-Simplify-test-cache-on-read.sh.patch deleted file mode 100644 index f2e0b9e..0000000 --- a/0011-tests-cache-Simplify-test-cache-on-read.sh.patch +++ /dev/null @@ -1,40 +0,0 @@ -From a09b06f2c104c01d7b0ff5e657c0c64bf1c4cc41 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Thu, 29 Jul 2021 20:14:24 +0100 -Subject: [PATCH] tests: cache: Simplify test-cache-on-read.sh - -We can use the memory plugin instead of a backing file. - -(cherry picked from commit 5527b28e323b7c9c35af8e1bb6b05e6468e68950) ---- - tests/test-cache-on-read.sh | 8 ++------ - 1 file changed, 2 insertions(+), 6 deletions(-) - -diff --git a/tests/test-cache-on-read.sh b/tests/test-cache-on-read.sh -index 3b3c7657..f8584dcd 100755 ---- a/tests/test-cache-on-read.sh -+++ b/tests/test-cache-on-read.sh -@@ -38,18 +38,14 @@ requires_filter cache - requires_nbdsh_uri - - sock=$(mktemp -u /tmp/nbdkit-test-sock.XXXXXX) --files="cache-on-read.img $sock cache-on-read.pid" -+files="$sock cache-on-read.pid" - rm -f $files - cleanup_fn rm -f $files - --# Create an empty base image. --truncate -s 128K cache-on-read.img -- - # Run nbdkit with the caching filter and cache-on-read set. - start_nbdkit -P cache-on-read.pid -U $sock \ - --filter=cache \ -- file cache-on-read.img \ -- cache-on-read=true -+ memory 128K cache-on-read=true - - nbdsh --connect "nbd+unix://?socket=$sock" \ - -c ' --- -2.31.1 - diff --git a/nbdkit.spec b/nbdkit.spec index 7670b29..11f3b14 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -50,8 +50,8 @@ ExclusiveArch: x86_64 %global source_directory 1.26-stable Name: nbdkit -Version: 1.26.2 -Release: 2%{?dist} +Version: 1.26.3 +Release: 1%{?dist} Summary: NBD server License: BSD @@ -76,27 +76,17 @@ Source3: copy-patches.sh # https://gitlab.com/nbdkit/nbdkit/-/commits/rhel-9.0/ # Patches. -Patch0001: 0001-ocaml-Call-caml_shutdown-when-unloading-the-plugin.patch -Patch0002: 0002-ocaml-Fix-valgrinding-by-only-ignoring-caml_stat_all.patch -Patch0003: 0003-ocaml-tests-Actually-call-.get_ready-method-in-test-.patch -Patch0004: 0004-ocaml-Rearrange-the-callbacks.patch -Patch0005: 0005-ocaml-Fix-comment-on-plugin-.pread-field.patch -Patch0006: 0006-docs-Correct-selinux-label-example.patch -Patch0007: 0007-cow-Fix-assert-failure-in-cow_extents.patch -Patch0008: 0008-cache-Fix-misleading-LRU-diagram-and-comment.patch -Patch0009: 0009-docs-Improve-documentation-of-.can_cache-and-.cache-.patch -Patch0010: 0010-cow-Improve-documentation-of-cow-on-cache-option.patch -Patch0011: 0011-tests-cache-Simplify-test-cache-on-read.sh.patch -Patch0012: 0012-cache-Reduce-verbosity-of-debugging.patch -Patch0013: 0013-cache-cow-Add-blk_read_multiple-function.patch -Patch0014: 0014-cache-cow-Use-full-pread-pwrite-operations.patch -Patch0015: 0015-cache-Implement-cache-on-read-PATH.patch -Patch0016: 0016-cache-Add-cache-min-block-size-parameter.patch -Patch0017: 0017-cache-cow-Use-a-64K-block-size-by-default.patch -Patch0018: 0018-cache-Refactor-printing-state-into-new-function.patch -Patch0019: 0019-tests-cache-Test-cache-on-read-option-really-caches.patch -Patch0020: 0020-cow-Implement-cow-on-read.patch -Patch0021: 0021-delay-Add-delay-open-and-delay-close.patch +Patch0001: 0001-cache-Reduce-verbosity-of-debugging.patch +Patch0002: 0002-cache-cow-Add-blk_read_multiple-function.patch +Patch0003: 0003-cache-cow-Use-full-pread-pwrite-operations.patch +Patch0004: 0004-cache-Implement-cache-on-read-PATH.patch +Patch0005: 0005-cache-Add-cache-min-block-size-parameter.patch +Patch0006: 0006-cache-cow-Use-a-64K-block-size-by-default.patch +Patch0007: 0007-cache-Refactor-printing-state-into-new-function.patch +Patch0008: 0008-tests-cache-Test-cache-on-read-option-really-caches.patch +Patch0009: 0009-cow-Implement-cow-on-read.patch +Patch0010: 0010-delay-Add-delay-open-and-delay-close.patch +Patch0011: 0011-python-Implement-.cleanup-method.patch BuildRequires: make %if 0%{patches_touch_autotools} @@ -1267,6 +1257,13 @@ export LIBGUESTFS_TRACE=1 %changelog +* Thu Aug 05 2021 Richard W.M. Jones - 1.26.3-1 +- New upstream stable version 1.26.3. + resolves: rhbz#1950632 +- Add Python .cleanup() method. +- Fix data corruption in zero and trim on unaligned tail. + resolves: rhbz#1990134 + * Fri Jul 30 2021 Richard W.M. Jones - 1.26.2-2 - More efficient cache and cow filters. - Add nbdkit-cow-filter cow-on-read option. diff --git a/sources b/sources index 7f6f945..6b4b5c9 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (nbdkit-1.26.2.tar.gz) = c46da59e27f06036527b50d758c423d12da92b0c515b0df7986f44a4a543e3e825653eaf4ab8267f8cc9b2e04e3c42bad25800a0a8bd5f022083b6c9e511c3ca -SHA512 (nbdkit-1.26.2.tar.gz.sig) = 830836b684c8d2bb81d531826301dc4206cc65f1091b7759ca0a5f8cbf18c9d77d6ecf7d1e7782e2fe30ccc66a731c968028917d6a00db1d73f447694b006499 +SHA512 (nbdkit-1.26.3.tar.gz) = 7a85b1f35aabbe9cf9f5b45f2cd6458df1e7acf25b4753cfeae13196cd16d83c8d91b491d3f4b4ee24f567f8432a82e1ddda0c3c4a145429eefe43e68aa9f0c7 +SHA512 (nbdkit-1.26.3.tar.gz.sig) = 34c61897a8f36a53f88c062de5da42ef12c21f43e6fe39b874da3c862be2e86ef075b02bd079195d91da43bd7aced126ae4e4d7763152329ff38ceee3906423c