diff --git a/.gitignore b/.gitignore index 3990bd5..b6925b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ SOURCES/libguestfs.keyring -SOURCES/nbdkit-1.38.3.tar.gz +SOURCES/nbdkit-1.38.5.tar.gz diff --git a/.nbdkit.metadata b/.nbdkit.metadata index c2dc5eb..8f4664f 100644 --- a/.nbdkit.metadata +++ b/.nbdkit.metadata @@ -1,2 +1,2 @@ cc1b37b9cfafa515aab3eefd345ecc59aac2ce7b SOURCES/libguestfs.keyring -442637a8da4527c50f9bac0762c31276c2d00796 SOURCES/nbdkit-1.38.3.tar.gz +c70e24853a2bd5eee4546014991a9487c2a4dcdb SOURCES/nbdkit-1.38.5.tar.gz diff --git a/SOURCES/0001-nbdkit-1.38-Fix-inclusion-of-gnutls-socket.h-with-ol.patch b/SOURCES/0001-nbdkit-1.38-Fix-inclusion-of-gnutls-socket.h-with-ol.patch deleted file mode 100644 index de950ec..0000000 --- a/SOURCES/0001-nbdkit-1.38-Fix-inclusion-of-gnutls-socket.h-with-ol.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 14a2646d4221d50b4b194d5dd2d6010808ea642b Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sun, 14 Jul 2024 09:50:31 +0100 -Subject: [PATCH] nbdkit 1.38: Fix inclusion of with old - gnutls - -Development branch commit 8ce65bac5a ("build: Move to minimum gnutls ->= 3.5.18") changed the way that is included. I -didn't cherry pick this commit to the stable-1.38 branch since we -don't want to force people to update gnutls. - -However when I cherry picked commit 47987e43bd ("server/crypto.c: -Check works before including it"), I missed that -there was still a place where was included (which -would have been fixed by the commit above). - -The upshot is that compilation of nbdkit 1.38.3 fails on mingw: - -In file included from ../../server/crypto.c:69: -/usr/i686-w64-mingw32/sys-root/mingw/include/gnutls/socket.h:32:10: fatal error: sys/socket.h: No such file or directory - 32 | #include - | ^~~~~~~~~~~~~~ -compilation terminated. - -Fixes: commit f889d822dd96bcf8c0427bd541d730d58b166d83 ---- - server/crypto.c | 3 --- - 1 file changed, 3 deletions(-) - -diff --git a/server/crypto.c b/server/crypto.c -index 83970282..86843192 100644 ---- a/server/crypto.c -+++ b/server/crypto.c -@@ -65,9 +65,6 @@ - #else - #define TRY_KTLS 0 - #endif --#if TRY_KTLS --#include --#endif - - static int crypto_auth; - #define CRYPTO_AUTH_CERTIFICATES 1 --- -2.47.1 - diff --git a/SOURCES/0002-server-log-Move-preserve-errno-to-log_verror-functio.patch b/SOURCES/0001-server-log-Move-preserve-errno-to-log_verror-functio.patch similarity index 98% rename from SOURCES/0002-server-log-Move-preserve-errno-to-log_verror-functio.patch rename to SOURCES/0001-server-log-Move-preserve-errno-to-log_verror-functio.patch index 705f1b2..c238183 100644 --- a/SOURCES/0002-server-log-Move-preserve-errno-to-log_verror-functio.patch +++ b/SOURCES/0001-server-log-Move-preserve-errno-to-log_verror-functio.patch @@ -1,4 +1,4 @@ -From f39c63a79ffb888bd565eb49b0ee2590fad8fbb9 Mon Sep 17 00:00:00 2001 +From e97b5ec6e7e7406688f68a5828e66ef46046fd9f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 23 Jul 2024 14:46:41 +0100 Subject: [PATCH] server: log: Move preserve errno to log_verror function diff --git a/SOURCES/0003-server-Rename-threadlocal_-set-get-_error-to-._errno.patch b/SOURCES/0002-server-Rename-threadlocal_-set-get-_error-to-._errno.patch similarity index 98% rename from SOURCES/0003-server-Rename-threadlocal_-set-get-_error-to-._errno.patch rename to SOURCES/0002-server-Rename-threadlocal_-set-get-_error-to-._errno.patch index 60f3b61..fdb9695 100644 --- a/SOURCES/0003-server-Rename-threadlocal_-set-get-_error-to-._errno.patch +++ b/SOURCES/0002-server-Rename-threadlocal_-set-get-_error-to-._errno.patch @@ -1,4 +1,4 @@ -From 179227c7d6b0677dcd1dced55881e0d024745424 Mon Sep 17 00:00:00 2001 +From ae28c97079cce7792c5954f67a418402a48ed0cf Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 24 Jul 2024 10:29:13 +0100 Subject: [PATCH] server: Rename threadlocal_{set,get}_error to .._errno diff --git a/SOURCES/0004-server-Introduce-threadlocal_-set-get-_last_error.patch b/SOURCES/0003-server-Introduce-threadlocal_-set-get-_last_error.patch similarity index 97% rename from SOURCES/0004-server-Introduce-threadlocal_-set-get-_last_error.patch rename to SOURCES/0003-server-Introduce-threadlocal_-set-get-_last_error.patch index c2c4acb..3608b77 100644 --- a/SOURCES/0004-server-Introduce-threadlocal_-set-get-_last_error.patch +++ b/SOURCES/0003-server-Introduce-threadlocal_-set-get-_last_error.patch @@ -1,4 +1,4 @@ -From 334ab902477a0e1db4d70a5c809eafe49ab1fc6e Mon Sep 17 00:00:00 2001 +From 00107f9d36fc6a1b33a1bde25e3239c520b82ab1 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 24 Jul 2024 10:37:58 +0100 Subject: [PATCH] server: Introduce threadlocal_{set,get}_last_error diff --git a/SOURCES/0005-server-Take-a-thread-local-copy-of-the-last-call-to-.patch b/SOURCES/0004-server-Take-a-thread-local-copy-of-the-last-call-to-.patch similarity index 97% rename from SOURCES/0005-server-Take-a-thread-local-copy-of-the-last-call-to-.patch rename to SOURCES/0004-server-Take-a-thread-local-copy-of-the-last-call-to-.patch index 8650238..593b818 100644 --- a/SOURCES/0005-server-Take-a-thread-local-copy-of-the-last-call-to-.patch +++ b/SOURCES/0004-server-Take-a-thread-local-copy-of-the-last-call-to-.patch @@ -1,4 +1,4 @@ -From a0e3f9d58142b8c5e7bcc9b73da60778e6503d0b Mon Sep 17 00:00:00 2001 +From 4cde9d78c4293e294f80376266cfce420f15a6ff Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 23 Jul 2024 15:28:06 +0100 Subject: [PATCH] server: Take a thread-local copy of the last call to diff --git a/SOURCES/0006-server-Send-the-last-error-to-the-NBD-client.patch b/SOURCES/0005-server-Send-the-last-error-to-the-NBD-client.patch similarity index 98% rename from SOURCES/0006-server-Send-the-last-error-to-the-NBD-client.patch rename to SOURCES/0005-server-Send-the-last-error-to-the-NBD-client.patch index 5659465..24d4cef 100644 --- a/SOURCES/0006-server-Send-the-last-error-to-the-NBD-client.patch +++ b/SOURCES/0005-server-Send-the-last-error-to-the-NBD-client.patch @@ -1,4 +1,4 @@ -From 7128144273f5355d7705e09a99aa1b2359e7e823 Mon Sep 17 00:00:00 2001 +From e121d8e1d39605043317cbdf28f60056e6681d56 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 23 Jul 2024 15:45:04 +0100 Subject: [PATCH] server: Send the last error to the NBD client @@ -92,7 +92,7 @@ index 6b3bc76f..c18d32e5 100644 /* Reply to NBD_OPT_LIST with the plugin's list of export names. diff --git a/tests/Makefile.am b/tests/Makefile.am -index 0664e109..9c321fcb 100644 +index b670fbf9..d510807c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -276,6 +276,7 @@ TESTS += \ diff --git a/SOURCES/0008-vddk-Include-stdbool.h.patch b/SOURCES/0006-vddk-Include-stdbool.h.patch similarity index 82% rename from SOURCES/0008-vddk-Include-stdbool.h.patch rename to SOURCES/0006-vddk-Include-stdbool.h.patch index 1082aea..829d183 100644 --- a/SOURCES/0008-vddk-Include-stdbool.h.patch +++ b/SOURCES/0006-vddk-Include-stdbool.h.patch @@ -1,4 +1,4 @@ -From d605868da2cb7cfd5842e5c1a70f4e419c82d0e3 Mon Sep 17 00:00:00 2001 +From 47345a7a56c343e2cd559b736df685214ed75a9b Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 6 Jan 2025 15:22:05 +0000 Subject: [PATCH] vddk: Include @@ -7,7 +7,6 @@ Since this file uses booleans. Acked-by: Eric Blake (cherry picked from commit fe855addae44e45e2344a33bd3857c561587f12e) -(cherry picked from commit 47345a7a56c343e2cd559b736df685214ed75a9b) --- plugins/vddk/worker.c | 1 + 1 file changed, 1 insertion(+) diff --git a/SOURCES/0007-tests-test-ext2-exportname.sh-Ignore-libnbd-1.8-for-.patch b/SOURCES/0007-tests-test-ext2-exportname.sh-Ignore-libnbd-1.8-for-.patch deleted file mode 100644 index 6e77013..0000000 --- a/SOURCES/0007-tests-test-ext2-exportname.sh-Ignore-libnbd-1.8-for-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From ea2fc2d273011bfe3d8be4fea0187f04ca6e3fa4 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Mon, 29 Jul 2024 13:20:24 +0100 -Subject: [PATCH] tests/test-ext2-exportname.sh: Ignore libnbd < 1.8 for this - test - -This test attempted to detect a case that happens in libnbd 1.6.2 -where an error was reported but the nbdinfo tool still exited with -EXIT_SUCCESS. However this test was wrong and a recent change to -libnbd caused it to fail visibly. - -The test was wrong because it checked the return code from cat ($?) -rather than the saved return code from nbdinfo ($st). - -libnbd commit 474a4ae6c8 ("lib: Don't overwrite error in -nbd_opt_{go,info}") changed the error message so "server replied with -error" no longer appears, which visibly broke this test. - -I chose to get rid of the incorrect test case and just skip this -entire test on libnbd < 1.8. (This skips the test on RHEL 8.) libnbd -1.8 was released over 3 years ago. - -(cherry picked from commit a67a2e1abdbde218bbaf8fca13dd62ac424e1155) ---- - tests/test-ext2-exportname.sh | 15 ++++----------- - 1 file changed, 4 insertions(+), 11 deletions(-) - -diff --git a/tests/test-ext2-exportname.sh b/tests/test-ext2-exportname.sh -index d32f07eb..ebfda13f 100755 ---- a/tests/test-ext2-exportname.sh -+++ b/tests/test-ext2-exportname.sh -@@ -39,8 +39,11 @@ requires_nbdinfo - requires_nbdsh_uri - requires nbdsh -c 'print(h.set_full_info)' - -+# nbdinfo 1.6.2 accidentally reported an error but had status 0 -+requires_libnbd_version 1.8 -+ - sock=$(mktemp -u /tmp/nbdkit-test-sock.XXXXXX) --files="$sock ext2-exportname.pid ext2-exportname.out ext2-exportname.err" -+files="$sock ext2-exportname.pid ext2-exportname.out" - rm -f $files - cleanup_fn rm -f $files - -@@ -61,16 +64,6 @@ cat ext2-exportname.out - grep disk.img ext2-exportname.out - grep 'content.*MBR' ext2-exportname.out - --# nbdinfo 1.6.2 accidentally reported an error but had status 0 --st=0 --nbdinfo nbd+unix://?socket=$sock > ext2-exportname.out \ -- 2> ext2-exportname.err || st=$? --cat ext2-exportname.out ext2-exportname.err --if test $? = 0 && ! grep "server replied with error" ext2-exportname.err; then -- echo "unexpected success" -- exit 1 --fi -- - # Test that there is no export list advertised - nbdinfo --list --json nbd+unix://?socket=$sock > ext2-exportname.out - cat ext2-exportname.out --- -2.47.1 - diff --git a/SOURCES/0009-vddk-Cache-the-disk-size-in-the-handle.patch b/SOURCES/0007-vddk-Cache-the-disk-size-in-the-handle.patch similarity index 88% rename from SOURCES/0009-vddk-Cache-the-disk-size-in-the-handle.patch rename to SOURCES/0007-vddk-Cache-the-disk-size-in-the-handle.patch index d997e19..9b3f1e2 100644 --- a/SOURCES/0009-vddk-Cache-the-disk-size-in-the-handle.patch +++ b/SOURCES/0007-vddk-Cache-the-disk-size-in-the-handle.patch @@ -1,4 +1,4 @@ -From 05b40b982880ec05ee1e333fd9bb4966e5e31cb9 Mon Sep 17 00:00:00 2001 +From 927cb4063da464aa2605ae87d1b1157146551a47 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 6 Jan 2025 16:47:55 +0000 Subject: [PATCH] vddk: Cache the disk size in the handle @@ -8,17 +8,16 @@ size (in bytes) available in the handle. Acked-by: Eric Blake (cherry picked from commit 2ba76db4a048471e997e508715081a70356f94f3) -(cherry picked from commit 927cb4063da464aa2605ae87d1b1157146551a47) --- plugins/vddk/vddk.c | 6 +++--- plugins/vddk/vddk.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c -index d9fd7186..1175865d 100644 +index 27d53bd6..2a787453 100644 --- a/plugins/vddk/vddk.c +++ b/plugins/vddk/vddk.c -@@ -862,19 +862,19 @@ vddk_get_size (void *handle) +@@ -875,19 +875,19 @@ vddk_get_size (void *handle) { struct vddk_handle *h = handle; VixDiskLibInfo *info; diff --git a/SOURCES/0010-vddk-do_extents-Mark-some-local-variables-const.patch b/SOURCES/0008-vddk-do_extents-Mark-some-local-variables-const.patch similarity index 88% rename from SOURCES/0010-vddk-do_extents-Mark-some-local-variables-const.patch rename to SOURCES/0008-vddk-do_extents-Mark-some-local-variables-const.patch index 843a632..826d9c1 100644 --- a/SOURCES/0010-vddk-do_extents-Mark-some-local-variables-const.patch +++ b/SOURCES/0008-vddk-do_extents-Mark-some-local-variables-const.patch @@ -1,4 +1,4 @@ -From 2449c43bdbf02a669ffa355c2273a2c99f63a616 Mon Sep 17 00:00:00 2001 +From 0ba2e0d3c53efd49309d9e274e0cb6c2e6720cbd Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 6 Jan 2025 15:37:54 +0000 Subject: [PATCH] vddk: do_extents: Mark some local variables const @@ -8,7 +8,6 @@ the *cmd struct), so mark them as const. Acked-by: Eric Blake (cherry picked from commit 24fd7df460ae31fe3f72b5100ca3dbe138bbadbe) -(cherry picked from commit 0ba2e0d3c53efd49309d9e274e0cb6c2e6720cbd) --- plugins/vddk/worker.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SOURCES/0011-vddk-do_extents-Exit-the-function-if-we-hit-req_one-.patch b/SOURCES/0009-vddk-do_extents-Exit-the-function-if-we-hit-req_one-.patch similarity index 86% rename from SOURCES/0011-vddk-do_extents-Exit-the-function-if-we-hit-req_one-.patch rename to SOURCES/0009-vddk-do_extents-Exit-the-function-if-we-hit-req_one-.patch index 8fd7755..34f187c 100644 --- a/SOURCES/0011-vddk-do_extents-Exit-the-function-if-we-hit-req_one-.patch +++ b/SOURCES/0009-vddk-do_extents-Exit-the-function-if-we-hit-req_one-.patch @@ -1,4 +1,4 @@ -From c300385161e27b8e8530d87f64f62110a626c918 Mon Sep 17 00:00:00 2001 +From 6dd8b5eb14c0723764dd39597d64f62162ca3ab3 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 6 Jan 2025 16:39:51 +0000 Subject: [PATCH] vddk: do_extents: Exit the function if we hit req_one @@ -9,7 +9,6 @@ No change to the functionality, since the code previously called Acked-by: Eric Blake (cherry picked from commit 2f4d71f8f704d89d69cd635791c3239d2f44d631) -(cherry picked from commit 6dd8b5eb14c0723764dd39597d64f62162ca3ab3) --- plugins/vddk/worker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOURCES/0012-vddk-do_extents-Avoid-reading-partial-chunk-beyond-t.patch b/SOURCES/0010-vddk-do_extents-Avoid-reading-partial-chunk-beyond-t.patch similarity index 97% rename from SOURCES/0012-vddk-do_extents-Avoid-reading-partial-chunk-beyond-t.patch rename to SOURCES/0010-vddk-do_extents-Avoid-reading-partial-chunk-beyond-t.patch index 462e521..89ba958 100644 --- a/SOURCES/0012-vddk-do_extents-Avoid-reading-partial-chunk-beyond-t.patch +++ b/SOURCES/0010-vddk-do_extents-Avoid-reading-partial-chunk-beyond-t.patch @@ -1,4 +1,4 @@ -From a4e715715ddace3dfa4f8f0c21e369862e250988 Mon Sep 17 00:00:00 2001 +From fdc2a6a9818aad25ee606118d5f6a32fa0739912 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 6 Jan 2025 15:45:35 +0000 Subject: [PATCH] vddk: do_extents: Avoid reading partial chunk beyond the end @@ -16,7 +16,6 @@ Fixes: https://issues.redhat.com/browse/RHEL-71694 Reported-by: Ming Xie Acked-by: Eric Blake (cherry picked from commit fd918f3d1a185fd996999766c75acb9d6e22395d) -(cherry picked from commit fdc2a6a9818aad25ee606118d5f6a32fa0739912) --- plugins/vddk/worker.c | 29 ++++++++- tests/Makefile.am | 5 +- @@ -81,7 +80,7 @@ index 112111e3..8a91250a 100644 } diff --git a/tests/Makefile.am b/tests/Makefile.am -index 9c321fcb..ba0fb2b6 100644 +index d510807c..0aa36846 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -178,7 +178,8 @@ if HAVE_VDDK diff --git a/SOURCES/0011-file-Fix-minor-typo-in-debug-message.patch b/SOURCES/0011-file-Fix-minor-typo-in-debug-message.patch new file mode 100644 index 0000000..d54f649 --- /dev/null +++ b/SOURCES/0011-file-Fix-minor-typo-in-debug-message.patch @@ -0,0 +1,27 @@ +From 700c3c26a1d20a9e658f7c4eadf1122bc58807df Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 1 May 2025 10:03:06 +0100 +Subject: [PATCH] file: Fix minor typo in debug message + +(cherry picked from commit a75db5636b94c9184f8eb02fd51182d935df64a6) +(cherry picked from commit a79bf57c8ec805516e8dbe7995aa2bd46b83ade3) +--- + plugins/file/file.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/plugins/file/file.c b/plugins/file/file.c +index 2bad6480..7ed4e71b 100644 +--- a/plugins/file/file.c ++++ b/plugins/file/file.c +@@ -901,7 +901,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); + if (r == 0) { + if (file_debug_zero) +- nbdkit_debug ("h->can_zero-range: " ++ nbdkit_debug ("h->can_zero_range: " + "zero succeeded using fallocate"); + goto out; + } +-- +2.47.1 + diff --git a/SOURCES/0012-file-Add-more-debugging-when-D-file.zero-1-is-used.patch b/SOURCES/0012-file-Add-more-debugging-when-D-file.zero-1-is-used.patch new file mode 100644 index 0000000..cd42827 --- /dev/null +++ b/SOURCES/0012-file-Add-more-debugging-when-D-file.zero-1-is-used.patch @@ -0,0 +1,37 @@ +From eebfe03293d7fd08e167bdbb2ab8b8e448393bdf Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 1 May 2025 10:21:23 +0100 +Subject: [PATCH] file: Add more debugging when -D file.zero=1 is used + +(cherry picked from commit ecf6b15fa84a02b74ea969f06552c82ee418b9b4) +(cherry picked from commit 1cb341e75c1a17553b69ea8d9889662e6d09ae78) +--- + plugins/file/file.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +diff --git a/plugins/file/file.c b/plugins/file/file.c +index 7ed4e71b..3668fa4b 100644 +--- a/plugins/file/file.c ++++ b/plugins/file/file.c +@@ -856,7 +856,17 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, + static int + do_fallocate (int fd, int mode_, off_t offset, off_t len) + { +- int r = fallocate (fd, mode_, offset, len); ++ int r; ++ ++ r = fallocate (fd, mode_, offset, len); ++ ++ if (file_debug_zero) ++ nbdkit_debug ("fallocate ([%s%s ], %" PRIu64 ", %" PRIu64") => %d (%d)", ++ mode_ & FALLOC_FL_PUNCH_HOLE ? " FALLOC_FL_PUNCH_HOLE" : "", ++ mode_ & FALLOC_FL_ZERO_RANGE ? " FALLOC_FL_ZERO_RANGE" : "", ++ (uint64_t) offset, (uint64_t) len, r, ++ r == -1 ? errno : 0); ++ + if (r == -1 && errno == ENODEV) { + /* kernel 3.10 fails with ENODEV for block device. Kernel >= 4.9 fails + with EOPNOTSUPP in this case. Normalize errno to simplify callers. */ +-- +2.47.1 + diff --git a/SOURCES/0013-file-Fix-comment-style-in-a-few-places.patch b/SOURCES/0013-file-Fix-comment-style-in-a-few-places.patch new file mode 100644 index 0000000..8e9409c --- /dev/null +++ b/SOURCES/0013-file-Fix-comment-style-in-a-few-places.patch @@ -0,0 +1,44 @@ +From fc302722b01afbf498746c7baf065d8103ce6ac7 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 1 May 2025 10:32:17 +0100 +Subject: [PATCH] file: Fix comment style in a few places + +No actual change here. + +(cherry picked from commit 0df4142c4be2b059c4d17aae0ec71f16ffc9ba35) +(cherry picked from commit 664e447d858a21304610db3023cc728db0c974bd) +--- + plugins/file/file.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/plugins/file/file.c b/plugins/file/file.c +index 3668fa4b..8b63184f 100644 +--- a/plugins/file/file.c ++++ b/plugins/file/file.c +@@ -869,7 +869,8 @@ do_fallocate (int fd, int mode_, off_t offset, off_t len) + + if (r == -1 && errno == ENODEV) { + /* kernel 3.10 fails with ENODEV for block device. Kernel >= 4.9 fails +- with EOPNOTSUPP in this case. Normalize errno to simplify callers. */ ++ * with EOPNOTSUPP in this case. Normalize errno to simplify callers. ++ */ + errno = EOPNOTSUPP; + } + return r; +@@ -926,9 +927,10 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + #endif + + #ifdef FALLOC_FL_PUNCH_HOLE +- /* If we can punch hole but may not trim, we can combine punching hole and +- * fallocate to zero a range. This is expected to be more efficient than +- * writing zeroes manually. */ ++ /* If we can punch hole but may not trim, we can combine punching ++ * hole and fallocate to zero a range. This is expected to be more ++ * efficient than writing zeroes manually. ++ */ + if (h->can_punch_hole && h->can_fallocate) { + int r; + +-- +2.47.1 + diff --git a/SOURCES/0014-file-Fix-do_fallocate-debugging-on-Alpine.patch b/SOURCES/0014-file-Fix-do_fallocate-debugging-on-Alpine.patch new file mode 100644 index 0000000..bb7d1e8 --- /dev/null +++ b/SOURCES/0014-file-Fix-do_fallocate-debugging-on-Alpine.patch @@ -0,0 +1,61 @@ +From 5dfd68ac3fde66113c0044c07679138dd72325b4 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 1 May 2025 10:59:17 +0100 +Subject: [PATCH] file: Fix do_fallocate debugging on Alpine + +Alpine has some weird/old kernel that doesn't support +FALLOC_FL_ZERO_RANGE but does support FALLOC_FL_PUNCH_HOLE, so the +debugging I added in commit ecf6b15fa8 failed to compile with: + + file.c: In function 'do_fallocate': + file.c:958:27: error: 'FALLOC_FL_ZERO_RANGE' undeclared (first use in this function) + 958 | mode_ & FALLOC_FL_ZERO_RANGE ? " FALLOC_FL_ZERO_RANGE" : "", + | ^~~~~~~~~~~~~~~~~~~~ + file.c:958:27: note: each undeclared identifier is reported only once for each function it appears in + make[3]: *** [Makefile:666: nbdkit_file_plugin_la-file.lo] Error 1 + +Fixes: commit ecf6b15fa84a02b74ea969f06552c82ee418b9b4 +(cherry picked from commit 419a347054f81c53706637feddbc5008beab77d3) +(cherry picked from commit 4c02ff62f40497335da185cc4b45c2ba43fb609b) +--- + plugins/file/file.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/plugins/file/file.c b/plugins/file/file.c +index 8b63184f..d94d5b78 100644 +--- a/plugins/file/file.c ++++ b/plugins/file/file.c +@@ -852,7 +852,7 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, + return 0; + } + +-#if defined (FALLOC_FL_PUNCH_HOLE) || defined (FALLOC_FL_ZERO_RANGE) ++#if defined(FALLOC_FL_PUNCH_HOLE) || defined(FALLOC_FL_ZERO_RANGE) + static int + do_fallocate (int fd, int mode_, off_t offset, off_t len) + { +@@ -861,9 +861,20 @@ do_fallocate (int fd, int mode_, off_t offset, off_t len) + r = fallocate (fd, mode_, offset, len); + + if (file_debug_zero) +- nbdkit_debug ("fallocate ([%s%s ], %" PRIu64 ", %" PRIu64") => %d (%d)", ++ nbdkit_debug ("fallocate ([" ++#if defined(FALLOC_FL_PUNCH_HOLE) ++ "%s" ++#endif ++#if defined(FALLOC_FL_ZERO_RANGE) ++ "%s" ++#endif ++ " ], %" PRIu64 ", %" PRIu64") => %d (%d)", ++#if defined(FALLOC_FL_PUNCH_HOLE) + mode_ & FALLOC_FL_PUNCH_HOLE ? " FALLOC_FL_PUNCH_HOLE" : "", ++#endif ++#if defined(FALLOC_FL_ZERO_RANGE) + mode_ & FALLOC_FL_ZERO_RANGE ? " FALLOC_FL_ZERO_RANGE" : "", ++#endif + (uint64_t) offset, (uint64_t) len, r, + r == -1 ? errno : 0); + +-- +2.47.1 + diff --git a/SOURCES/0015-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch b/SOURCES/0015-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch new file mode 100644 index 0000000..a2ddfcf --- /dev/null +++ b/SOURCES/0015-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch @@ -0,0 +1,66 @@ +From a41be72f9d2fe9a8ba6ee4f0549dd0c149bd2c96 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 1 May 2025 10:26:41 +0100 +Subject: [PATCH] file: Rename h->can_zeroout to h->can_blkzeroout to reflect + ioctl + +Since we're calling the blockdev-specific BLKZEROOUT ioctl when this +flag is set, rename the flag. + +(cherry picked from commit fba20ce06c2f0e7c4be7e52e8e1934933851dfbc) +(cherry picked from commit bc4598f3d2d1ef2f4ebdf5b365ed08eff14d5654) +--- + plugins/file/file.c | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/plugins/file/file.c b/plugins/file/file.c +index d94d5b78..55941bb8 100644 +--- a/plugins/file/file.c ++++ b/plugins/file/file.c +@@ -476,7 +476,7 @@ struct handle { + bool can_punch_hole; + bool can_zero_range; + bool can_fallocate; +- bool can_zeroout; ++ bool can_blkzeroout; + }; + + /* Common code for opening a file by name, used by mode_filename and +@@ -682,7 +682,7 @@ file_open (int readonly) + #endif + + h->can_fallocate = true; +- h->can_zeroout = h->is_block_device; ++ h->can_blkzeroout = h->is_block_device; + + return h; + } +@@ -975,14 +975,14 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + + #ifdef BLKZEROOUT + /* For aligned range and block device, we can use BLKZEROOUT. */ +- if (h->can_zeroout && IS_ALIGNED (offset | count, h->sector_size)) { ++ if (h->can_blkzeroout && IS_ALIGNED (offset | count, h->sector_size)) { + int r; + uint64_t range[2] = {offset, count}; + + r = ioctl (h->fd, BLKZEROOUT, &range); + if (r == 0) { + if (file_debug_zero) +- nbdkit_debug ("h->can_zeroout && IS_ALIGNED: " ++ nbdkit_debug ("h->can_blkzeroout && IS_ALIGNED: " + "zero succeeded using BLKZEROOUT"); + goto out; + } +@@ -992,7 +992,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + return -1; + } + +- h->can_zeroout = false; ++ h->can_blkzeroout = false; + } + #endif + +-- +2.47.1 + diff --git a/SOURCES/0016-file-zero-Document-implicit-order-that-we-will-try-z.patch b/SOURCES/0016-file-zero-Document-implicit-order-that-we-will-try-z.patch new file mode 100644 index 0000000..fdc75aa --- /dev/null +++ b/SOURCES/0016-file-zero-Document-implicit-order-that-we-will-try-z.patch @@ -0,0 +1,39 @@ +From 8322b16cd13979f7c872d5ce50517688fc7220bd Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 1 May 2025 10:30:41 +0100 +Subject: [PATCH] file: zero: Document implicit order that we will try zeroing + methods + +There's no substantive change here. I just pulled out the test (flags +& NBDKIT_FLAG_MAY_TRIM) into a boolean variable, and documented that +we (will) try zero-with-trim methods first. + +(cherry picked from commit 61fc023f235b17f8a19302885d1613dd0a7a3793) +(cherry picked from commit c1984ddcc6497c4446d1bf0e8828d1259852eb74) +--- + plugins/file/file.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/plugins/file/file.c b/plugins/file/file.c +index 55941bb8..e5fd864f 100644 +--- a/plugins/file/file.c ++++ b/plugins/file/file.c +@@ -893,9 +893,14 @@ static int + file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + { + struct handle *h __attribute__ ((unused)) = handle; ++ const bool may_trim __attribute__ ((unused)) = flags & NBDKIT_FLAG_MAY_TRIM; + ++ /* These alternate zeroing methods are ordered. Methods which can ++ * trim (if may_trim is set) are tried first. Methods which can ++ * only zero are tried last. ++ */ + #ifdef FALLOC_FL_PUNCH_HOLE +- if (h->can_punch_hole && (flags & NBDKIT_FLAG_MAY_TRIM)) { ++ if (may_trim && h->can_punch_hole) { + int r; + + r = do_fallocate (h->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, +-- +2.47.1 + diff --git a/SOURCES/0017-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch b/SOURCES/0017-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch new file mode 100644 index 0000000..6ebe04f --- /dev/null +++ b/SOURCES/0017-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch @@ -0,0 +1,123 @@ +From 26598004453d1d35c70229ade48a085a74b3dada Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Thu, 1 May 2025 10:36:23 +0100 +Subject: [PATCH] file: zero: Use BLKDISCARD method if may_trim is set + +If we're allowed to trim and we're writing to a block device, +previously we hit the case fallocate(FALLOC_FL_ZERO_RANGE) first. +This succeeds in Linux, zeroing (not trimming) the range. + +However it would be better to trim in this case. Linux supports +ioctl(BLKDISCARD) on block devices, so try this method first. + +Fixes: https://issues.redhat.com/browse/RHEL-89353 +Reported-by: Germano Veit Michel +Thanks: Eric Blake +(cherry picked from commit 7a9ecda24906c64d9f8c7238a96cb3f686e894eb) +(cherry picked from commit 396e8a97835155a620cabbcf1aabaaa1fa4a08f1) +--- + plugins/file/file.c | 50 +++++++++++++++++++++++++++++ + plugins/file/nbdkit-file-plugin.pod | 5 +++ + 2 files changed, 55 insertions(+) + +diff --git a/plugins/file/file.c b/plugins/file/file.c +index e5fd864f..41b23457 100644 +--- a/plugins/file/file.c ++++ b/plugins/file/file.c +@@ -376,6 +376,9 @@ file_dump_plugin (void) + #ifdef BLKSSZGET + printf ("file_blksszget=yes\n"); + #endif ++#ifdef BLKDISCARD ++ printf ("file_blkdiscard=yes\n"); ++#endif + #ifdef BLKZEROOUT + printf ("file_blkzeroout=yes\n"); + #endif +@@ -476,6 +479,7 @@ struct handle { + bool can_punch_hole; + bool can_zero_range; + bool can_fallocate; ++ bool can_blkdiscard; + bool can_blkzeroout; + }; + +@@ -683,6 +687,7 @@ file_open (int readonly) + + h->can_fallocate = true; + h->can_blkzeroout = h->is_block_device; ++ h->can_blkdiscard = h->is_block_device; + + return h; + } +@@ -921,6 +926,51 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + } + #endif + ++#if defined(BLKDISCARD) && defined(FALLOC_FL_ZERO_RANGE) ++ /* For aligned range and block device, we can use BLKDISCARD to ++ * trim. However BLKDISCARD doesn't necessarily zero (eg for local ++ * disk) so we have to zero first and then discard. ++ * ++ * In future all Linux block devices may understand ++ * FALLOC_FL_PUNCH_HOLE which means this case would no longer be ++ * necessary, since the case above will handle it. ++ */ ++ if (may_trim && h->can_blkdiscard && h->can_zero_range && ++ IS_ALIGNED (offset | count, h->sector_size)) { ++ int r; ++ uint64_t range[2] = {offset, count}; ++ ++ r = do_fallocate (h->fd, FALLOC_FL_ZERO_RANGE, offset, count); ++ if (r == 0) { ++ /* We could use FALLOC_FL_PUNCH_HOLE here instead, but currently ++ * thin LVs do not support it (XXX 2025-04). ++ */ ++ r = ioctl (h->fd, BLKDISCARD, &range); ++ if (r == 0) { ++ if (file_debug_zero) ++ nbdkit_debug ("h->can_blkdiscard && may_trim && IS_ALIGNED: " ++ "zero succeeded using BLKDISCARD"); ++ goto out; ++ } ++ ++ if (!is_enotsup (errno)) { ++ nbdkit_error ("zero: %m"); ++ return -1; ++ } ++ ++ h->can_blkdiscard = false; ++ } ++ else { ++ if (!is_enotsup (errno)) { ++ nbdkit_error ("zero: %m"); ++ return -1; ++ } ++ ++ h->can_fallocate = false; ++ } ++ } ++#endif ++ + #ifdef FALLOC_FL_ZERO_RANGE + if (h->can_zero_range) { + int r; +diff --git a/plugins/file/nbdkit-file-plugin.pod b/plugins/file/nbdkit-file-plugin.pod +index a50bef2d..0e260b7f 100644 +--- a/plugins/file/nbdkit-file-plugin.pod ++++ b/plugins/file/nbdkit-file-plugin.pod +@@ -227,6 +227,11 @@ future. + If both set, the plugin may be able to efficiently zero ranges of + block devices, where the driver and block device itself supports this. + ++=item C ++ ++If set, the plugin may be able to efficiently trim ranges of block ++devices, where the driver and block device itself supports this. ++ + =item C + + If set, the plugin can read file extents. +-- +2.47.1 + diff --git a/SOURCES/copy-patches.sh b/SOURCES/copy-patches.sh index 8cbd83a..38b87a1 100644 --- a/SOURCES/copy-patches.sh +++ b/SOURCES/copy-patches.sh @@ -6,7 +6,7 @@ set -e # directory. Use it like this: # ./copy-patches.sh -rhel_version=9.5 +rhel_version=9.6 # Check we're in the right directory. if [ ! -f nbdkit.spec ]; then diff --git a/SOURCES/nbdkit-1.38.3.tar.gz.sig b/SOURCES/nbdkit-1.38.3.tar.gz.sig deleted file mode 100644 index 955145d..0000000 --- a/SOURCES/nbdkit-1.38.3.tar.gz.sig +++ /dev/null @@ -1,17 +0,0 @@ ------BEGIN PGP SIGNATURE----- - -iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAmaTi9oRHHJpY2hAYW5u -ZXhpYS5vcmcACgkQkXOPc+G3aKB97w/9H/Ss3V0yhUPgK6bidlCIBmZcUmw0ItTa -PoI42QL+lmJCP4FiLd4aAZRfnosTbi/KFfGC5OI/DhZs/bFvLJPX56Dq+tDfLTo8 -OlpdWkW2E6tALN5ZlA8zFXLfJ+xofpn9/F7O4XdkW04HIpXx4ly8tCPG27idV9UV -jjVzwmo/eqhJTWHJAspD1iB/oXfCVh0VVe3d4G/n32/pLfULwK6iEGMze+51IJoI -SdKPKtwFmPn5e0r34+JLyCilugJvl3crJI2CZt9Azi31joCgEEif0Mkn2aiY8Zc9 -S3/3r9US6VriKYYhilLTgpjbimeNZJGuVPqPS8lhaSmAoyOncG1CcKOk2Tewf8m+ -vrUHFTWKSP6IgdlGnXYZNQprA1zPUePyMpm3RwnaV8N3Vcy0J4lkL80laSQs5VUn -PkzwrSxaegWDnrlBjNQi5cWWVSqUMUsEpCQXu93fvbGi/V2wkVlOx5ubPIIo8ykc -dPVG3+9d2PUEVXyJLWmA5jXJW19EnZK8fttUrcshbF375CU7Vuo6Ds6QFdcTqEs/ -te1c3QxDQav4BeV7VbD5xL1xc931F6fWwa9FpzPf366AhCM/tunw91oIUP2bkw8U -B7Z83x9nAuxewQeeI+7nDLKdhdg/bpeMoiUUCYQVS1K61+4D+J6bmc2lvsvhj3Pp -gMcCwZR9wF0= -=SuJ6 ------END PGP SIGNATURE----- diff --git a/SOURCES/nbdkit-1.38.5.tar.gz.sig b/SOURCES/nbdkit-1.38.5.tar.gz.sig new file mode 100644 index 0000000..e4bbfee --- /dev/null +++ b/SOURCES/nbdkit-1.38.5.tar.gz.sig @@ -0,0 +1,17 @@ +-----BEGIN PGP SIGNATURE----- + +iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAmb3vXwRHHJpY2hAYW5u +ZXhpYS5vcmcACgkQkXOPc+G3aKD5MQ/+NnAunC2qzgUZFzeTf5gilj/xlk3M7LbA +LDtrAMacpq88CvoxKBcvKvW47/loaL9GBxp0rvly7DQ0vm3WaYMIMj9A25vDFqKC +IN16/6DDmzMOPkWsDgqAx+VXRMEv/KjtJUxl9jbvZdlmUNGlag/MftVryNqr654w +NPDeJnL0jN87/S28LHRhuleVMV9SozSb9iG87S1Z6ipXpHu8MzcXYWWiR4P4eecD +0Rbg+HpBQJJnoVtsBBf35V5HEFtpqg4GvCTMQH0lfLsleE1vTi5Yueq4cpE6YVY9 +Bo5qXUHYy6kVuKcAX6Prvycrh3A847Wh/4M6KfKw4RQgP3FFGMJp+/+M9PzG14gK +HtL0moKlS/q78kkpyPvAdKDEpD/U+kSrlv2fwugu403o/XrvLaSzhdWSWBgbaB/0 +x3pENPe+UIF+VdNikOa2S3hY4mh7/lx2BpTsGN38qFIiK7TZsAY9aAR2z8Er5/O4 +iubxuPUDsDOTFxCGDS6rxWQKwKVynhEbMzce9R+fKY7XfpRf3RWmplKYyLtAhKbT +rQoecPj5fIPpUdWIos8FbiQaC5EeBOEq+ZndTSumyKmkHorSI/VpCRio8DAjXdBd +bXDC1CfXSe9VeScTMYFjim8BcFsLexdrJweYANCCURvOG0drgjWxHAlJ+Ou3Beka +ygBLbICcbJM= +=oY/3 +-----END PGP SIGNATURE----- diff --git a/SPECS/nbdkit.spec b/SPECS/nbdkit.spec index a74f6c1..f788586 100644 --- a/SPECS/nbdkit.spec +++ b/SPECS/nbdkit.spec @@ -55,8 +55,8 @@ %global source_directory 1.38-stable Name: nbdkit -Version: 1.38.3 -Release: 2%{?dist} +Version: 1.38.5 +Release: 3%{?dist} Summary: NBD server License: BSD-3-Clause @@ -78,21 +78,26 @@ Source2: libguestfs.keyring Source3: copy-patches.sh # Patches come from the upstream repository: -# https://gitlab.com/nbdkit/nbdkit/-/commits/rhel-9.5/ +# https://gitlab.com/nbdkit/nbdkit/-/commits/rhel-9.6/ # Patches. -Patch0001: 0001-nbdkit-1.38-Fix-inclusion-of-gnutls-socket.h-with-ol.patch -Patch0002: 0002-server-log-Move-preserve-errno-to-log_verror-functio.patch -Patch0003: 0003-server-Rename-threadlocal_-set-get-_error-to-._errno.patch -Patch0004: 0004-server-Introduce-threadlocal_-set-get-_last_error.patch -Patch0005: 0005-server-Take-a-thread-local-copy-of-the-last-call-to-.patch -Patch0006: 0006-server-Send-the-last-error-to-the-NBD-client.patch -Patch0007: 0007-tests-test-ext2-exportname.sh-Ignore-libnbd-1.8-for-.patch -Patch0008: 0008-vddk-Include-stdbool.h.patch -Patch0009: 0009-vddk-Cache-the-disk-size-in-the-handle.patch -Patch0010: 0010-vddk-do_extents-Mark-some-local-variables-const.patch -Patch0011: 0011-vddk-do_extents-Exit-the-function-if-we-hit-req_one-.patch -Patch0012: 0012-vddk-do_extents-Avoid-reading-partial-chunk-beyond-t.patch +Patch0001: 0001-server-log-Move-preserve-errno-to-log_verror-functio.patch +Patch0002: 0002-server-Rename-threadlocal_-set-get-_error-to-._errno.patch +Patch0003: 0003-server-Introduce-threadlocal_-set-get-_last_error.patch +Patch0004: 0004-server-Take-a-thread-local-copy-of-the-last-call-to-.patch +Patch0005: 0005-server-Send-the-last-error-to-the-NBD-client.patch +Patch0006: 0006-vddk-Include-stdbool.h.patch +Patch0007: 0007-vddk-Cache-the-disk-size-in-the-handle.patch +Patch0008: 0008-vddk-do_extents-Mark-some-local-variables-const.patch +Patch0009: 0009-vddk-do_extents-Exit-the-function-if-we-hit-req_one-.patch +Patch0010: 0010-vddk-do_extents-Avoid-reading-partial-chunk-beyond-t.patch +Patch0011: 0011-file-Fix-minor-typo-in-debug-message.patch +Patch0012: 0012-file-Add-more-debugging-when-D-file.zero-1-is-used.patch +Patch0013: 0013-file-Fix-comment-style-in-a-few-places.patch +Patch0014: 0014-file-Fix-do_fallocate-debugging-on-Alpine.patch +Patch0015: 0015-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch +Patch0016: 0016-file-zero-Document-implicit-order-that-we-will-try-z.patch +Patch0017: 0017-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch # For automatic RPM Provides generation. # See: https://rpm-software-management.github.io/rpm/manual/dependency_generators.html @@ -1511,10 +1516,16 @@ fi %changelog -* Mon Mar 10 2025 Richard W.M. Jones - 1.38.3-2 +* Tue May 13 2025 Richard W.M. Jones - 1.38.5-3 +- file: zero: Use BLKDISCARD method if may_trim is set + resolves: RHEL-91094 + +* Mon Jan 06 2025 Richard W.M. Jones - 1.38.5-2 - vddk: Avoid reading partial chunk beyond the end of the disk - resolves: RHEL-82831 -- Fix tests/test-ext2-exportname.sh. + resolves: RHEL-71694 + +* Sat Sep 28 2024 Richard W.M. Jones - 1.38.5-1 +- Rebase to 1.38.5 (along stable branch) * Fri Jul 26 2024 Richard W.M. Jones - 1.38.3-1 - Rebase to 1.38.3 (along stable branch)