From 7a3edc95420ee36e0ab60da0883d9d24256bef65 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 23 Jun 2025 14:14:00 +0100 Subject: [PATCH] Rebase to nbdkit 1.42.5 resolves: RHEL-78830 Add support for VDDK 9.0.0.0 resolves: RHEL-99467 --- ...ng-if-sync_file_range-posix_fadvise-.patch | 41 ----- ...-Add-tests-of-file-plugin-cache-none.patch | 8 +- ...e_range-fails-to-start-don-t-add-win.patch | 82 --------- ...ore-generic-tests-of-file-cache-none.patch | 8 +- ...eadonly-flag-from-the-.open-call-in-.patch | 6 +- ...-Move-minimum-version-of-VDDK-to-6.7.patch | 20 +-- ...-Hard-error-if-sync_file_range-fails.patch | 101 ----------- ...ditionally-test-QueryAllocatedBlocks.patch | 8 +- ...size-of-the-lock-around-write-evicti.patch | 90 ---------- ...the-extents-for-readonly-connections.patch | 10 +- ...plicit-assumption-about-eviction-win.patch | 29 --- ...lename-or-equivalent-in-the-file-han.patch | 4 +- ...ename-or-equivalent-to-error-message.patch | 28 +-- ...urn-flush-into-a-controlpath-message.patch | 33 ---- ...e-Add-offset-count-to-error-messages.patch | 28 +-- ...file-Fix-minor-typo-in-debug-message.patch | 26 --- ...debugging-when-D-file.zero-1-is-used.patch | 36 ---- ...d-the-byte-count-of-each-QueryAlloca.patch | 6 +- ...le-Fix-comment-style-in-a-few-places.patch | 43 ----- ...ct-elapsed-time-for-ReadAsync-and-Wr.patch | 8 +- ...Fix-do_fallocate-debugging-on-Alpine.patch | 60 ------- ...n_zeroout-to-h-can_blkzeroout-to-ref.patch | 65 ------- ...nt-implicit-order-that-we-will-try-z.patch | 38 ---- ...BLKDISCARD-method-if-may_trim-is-set.patch | 122 ------------- ...h-of-extents-when-using-D-vddk.exten.patch | 30 ---- ...tents-Mark-this-filter-as-deprecated.patch | 38 ---- ...e-extent-functions-to-nbdkit-common..patch | 77 -------- ...mand-type-in-command-completed-messa.patch | 29 --- ...s-instead-of-Unicode-s-for-microseco.patch | 34 ---- ...-stats-Line-up-the-columns-correctly.patch | 26 --- ...y-one-for-maximum-block_status-lengt.patch | 170 ------------------ ...-bit-overflow-in-.extents-CVE-2025-4.patch | 163 ----------------- nbdkit.spec | 55 ++---- sources | 4 +- 34 files changed, 87 insertions(+), 1439 deletions(-) delete mode 100644 0001-file-Add-debugging-if-sync_file_range-posix_fadvise-.patch rename 0003-tests-Add-tests-of-file-plugin-cache-none.patch => 0001-tests-Add-tests-of-file-plugin-cache-none.patch (98%) delete mode 100644 0002-file-If-sync_file_range-fails-to-start-don-t-add-win.patch rename 0004-tests-Add-more-generic-tests-of-file-cache-none.patch => 0002-tests-Add-more-generic-tests-of-file-cache-none.patch (98%) rename 0020-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch => 0003-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch (89%) rename 0021-vddk-Move-minimum-version-of-VDDK-to-6.7.patch => 0004-vddk-Move-minimum-version-of-VDDK-to-6.7.patch (94%) delete mode 100644 0005-file-Hard-error-if-sync_file_range-fails.patch rename 0022-vddk-Unconditionally-test-QueryAllocatedBlocks.patch => 0005-vddk-Unconditionally-test-QueryAllocatedBlocks.patch (91%) delete mode 100644 0006-file-Reduce-the-size-of-the-lock-around-write-evicti.patch rename 0023-vddk-Pre-cache-the-extents-for-readonly-connections.patch => 0006-vddk-Pre-cache-the-extents-for-readonly-connections.patch (98%) delete mode 100644 0007-file-Document-implicit-assumption-about-eviction-win.patch rename 0024-file-Save-the-filename-or-equivalent-in-the-file-han.patch => 0007-file-Save-the-filename-or-equivalent-in-the-file-han.patch (98%) rename 0025-file-Add-the-filename-or-equivalent-to-error-message.patch => 0008-file-Add-the-filename-or-equivalent-to-error-message.patch (81%) delete mode 100644 0008-server-Turn-flush-into-a-controlpath-message.patch rename 0026-file-Add-offset-count-to-error-messages.patch => 0009-file-Add-offset-count-to-error-messages.patch (82%) delete mode 100644 0009-file-Fix-minor-typo-in-debug-message.patch delete mode 100644 0010-file-Add-more-debugging-when-D-file.zero-1-is-used.patch rename 0029-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch => 0010-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch (94%) delete mode 100644 0011-file-Fix-comment-style-in-a-few-places.patch rename 0030-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch => 0011-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch (97%) delete mode 100644 0012-file-Fix-do_fallocate-debugging-on-Alpine.patch delete mode 100644 0013-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch delete mode 100644 0014-file-zero-Document-implicit-order-that-we-will-try-z.patch delete mode 100644 0015-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch delete mode 100644 0016-vddk-Debug-length-of-extents-when-using-D-vddk.exten.patch delete mode 100644 0017-cacheextents-Mark-this-filter-as-deprecated.patch delete mode 100644 0018-include-Move-some-extent-functions-to-nbdkit-common..patch delete mode 100644 0019-vddk-Display-command-type-in-command-completed-messa.patch delete mode 100644 0027-vddk-stats-Use-us-instead-of-Unicode-s-for-microseco.patch delete mode 100644 0028-vddk-stats-Line-up-the-columns-correctly.patch delete mode 100644 0031-server-Fix-off-by-one-for-maximum-block_status-lengt.patch delete mode 100644 0032-blocksize-Fix-32-bit-overflow-in-.extents-CVE-2025-4.patch diff --git a/0001-file-Add-debugging-if-sync_file_range-posix_fadvise-.patch b/0001-file-Add-debugging-if-sync_file_range-posix_fadvise-.patch deleted file mode 100644 index 57a1009..0000000 --- a/0001-file-Add-debugging-if-sync_file_range-posix_fadvise-.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 96315050f6683c8834f8ac3ccaea33e8e58fb183 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Fri, 28 Mar 2025 20:32:46 +0000 -Subject: [PATCH] file: Add debugging if sync_file_range / posix_fadvise fails - -These are advisory hints, but add some debugging so we know if these -calls are failing. The errors are ignored so there is no behaviour -change. - -Thanks: Eric Sandeen -(cherry picked from commit feb22cfc85b0750a4e4bfbc5fe56636883599feb) ---- - plugins/file/file.c | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - -diff --git a/plugins/file/file.c b/plugins/file/file.c -index 52396bb2..77de1cc8 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -125,11 +125,13 @@ evict_writes (int fd, uint64_t offset, size_t len) - - /* Evict the oldest window from the page cache. */ - if (window[0].len > 0) { -- sync_file_range (window[0].fd, window[0].offset, window[0].len, -- SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| -- SYNC_FILE_RANGE_WAIT_AFTER); -- posix_fadvise (window[0].fd, window[0].offset, window[0].len, -- POSIX_FADV_DONTNEED); -+ if (sync_file_range (window[0].fd, window[0].offset, window[0].len, -+ SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| -+ SYNC_FILE_RANGE_WAIT_AFTER) == -1) -+ nbdkit_debug ("sync_file_range: wait: (ignored): %m"); -+ if (posix_fadvise (window[0].fd, window[0].offset, window[0].len, -+ POSIX_FADV_DONTNEED) == -1) -+ nbdkit_debug ("posix_fadvise: POSIX_FADV_DONTNEED: (ignored): %m"); - } - - /* Move the Nth window to N-1. */ --- -2.47.1 - diff --git a/0003-tests-Add-tests-of-file-plugin-cache-none.patch b/0001-tests-Add-tests-of-file-plugin-cache-none.patch similarity index 98% rename from 0003-tests-Add-tests-of-file-plugin-cache-none.patch rename to 0001-tests-Add-tests-of-file-plugin-cache-none.patch index 606ba90..3e4bc00 100644 --- a/0003-tests-Add-tests-of-file-plugin-cache-none.patch +++ b/0001-tests-Add-tests-of-file-plugin-cache-none.patch @@ -1,4 +1,4 @@ -From ecd719d5ab101e54cab496085b827a485c9398e6 Mon Sep 17 00:00:00 2001 +From eca2b4034d446f1daaca4805c8a5380cb352a512 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 29 Mar 2025 10:01:05 +0000 Subject: [PATCH] tests: Add tests of file plugin cache=none @@ -34,10 +34,10 @@ index 5d61e786..2f5123c9 100644 * fdisk, sfdisk (from util-linux) * flake8 diff --git a/tests/Makefile.am b/tests/Makefile.am -index 7376c948..e8003c1c 100644 +index 10565b43..7836f5dd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am -@@ -899,6 +899,8 @@ TESTS += \ +@@ -901,6 +901,8 @@ TESTS += \ test-file-extents.sh \ test-file-dir.sh \ test-file-dirfd.sh \ @@ -46,7 +46,7 @@ index 7376c948..e8003c1c 100644 $(NULL) EXTRA_DIST += \ test-file.sh \ -@@ -908,6 +910,8 @@ EXTRA_DIST += \ +@@ -910,6 +912,8 @@ EXTRA_DIST += \ test-file-extents.sh \ test-file-dir.sh \ test-file-dirfd.sh \ diff --git a/0002-file-If-sync_file_range-fails-to-start-don-t-add-win.patch b/0002-file-If-sync_file_range-fails-to-start-don-t-add-win.patch deleted file mode 100644 index ea2b05a..0000000 --- a/0002-file-If-sync_file_range-fails-to-start-don-t-add-win.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 93e3804d42b5e6f4afcd7524eb07d776b56c883d Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Fri, 28 Mar 2025 20:35:54 +0000 -Subject: [PATCH] file: If sync_file_range fails to start, don't add window to - list - -When starting the process of writing out the newest range, we -previously didn't check if sync_file_range succeeded or failed. But -if it failed there's no reason to add it to the list of windows. Also -debug any failures. - -This shouldn't change any semantics as far as we're aware. - -Thanks: Eric Sandeen -(cherry picked from commit d35f0636373e6a58c8f3fcfcf505af248e27c574) ---- - plugins/file/file.c | 48 ++++++++++++++++++++++++++------------------- - 1 file changed, 28 insertions(+), 20 deletions(-) - -diff --git a/plugins/file/file.c b/plugins/file/file.c -index 77de1cc8..0271a56b 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -123,27 +123,35 @@ evict_writes (int fd, uint64_t offset, size_t len) - { - ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&window_lock); - -- /* Evict the oldest window from the page cache. */ -- if (window[0].len > 0) { -- if (sync_file_range (window[0].fd, window[0].offset, window[0].len, -- SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| -- SYNC_FILE_RANGE_WAIT_AFTER) == -1) -- nbdkit_debug ("sync_file_range: wait: (ignored): %m"); -- if (posix_fadvise (window[0].fd, window[0].offset, window[0].len, -- POSIX_FADV_DONTNEED) == -1) -- nbdkit_debug ("posix_fadvise: POSIX_FADV_DONTNEED: (ignored): %m"); -- } -- -- /* Move the Nth window to N-1. */ -- memmove (&window[0], &window[1], sizeof window[0] * (NR_WINDOWS-1)); -- -- /* Set up the current window and tell Linux to start writing it out -- * to disk (asynchronously). -+ /* Tell Linux to start writing the current range out to disk -+ * (asynchronously). - */ -- sync_file_range (fd, offset, len, SYNC_FILE_RANGE_WRITE); -- window[NR_WINDOWS-1].fd = fd; -- window[NR_WINDOWS-1].offset = offset; -- window[NR_WINDOWS-1].len = len; -+ if (sync_file_range (fd, offset, len, SYNC_FILE_RANGE_WRITE) == -1) { -+ /* sync_file_range to start the write failed */ -+ nbdkit_debug ("sync_file_range: write: (ignored): %m"); -+ } -+ else { -+ /* sync_file_range to start the write succeeded, so -+ * evict the oldest window from the page cache. -+ */ -+ if (window[0].len > 0) { -+ if (sync_file_range (window[0].fd, window[0].offset, window[0].len, -+ SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| -+ SYNC_FILE_RANGE_WAIT_AFTER) == -1) -+ nbdkit_debug ("sync_file_range: wait: (ignored): %m"); -+ if (posix_fadvise (window[0].fd, window[0].offset, window[0].len, -+ POSIX_FADV_DONTNEED) == -1) -+ nbdkit_debug ("posix_fadvise: POSIX_FADV_DONTNEED: (ignored): %m"); -+ } -+ -+ /* Move the Nth window to N-1. */ -+ memmove (&window[0], &window[1], sizeof window[0] * (NR_WINDOWS-1)); -+ -+ /* Add the range to the newest end of the list of windows. */ -+ window[NR_WINDOWS-1].fd = fd; -+ window[NR_WINDOWS-1].offset = offset; -+ window[NR_WINDOWS-1].len = len; -+ } - } - - /* When we close the handle we must remove any windows which are still --- -2.47.1 - diff --git a/0004-tests-Add-more-generic-tests-of-file-cache-none.patch b/0002-tests-Add-more-generic-tests-of-file-cache-none.patch similarity index 98% rename from 0004-tests-Add-more-generic-tests-of-file-cache-none.patch rename to 0002-tests-Add-more-generic-tests-of-file-cache-none.patch index 84199d9..7dbcfac 100644 --- a/0004-tests-Add-more-generic-tests-of-file-cache-none.patch +++ b/0002-tests-Add-more-generic-tests-of-file-cache-none.patch @@ -1,4 +1,4 @@ -From cf595cb02d8241fe01b943bd28cf744a0c7cb852 Mon Sep 17 00:00:00 2001 +From 05348e4e97a034070878e0ef44392b5844d32b1f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 1 Apr 2025 12:45:43 +0100 Subject: [PATCH] tests: Add more generic tests of file cache=none @@ -23,10 +23,10 @@ Updates: commit 6017ba21aeeb3d7ad85925e78dba85a005194dee rename tests/{test-file-cache-none-write.sh => test-file-cache-none-write-effective.sh} (92%) diff --git a/tests/Makefile.am b/tests/Makefile.am -index e8003c1c..2b494b89 100644 +index 7836f5dd..00cb1618 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am -@@ -899,8 +899,10 @@ TESTS += \ +@@ -901,8 +901,10 @@ TESTS += \ test-file-extents.sh \ test-file-dir.sh \ test-file-dirfd.sh \ @@ -39,7 +39,7 @@ index e8003c1c..2b494b89 100644 $(NULL) EXTRA_DIST += \ test-file.sh \ -@@ -910,8 +912,10 @@ EXTRA_DIST += \ +@@ -912,8 +914,10 @@ EXTRA_DIST += \ test-file-extents.sh \ test-file-dir.sh \ test-file-dirfd.sh \ diff --git a/0020-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch b/0003-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch similarity index 89% rename from 0020-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch rename to 0003-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch index 5acc431..58e0a3c 100644 --- a/0020-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch +++ b/0003-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch @@ -1,4 +1,4 @@ -From d01437869db201f45c1a7ce1bb1e5f9142c9081c Mon Sep 17 00:00:00 2001 +From cdb379e91341feeefa2e2cdf1d09b66ed387ec1c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 30 May 2025 13:32:00 +0100 Subject: [PATCH] vddk: Cache the readonly flag from the .open call in the @@ -11,10 +11,10 @@ Subject: [PATCH] vddk: Cache the readonly flag from the .open call in the 2 files changed, 4 insertions(+) diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c -index 1de356d8..342a913b 100644 +index b5fa28fb..d00abde7 100644 --- a/plugins/vddk/vddk.c +++ b/plugins/vddk/vddk.c -@@ -713,6 +713,7 @@ vddk_open (int readonly) +@@ -715,6 +715,7 @@ vddk_open (int readonly) nbdkit_error ("calloc: %m"); return NULL; } diff --git a/0021-vddk-Move-minimum-version-of-VDDK-to-6.7.patch b/0004-vddk-Move-minimum-version-of-VDDK-to-6.7.patch similarity index 94% rename from 0021-vddk-Move-minimum-version-of-VDDK-to-6.7.patch rename to 0004-vddk-Move-minimum-version-of-VDDK-to-6.7.patch index 016a824..566061a 100644 --- a/0021-vddk-Move-minimum-version-of-VDDK-to-6.7.patch +++ b/0004-vddk-Move-minimum-version-of-VDDK-to-6.7.patch @@ -1,4 +1,4 @@ -From 6df932e5a77250d9946b91a02a143bdd28ee2f77 Mon Sep 17 00:00:00 2001 +From ed73435936467ecc9d585764f7fa468ef3626eaa Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 30 May 2025 13:49:10 +0100 Subject: [PATCH] vddk: Move minimum version of VDDK to 6.7 @@ -19,10 +19,10 @@ to upgrade. 5 files changed, 76 insertions(+), 66 deletions(-) diff --git a/plugins/vddk/nbdkit-vddk-plugin.pod b/plugins/vddk/nbdkit-vddk-plugin.pod -index da3e9f9a..279da2d0 100644 +index 4810bceb..7cf938de 100644 --- a/plugins/vddk/nbdkit-vddk-plugin.pod +++ b/plugins/vddk/nbdkit-vddk-plugin.pod -@@ -397,15 +397,13 @@ is I recommended. +@@ -396,15 +396,13 @@ is I recommended. =over 4 @@ -40,7 +40,7 @@ index da3e9f9a..279da2d0 100644 +C API. This is used to provide sparseness (extent) information over NBD. - =item VDDK 8.0.3 (released Jun 2024) + =item VDDK 9.0.0.0 (released Jun 2025) diff --git a/plugins/vddk/vddk-stubs.h b/plugins/vddk/vddk-stubs.h index 8e5afdb8..d768c51a 100644 --- a/plugins/vddk/vddk-stubs.h @@ -82,10 +82,10 @@ index 8e5afdb8..d768c51a 100644 + * longer using this macro. + */ diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c -index 342a913b..60f75b51 100644 +index d00abde7..3c8bb03a 100644 --- a/plugins/vddk/vddk.c +++ b/plugins/vddk/vddk.c -@@ -666,37 +666,6 @@ vddk_dump_plugin (void) +@@ -668,37 +668,6 @@ vddk_dump_plugin (void) /* Lock protecting open/close calls - see above. */ static pthread_mutex_t open_close_lock = PTHREAD_MUTEX_INITIALIZER; @@ -123,7 +123,7 @@ index 342a913b..60f75b51 100644 /* Create the per-connection handle. */ static void * vddk_open (int readonly) -@@ -718,7 +687,9 @@ vddk_open (int readonly) +@@ -720,7 +689,9 @@ vddk_open (int readonly) pthread_mutex_init (&h->commands_lock, NULL); pthread_cond_init (&h->commands_cond, NULL); @@ -134,7 +134,7 @@ index 342a913b..60f75b51 100644 if (h->params == NULL) { nbdkit_error ("allocate VixDiskLibConnectParams: %m"); goto err0; -@@ -851,7 +822,9 @@ vddk_open (int readonly) +@@ -853,7 +824,9 @@ vddk_open (int readonly) VixDiskLib_Disconnect (h->connection); VDDK_CALL_END (VixDiskLib_Disconnect, 0); err1: @@ -145,7 +145,7 @@ index 342a913b..60f75b51 100644 err0: pthread_mutex_destroy (&h->commands_lock); pthread_cond_destroy (&h->commands_cond); -@@ -877,7 +850,9 @@ vddk_close (void *handle) +@@ -879,7 +852,9 @@ vddk_close (void *handle) VixDiskLib_Disconnect (h->connection); VDDK_CALL_END (VixDiskLib_Disconnect, 0); @@ -157,7 +157,7 @@ index 342a913b..60f75b51 100644 pthread_cond_destroy (&h->commands_cond); command_queue_reset (&h->commands); diff --git a/plugins/vddk/worker.c b/plugins/vddk/worker.c -index 3bf1d5c2..076b2bd7 100644 +index 8c602ac7..e51da8c0 100644 --- a/plugins/vddk/worker.c +++ b/plugins/vddk/worker.c @@ -309,23 +309,13 @@ do_can_extents (struct command *cmd, struct vddk_handle *h) diff --git a/0005-file-Hard-error-if-sync_file_range-fails.patch b/0005-file-Hard-error-if-sync_file_range-fails.patch deleted file mode 100644 index 5bf4b48..0000000 --- a/0005-file-Hard-error-if-sync_file_range-fails.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 21ac419d37f307fee4ba88d37c0bf1da0c591bac Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 1 Apr 2025 11:07:51 +0100 -Subject: [PATCH] file: Hard error if sync_file_range fails - -After discussion with Dave Chinner, it appears that I/O errors can be -returned by sync_file_range, ie. it is not merely a hint to start the -eviction. Therefore return a hard error if any of the sync_file_range -calls fails. - -Thanks: Dave Chinner -Updates: commit d35f0636373e6a58c8f3fcfcf505af248e27c574 -(cherry picked from commit d2ed6a839c3ed50b417f45dc13e5b811ecdc4e74) ---- - plugins/file/file.c | 53 ++++++++++++++++++++++++--------------------- - 1 file changed, 28 insertions(+), 25 deletions(-) - -diff --git a/plugins/file/file.c b/plugins/file/file.c -index 0271a56b..aa552037 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -118,7 +118,7 @@ struct write_window { - static pthread_mutex_t window_lock = PTHREAD_MUTEX_INITIALIZER; - static struct write_window window[NR_WINDOWS]; - --static void -+static int - evict_writes (int fd, uint64_t offset, size_t len) - { - ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&window_lock); -@@ -127,31 +127,32 @@ evict_writes (int fd, uint64_t offset, size_t len) - * (asynchronously). - */ - if (sync_file_range (fd, offset, len, SYNC_FILE_RANGE_WRITE) == -1) { -- /* sync_file_range to start the write failed */ -- nbdkit_debug ("sync_file_range: write: (ignored): %m"); -+ nbdkit_error ("sync_file_range: cache=none: starting eviction: %m"); -+ return -1; - } -- else { -- /* sync_file_range to start the write succeeded, so -- * evict the oldest window from the page cache. -- */ -- if (window[0].len > 0) { -- if (sync_file_range (window[0].fd, window[0].offset, window[0].len, -- SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| -- SYNC_FILE_RANGE_WAIT_AFTER) == -1) -- nbdkit_debug ("sync_file_range: wait: (ignored): %m"); -- if (posix_fadvise (window[0].fd, window[0].offset, window[0].len, -- POSIX_FADV_DONTNEED) == -1) -- nbdkit_debug ("posix_fadvise: POSIX_FADV_DONTNEED: (ignored): %m"); -+ -+ /* Evict the oldest window from the page cache. */ -+ if (window[0].len > 0) { -+ if (sync_file_range (window[0].fd, window[0].offset, window[0].len, -+ SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| -+ SYNC_FILE_RANGE_WAIT_AFTER) == -1) { -+ nbdkit_error ("sync_file_range: cache=none: evicting oldest window: %m"); -+ return -1; - } -- -- /* Move the Nth window to N-1. */ -- memmove (&window[0], &window[1], sizeof window[0] * (NR_WINDOWS-1)); -- -- /* Add the range to the newest end of the list of windows. */ -- window[NR_WINDOWS-1].fd = fd; -- window[NR_WINDOWS-1].offset = offset; -- window[NR_WINDOWS-1].len = len; -+ if (posix_fadvise (window[0].fd, window[0].offset, window[0].len, -+ POSIX_FADV_DONTNEED) == -1) -+ nbdkit_debug ("posix_fadvise: POSIX_FADV_DONTNEED: (ignored): %m"); - } -+ -+ /* Move the Nth window to N-1. */ -+ memmove (&window[0], &window[1], sizeof window[0] * (NR_WINDOWS-1)); -+ -+ /* Add the range to the newest end of the list of windows. */ -+ window[NR_WINDOWS-1].fd = fd; -+ window[NR_WINDOWS-1].offset = offset; -+ window[NR_WINDOWS-1].len = len; -+ -+ return 0; - } - - /* When we close the handle we must remove any windows which are still -@@ -920,8 +921,10 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, - return -1; - - #if EVICT_WRITES -- if (cache_mode == cache_none) -- evict_writes (h->fd, orig_offset, orig_count); -+ if (cache_mode == cache_none) { -+ if (evict_writes (h->fd, orig_offset, orig_count) == -1) -+ return -1; -+ } - #endif - - return 0; --- -2.47.1 - diff --git a/0022-vddk-Unconditionally-test-QueryAllocatedBlocks.patch b/0005-vddk-Unconditionally-test-QueryAllocatedBlocks.patch similarity index 91% rename from 0022-vddk-Unconditionally-test-QueryAllocatedBlocks.patch rename to 0005-vddk-Unconditionally-test-QueryAllocatedBlocks.patch index 9572372..ebb4404 100644 --- a/0022-vddk-Unconditionally-test-QueryAllocatedBlocks.patch +++ b/0005-vddk-Unconditionally-test-QueryAllocatedBlocks.patch @@ -1,4 +1,4 @@ -From 0c3394942b857815feebe7586b2cb18e2bf113e5 Mon Sep 17 00:00:00 2001 +From 084dfd7e9037e12a2d0ef7051f7d0d29ff9dd67a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 30 May 2025 13:59:28 +0100 Subject: [PATCH] vddk: Unconditionally test QueryAllocatedBlocks @@ -16,7 +16,7 @@ this flag when the worker thread starts up. 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/plugins/vddk/worker.c b/plugins/vddk/worker.c -index 076b2bd7..6efcc6f6 100644 +index e51da8c0..b3a5180e 100644 --- a/plugins/vddk/worker.c +++ b/plugins/vddk/worker.c @@ -303,8 +303,13 @@ do_flush (struct command *cmd, struct vddk_handle *h) @@ -45,7 +45,7 @@ index 076b2bd7..6efcc6f6 100644 VDDK_CALL_START (VixDiskLib_QueryAllocatedBlocks, "handle, 0, %d sectors, %d sectors", VIXDISKLIB_MIN_CHUNK_SIZE, VIXDISKLIB_MIN_CHUNK_SIZE) -@@ -502,6 +504,10 @@ vddk_worker_thread (void *handle) +@@ -505,6 +507,10 @@ vddk_worker_thread (void *handle) { struct vddk_handle *h = handle; bool stop = false; @@ -56,7 +56,7 @@ index 076b2bd7..6efcc6f6 100644 while (!stop) { struct command *cmd; -@@ -544,12 +550,13 @@ vddk_worker_thread (void *handle) +@@ -547,12 +553,13 @@ vddk_worker_thread (void *handle) break; case CAN_EXTENTS: diff --git a/0006-file-Reduce-the-size-of-the-lock-around-write-evicti.patch b/0006-file-Reduce-the-size-of-the-lock-around-write-evicti.patch deleted file mode 100644 index 4d65703..0000000 --- a/0006-file-Reduce-the-size-of-the-lock-around-write-evicti.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 15d235587c14dcbc9a98197921994bc6e2d505d8 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 1 Apr 2025 11:56:22 +0100 -Subject: [PATCH] file: Reduce the size of the lock around write eviction - -Previously we held window_lock during the synchronous eviction of the -oldest window. This potentially serializes all writes in the slow -write case. We don't need to hold the lock here. - -(cherry picked from commit d3d2bc45bb59a30669a3d926435cf57e99feb3a2) ---- - plugins/file/file.c | 52 +++++++++++++++++++++++++++------------------ - 1 file changed, 31 insertions(+), 21 deletions(-) - -diff --git a/plugins/file/file.c b/plugins/file/file.c -index aa552037..d1e91203 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -121,37 +121,47 @@ static struct write_window window[NR_WINDOWS]; - static int - evict_writes (int fd, uint64_t offset, size_t len) - { -- ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&window_lock); -- -- /* Tell Linux to start writing the current range out to disk -- * (asynchronously). -- */ -- if (sync_file_range (fd, offset, len, SYNC_FILE_RANGE_WRITE) == -1) { -- nbdkit_error ("sync_file_range: cache=none: starting eviction: %m"); -- return -1; -+ struct write_window oldest = { 0 }; -+ -+ { -+ ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&window_lock); -+ -+ /* Save oldest window[0] for eviction below, and move all windows -+ * down one. Set the newest slot to empty. -+ */ -+ oldest = window[0]; -+ memmove (&window[0], &window[1], sizeof window[0] * (NR_WINDOWS-1)); -+ window[NR_WINDOWS-1].len = 0; -+ -+ /* Tell Linux to start writing the current range out to disk -+ * (asynchronously). -+ */ -+ if (sync_file_range (fd, offset, len, SYNC_FILE_RANGE_WRITE) == -1) { -+ nbdkit_error ("sync_file_range: cache=none: starting eviction: %m"); -+ return -1; -+ } -+ -+ /* Add the range to the newest end of the list of windows. */ -+ window[NR_WINDOWS-1].fd = fd; -+ window[NR_WINDOWS-1].offset = offset; -+ window[NR_WINDOWS-1].len = len; - } -+ /* Release lock here. */ - -- /* Evict the oldest window from the page cache. */ -- if (window[0].len > 0) { -- if (sync_file_range (window[0].fd, window[0].offset, window[0].len, -- SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE| -+ /* Evict the oldest window from the page cache (synchronously). */ -+ if (oldest.len > 0) { -+ if (sync_file_range (oldest.fd, oldest.offset, oldest.len, -+ SYNC_FILE_RANGE_WAIT_BEFORE | -+ SYNC_FILE_RANGE_WRITE | - SYNC_FILE_RANGE_WAIT_AFTER) == -1) { - nbdkit_error ("sync_file_range: cache=none: evicting oldest window: %m"); - return -1; - } -- if (posix_fadvise (window[0].fd, window[0].offset, window[0].len, -+ if (posix_fadvise (oldest.fd, oldest.offset, oldest.len, - POSIX_FADV_DONTNEED) == -1) - nbdkit_debug ("posix_fadvise: POSIX_FADV_DONTNEED: (ignored): %m"); - } - -- /* Move the Nth window to N-1. */ -- memmove (&window[0], &window[1], sizeof window[0] * (NR_WINDOWS-1)); -- -- /* Add the range to the newest end of the list of windows. */ -- window[NR_WINDOWS-1].fd = fd; -- window[NR_WINDOWS-1].offset = offset; -- window[NR_WINDOWS-1].len = len; -- - return 0; - } - --- -2.47.1 - diff --git a/0023-vddk-Pre-cache-the-extents-for-readonly-connections.patch b/0006-vddk-Pre-cache-the-extents-for-readonly-connections.patch similarity index 98% rename from 0023-vddk-Pre-cache-the-extents-for-readonly-connections.patch rename to 0006-vddk-Pre-cache-the-extents-for-readonly-connections.patch index ef46fc5..7ed08c2 100644 --- a/0023-vddk-Pre-cache-the-extents-for-readonly-connections.patch +++ b/0006-vddk-Pre-cache-the-extents-for-readonly-connections.patch @@ -1,4 +1,4 @@ -From 3be0221d8cbf5cc916efb9975b4f6a2d85044991 Mon Sep 17 00:00:00 2001 +From f93b05e7e6f7edd03cc73e154d53386e66216070 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 30 May 2025 15:06:07 +0100 Subject: [PATCH] vddk: Pre-cache the extents for readonly connections @@ -127,10 +127,10 @@ it is never used.) 3 files changed, 170 insertions(+), 1 deletion(-) diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c -index 60f75b51..3c63014e 100644 +index 3c8bb03a..a13698a3 100644 --- a/plugins/vddk/vddk.c +++ b/plugins/vddk/vddk.c -@@ -843,6 +843,8 @@ vddk_close (void *handle) +@@ -845,6 +845,8 @@ vddk_close (void *handle) send_command_and_wait (h, &stop_cmd); pthread_join (h->thread, NULL); @@ -154,7 +154,7 @@ index 3586c5da..461fb528 100644 /* reexec.c */ diff --git a/plugins/vddk/worker.c b/plugins/vddk/worker.c -index 6efcc6f6..3925fb91 100644 +index b3a5180e..27f56e37 100644 --- a/plugins/vddk/worker.c +++ b/plugins/vddk/worker.c @@ -37,6 +37,7 @@ @@ -174,7 +174,7 @@ index 6efcc6f6..3925fb91 100644 { const uint32_t count = cmd->count; const uint64_t offset = cmd->offset; -@@ -496,6 +497,169 @@ do_extents (struct command *cmd, struct vddk_handle *h) +@@ -499,6 +500,169 @@ do_extents (struct command *cmd, struct vddk_handle *h) return 0; } diff --git a/0007-file-Document-implicit-assumption-about-eviction-win.patch b/0007-file-Document-implicit-assumption-about-eviction-win.patch deleted file mode 100644 index 9da3655..0000000 --- a/0007-file-Document-implicit-assumption-about-eviction-win.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 72d95a4563149dfda0502ef28f06c7f7f972bd75 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Tue, 1 Apr 2025 16:51:24 +0100 -Subject: [PATCH] file: Document implicit assumption about eviction windows - -Add a comment that slots in the window list are only valid when len > 0. -This was true before but only implicit. - -(cherry picked from commit 2022ac667f3c1de81b692f0128dd83a7c4999e38) ---- - 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 d1e91203..b8470c20 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -112,7 +112,7 @@ static enum { cache_default, cache_none } cache_mode = cache_default; - struct write_window { - int fd; - uint64_t offset; -- size_t len; -+ size_t len; /* window slot only valid if len > 0 */ - }; - - static pthread_mutex_t window_lock = PTHREAD_MUTEX_INITIALIZER; --- -2.47.1 - diff --git a/0024-file-Save-the-filename-or-equivalent-in-the-file-han.patch b/0007-file-Save-the-filename-or-equivalent-in-the-file-han.patch similarity index 98% rename from 0024-file-Save-the-filename-or-equivalent-in-the-file-han.patch rename to 0007-file-Save-the-filename-or-equivalent-in-the-file-han.patch index d8c64b9..d71462c 100644 --- a/0024-file-Save-the-filename-or-equivalent-in-the-file-han.patch +++ b/0007-file-Save-the-filename-or-equivalent-in-the-file-han.patch @@ -1,4 +1,4 @@ -From 0f2fc18c423dc3f5aef5a2d38c918905b4fbc6ef Mon Sep 17 00:00:00 2001 +From f048b5dd411ab4ada0f4b57fb27fee84908a6d7f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 4 Jun 2025 21:00:47 +0100 Subject: [PATCH] file: Save the filename or equivalent in the file handle @@ -14,7 +14,7 @@ a common error path in the file_open function. 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/plugins/file/file.c b/plugins/file/file.c -index dc100bb3..4dec4bd9 100644 +index 94adc43d..13898af1 100644 --- a/plugins/file/file.c +++ b/plugins/file/file.c @@ -500,6 +500,7 @@ file_list_exports (int readonly, int default_only, diff --git a/0025-file-Add-the-filename-or-equivalent-to-error-message.patch b/0008-file-Add-the-filename-or-equivalent-to-error-message.patch similarity index 81% rename from 0025-file-Add-the-filename-or-equivalent-to-error-message.patch rename to 0008-file-Add-the-filename-or-equivalent-to-error-message.patch index fd7f6b5..317b06f 100644 --- a/0025-file-Add-the-filename-or-equivalent-to-error-message.patch +++ b/0008-file-Add-the-filename-or-equivalent-to-error-message.patch @@ -1,4 +1,4 @@ -From 53f5fa4e1f560475dadbefc1f00e0f3d2ca84ca0 Mon Sep 17 00:00:00 2001 +From 33e8a5b15a4edf5ea03d3f339e1580855c746fcf Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 4 Jun 2025 21:03:58 +0100 Subject: [PATCH] file: Add the filename (or equivalent) to error messages @@ -14,7 +14,7 @@ passed by the client. 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/plugins/file/file.c b/plugins/file/file.c -index 4dec4bd9..8018b294 100644 +index 13898af1..2bba7e77 100644 --- a/plugins/file/file.c +++ b/plugins/file/file.c @@ -797,7 +797,7 @@ file_get_size (void *handle) @@ -49,7 +49,7 @@ index 4dec4bd9..8018b294 100644 return -1; } buf += r; -@@ -940,7 +940,7 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, +@@ -939,7 +939,7 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, while (count > 0) { ssize_t r = pwrite (h->fd, buf, count, offset); if (r == -1) { @@ -58,7 +58,7 @@ index 4dec4bd9..8018b294 100644 return -1; } buf += r; -@@ -1022,7 +1022,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1021,7 +1021,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (!is_enotsup (errno)) { @@ -67,7 +67,7 @@ index 4dec4bd9..8018b294 100644 return -1; } -@@ -1058,7 +1058,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1057,7 +1057,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (!is_enotsup (errno)) { @@ -76,7 +76,7 @@ index 4dec4bd9..8018b294 100644 return -1; } -@@ -1066,7 +1066,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1065,7 +1065,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } else { if (!is_enotsup (errno)) { @@ -85,7 +85,7 @@ index 4dec4bd9..8018b294 100644 return -1; } -@@ -1088,7 +1088,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1087,7 +1087,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (!is_enotsup (errno)) { @@ -94,7 +94,7 @@ index 4dec4bd9..8018b294 100644 return -1; } -@@ -1116,14 +1116,14 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1115,14 +1115,14 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (!is_enotsup (errno)) { @@ -111,7 +111,7 @@ index 4dec4bd9..8018b294 100644 return -1; } -@@ -1147,7 +1147,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1146,7 +1146,7 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (errno != ENOTTY) { @@ -120,16 +120,16 @@ index 4dec4bd9..8018b294 100644 return -1; } -@@ -1185,7 +1185,7 @@ file_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) - /* Trim is advisory; we don't care if it fails for anything other - * than EIO or EPERM. */ - if (errno == EPERM || errno == EIO) { +@@ -1183,7 +1183,7 @@ file_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + offset, count); + if (r == -1) { + if (!is_enotsup (errno)) { - nbdkit_error ("fallocate: %m"); + nbdkit_error ("fallocate: %s: %m", h->name); return -1; } -@@ -1306,7 +1306,7 @@ file_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1322,7 +1322,7 @@ file_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) r = posix_fadvise (h->fd, offset, count, POSIX_FADV_WILLNEED); if (r) { errno = r; diff --git a/0008-server-Turn-flush-into-a-controlpath-message.patch b/0008-server-Turn-flush-into-a-controlpath-message.patch deleted file mode 100644 index ab390bd..0000000 --- a/0008-server-Turn-flush-into-a-controlpath-message.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 68b8aed947fdb5708963972417ec6bb48ae63d9a Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sat, 5 Apr 2025 09:02:03 +0100 -Subject: [PATCH] server: Turn flush into a controlpath message - -The server debug flags -D nbdkit.backend.controlpath= and --D nbdkit.backend.datapath= control the verbosity of messages. - -'flush' was categorized as a datapath message, but it's more arguably -a controlpath message, and anyway it is rare and useful to see in -virt-v2v output even when datapath messages are suppressed. - -(cherry picked from commit 079c8a91bf5161614916470dcb1f52bee8bfb397) ---- - server/backend.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/server/backend.c b/server/backend.c -index 6232b69d..1f1bcfce 100644 ---- a/server/backend.c -+++ b/server/backend.c -@@ -693,7 +693,7 @@ backend_flush (struct context *c, - assert (c->handle && (c->state & HANDLE_CONNECTED)); - assert (c->can_flush == 1); - assert (flags == 0); -- datapath_debug ("%s: flush", b->name); -+ controlpath_debug ("%s: flush", b->name); - - r = b->flush (c, flags, err); - if (r == -1) --- -2.47.1 - diff --git a/0026-file-Add-offset-count-to-error-messages.patch b/0009-file-Add-offset-count-to-error-messages.patch similarity index 82% rename from 0026-file-Add-offset-count-to-error-messages.patch rename to 0009-file-Add-offset-count-to-error-messages.patch index e687e2d..737e289 100644 --- a/0026-file-Add-offset-count-to-error-messages.patch +++ b/0009-file-Add-offset-count-to-error-messages.patch @@ -1,4 +1,4 @@ -From 817bacccc1f44a060a4250ff9e6a27086be09d8b Mon Sep 17 00:00:00 2001 +From 84362587e5bb53e113c65d9876cf5b3c39174bab Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Wed, 4 Jun 2025 21:15:26 +0100 Subject: [PATCH] file: Add offset/count to error messages @@ -13,7 +13,7 @@ be useful occasionally, ensure it is captured in errors. 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/plugins/file/file.c b/plugins/file/file.c -index 8018b294..e62e2437 100644 +index 2bba7e77..ef40b400 100644 --- a/plugins/file/file.c +++ b/plugins/file/file.c @@ -904,7 +904,8 @@ file_pread (void *handle, void *buf, uint32_t count, uint64_t offset, @@ -26,7 +26,7 @@ index 8018b294..e62e2437 100644 return -1; } if (r == 0) { -@@ -940,7 +941,8 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, +@@ -939,7 +940,8 @@ file_pwrite (void *handle, const void *buf, uint32_t count, uint64_t offset, while (count > 0) { ssize_t r = pwrite (h->fd, buf, count, offset); if (r == -1) { @@ -36,7 +36,7 @@ index 8018b294..e62e2437 100644 return -1; } buf += r; -@@ -1022,7 +1024,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1021,7 +1023,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (!is_enotsup (errno)) { @@ -46,7 +46,7 @@ index 8018b294..e62e2437 100644 return -1; } -@@ -1058,7 +1061,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1057,7 +1060,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (!is_enotsup (errno)) { @@ -56,7 +56,7 @@ index 8018b294..e62e2437 100644 return -1; } -@@ -1066,7 +1070,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1065,7 +1069,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } else { if (!is_enotsup (errno)) { @@ -66,7 +66,7 @@ index 8018b294..e62e2437 100644 return -1; } -@@ -1088,7 +1093,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1087,7 +1092,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (!is_enotsup (errno)) { @@ -76,7 +76,7 @@ index 8018b294..e62e2437 100644 return -1; } -@@ -1116,14 +1122,16 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1115,14 +1121,16 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (!is_enotsup (errno)) { @@ -95,7 +95,7 @@ index 8018b294..e62e2437 100644 return -1; } -@@ -1147,7 +1155,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1146,7 +1154,8 @@ file_zero (void *handle, uint32_t count, uint64_t offset, uint32_t flags) } if (errno != ENOTTY) { @@ -105,10 +105,10 @@ index 8018b294..e62e2437 100644 return -1; } -@@ -1185,7 +1194,9 @@ file_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) - /* Trim is advisory; we don't care if it fails for anything other - * than EIO or EPERM. */ - if (errno == EPERM || errno == EIO) { +@@ -1183,7 +1192,9 @@ file_trim (void *handle, uint32_t count, uint64_t offset, uint32_t flags) + offset, count); + if (r == -1) { + if (!is_enotsup (errno)) { - nbdkit_error ("fallocate: %s: %m", h->name); + nbdkit_error ("fallocate: %s: offset=%" PRIu64 ", count=%" PRIu32 ":" + " %m", @@ -116,7 +116,7 @@ index 8018b294..e62e2437 100644 return -1; } -@@ -1306,7 +1317,9 @@ file_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) +@@ -1322,7 +1333,9 @@ file_cache (void *handle, uint32_t count, uint64_t offset, uint32_t flags) r = posix_fadvise (h->fd, offset, count, POSIX_FADV_WILLNEED); if (r) { errno = r; diff --git a/0009-file-Fix-minor-typo-in-debug-message.patch b/0009-file-Fix-minor-typo-in-debug-message.patch deleted file mode 100644 index 8f4ede9..0000000 --- a/0009-file-Fix-minor-typo-in-debug-message.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 4edf62487072d6e61b95bed6ca55750bf3110ae4 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) ---- - 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 b8470c20..8e4acedd 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -989,7 +989,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/0010-file-Add-more-debugging-when-D-file.zero-1-is-used.patch b/0010-file-Add-more-debugging-when-D-file.zero-1-is-used.patch deleted file mode 100644 index 0c69654..0000000 --- a/0010-file-Add-more-debugging-when-D-file.zero-1-is-used.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 9db29d77149a7bed9daef9f35a584d798e8f22f0 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) ---- - 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 8e4acedd..a49c11e9 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -944,7 +944,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/0029-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch b/0010-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch similarity index 94% rename from 0029-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch rename to 0010-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch index 84bd06d..dbd374f 100644 --- a/0029-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch +++ b/0010-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch @@ -1,4 +1,4 @@ -From 3cbde587c10dbe4da016eaf6a2d45dc09fac1858 Mon Sep 17 00:00:00 2001 +From f6cbb39d3db9b138b98e9d5af3f50e430520302f Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 8 Jun 2025 10:40:26 +0100 Subject: [PATCH] vddk: stats: Record the byte count of each @@ -23,7 +23,7 @@ nbdkit: debug: Exit 1001407 1 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/vddk/worker.c b/plugins/vddk/worker.c -index 3925fb91..feb8d96f 100644 +index 27f56e37..bb088418 100644 --- a/plugins/vddk/worker.c +++ b/plugins/vddk/worker.c @@ -327,7 +327,8 @@ test_can_extents (struct vddk_handle *h) @@ -46,7 +46,7 @@ index 3925fb91..feb8d96f 100644 if (err != VIX_OK) { VDDK_ERROR (err, "VixDiskLib_QueryAllocatedBlocks"); return -1; -@@ -532,7 +534,8 @@ pre_cache_extents (struct vddk_handle *h) +@@ -535,7 +537,8 @@ pre_cache_extents (struct vddk_handle *h) start_sector, nr_sectors, VIXDISKLIB_MIN_CHUNK_SIZE, &block_list); diff --git a/0011-file-Fix-comment-style-in-a-few-places.patch b/0011-file-Fix-comment-style-in-a-few-places.patch deleted file mode 100644 index 7adb5f7..0000000 --- a/0011-file-Fix-comment-style-in-a-few-places.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 1df73694a75a6dc353bf15a277164f21e6e66227 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) ---- - 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 a49c11e9..c381c1e2 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -957,7 +957,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; -@@ -1014,9 +1015,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/0030-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch b/0011-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch similarity index 97% rename from 0030-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch rename to 0011-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch index a368bd5..53eb39f 100644 --- a/0030-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch +++ b/0011-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch @@ -1,4 +1,4 @@ -From 9de0cd7c25acb8eaa47cb128fa15053235eb433f Mon Sep 17 00:00:00 2001 +From bd7a0bbbdc36844662f4018d37f05c40452c6763 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 8 Jun 2025 10:59:57 +0100 Subject: [PATCH] vddk: stats: Collect elapsed time for ReadAsync and @@ -34,10 +34,10 @@ increases the apparent elapsed time in the remote case. 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/plugins/vddk/nbdkit-vddk-plugin.pod b/plugins/vddk/nbdkit-vddk-plugin.pod -index 279da2d0..a375e152 100644 +index 7cf938de..18486d75 100644 --- a/plugins/vddk/nbdkit-vddk-plugin.pod +++ b/plugins/vddk/nbdkit-vddk-plugin.pod -@@ -724,8 +724,7 @@ Same as above, but for writing and flushing writes. +@@ -723,8 +723,7 @@ Same as above, but for writing and flushing writes. =item C Same as above, but for asynchronous read and write calls introduced in @@ -124,7 +124,7 @@ index 461fb528..5ff02649 100644 extern void trim (char *str); diff --git a/plugins/vddk/worker.c b/plugins/vddk/worker.c -index feb8d96f..9d3a5940 100644 +index bb088418..d26574ef 100644 --- a/plugins/vddk/worker.c +++ b/plugins/vddk/worker.c @@ -120,6 +120,11 @@ complete_command (void *vp, VixError result) diff --git a/0012-file-Fix-do_fallocate-debugging-on-Alpine.patch b/0012-file-Fix-do_fallocate-debugging-on-Alpine.patch deleted file mode 100644 index d36a62a..0000000 --- a/0012-file-Fix-do_fallocate-debugging-on-Alpine.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 6f64ded91340340ab803abadf0542d953e6bf2d5 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) ---- - 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 c381c1e2..00aa5416 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -940,7 +940,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) - { -@@ -949,9 +949,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/0013-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch b/0013-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch deleted file mode 100644 index 64eefa4..0000000 --- a/0013-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 6653df377b97d817a1984076cb744c01c86ecf97 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) ---- - 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 00aa5416..a649ccd7 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -506,7 +506,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 -@@ -746,7 +746,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; - } -@@ -1063,14 +1063,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; - } -@@ -1080,7 +1080,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/0014-file-zero-Document-implicit-order-that-we-will-try-z.patch b/0014-file-zero-Document-implicit-order-that-we-will-try-z.patch deleted file mode 100644 index ce07026..0000000 --- a/0014-file-zero-Document-implicit-order-that-we-will-try-z.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 661bb729bfcba63842840c32dc8cd0e778e38b21 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) ---- - 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 a649ccd7..d7405f36 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -981,9 +981,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/0015-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch b/0015-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch deleted file mode 100644 index 073a9f6..0000000 --- a/0015-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch +++ /dev/null @@ -1,122 +0,0 @@ -From cf35037d52c2abf383fc3e8db00283a58ffc53db 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) ---- - 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 d7405f36..dc100bb3 100644 ---- a/plugins/file/file.c -+++ b/plugins/file/file.c -@@ -404,6 +404,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 -@@ -506,6 +509,7 @@ struct handle { - bool can_punch_hole; - bool can_zero_range; - bool can_fallocate; -+ bool can_blkdiscard; - bool can_blkzeroout; - }; - -@@ -747,6 +751,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; - } -@@ -1009,6 +1014,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 43fc23c7..f1b33582 100644 ---- a/plugins/file/nbdkit-file-plugin.pod -+++ b/plugins/file/nbdkit-file-plugin.pod -@@ -237,6 +237,11 @@ block devices. - 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/0016-vddk-Debug-length-of-extents-when-using-D-vddk.exten.patch b/0016-vddk-Debug-length-of-extents-when-using-D-vddk.exten.patch deleted file mode 100644 index 30161f3..0000000 --- a/0016-vddk-Debug-length-of-extents-when-using-D-vddk.exten.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 27736bb9e22f6c86b1a19fc02668dd04f6fc8bd0 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Thu, 29 May 2025 09:15:33 +0000 -Subject: [PATCH] vddk: Debug length of extents when using -D vddk.extents=1 - -(cherry picked from commit a53746d326e08fae9ec1ea782df740abb48d0114) ---- - plugins/vddk/worker.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/plugins/vddk/worker.c b/plugins/vddk/worker.c -index 8a91250a..c61c4d16 100644 ---- a/plugins/vddk/worker.c -+++ b/plugins/vddk/worker.c -@@ -375,9 +375,10 @@ add_extent (struct nbdkit_extents *extents, - return 0; - - if (vddk_debug_extents) -- nbdkit_debug ("adding extent type %s at [%" PRIu64 "...%" PRIu64 "]", -+ nbdkit_debug ("adding extent type %s at [%" PRIu64 "...%" PRIu64 "] " -+ "(length %" PRIu64 ")", - is_hole ? "hole" : "allocated data", -- *position, next_position-1); -+ *position, next_position-1, length); - if (nbdkit_add_extent (extents, *position, length, type) == -1) - return -1; - --- -2.47.1 - diff --git a/0017-cacheextents-Mark-this-filter-as-deprecated.patch b/0017-cacheextents-Mark-this-filter-as-deprecated.patch deleted file mode 100644 index b5d05cc..0000000 --- a/0017-cacheextents-Mark-this-filter-as-deprecated.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 85499cfd9c282d986ee8964d0404ccdf25733a6a Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sat, 31 May 2025 08:12:32 +0100 -Subject: [PATCH] cacheextents: Mark this filter as deprecated - -We will remove it in nbdkit 1.46. - -Its usage was removed from virt-v2v because we found that it did not -do anything: -https://github.com/libguestfs/virt-v2v/commit/48c4ce8e6cf6f1c390a48245ef0f99233f80cfe8 - -(cherry picked from commit 9717c47999fb2f56c3569cf1cdd4d0c160f866c1) ---- - filters/cacheextents/nbdkit-cacheextents-filter.pod | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/filters/cacheextents/nbdkit-cacheextents-filter.pod b/filters/cacheextents/nbdkit-cacheextents-filter.pod -index c3d89465..0693ca80 100644 ---- a/filters/cacheextents/nbdkit-cacheextents-filter.pod -+++ b/filters/cacheextents/nbdkit-cacheextents-filter.pod -@@ -6,6 +6,14 @@ nbdkit-cacheextents-filter - cache extents - - nbdkit --filter=cacheextents plugin - -+=head1 DEPRECATED -+ -+B 1.43.10> and -+will be removed in S>. There is no direct replacement, -+but as the filter only worked for a narrow and unusual range of access -+patterns it is likely that it has no effect and you can just stop -+using it. -+ - =head1 DESCRIPTION - - C is a filter that caches the result of last --- -2.47.1 - diff --git a/0018-include-Move-some-extent-functions-to-nbdkit-common..patch b/0018-include-Move-some-extent-functions-to-nbdkit-common..patch deleted file mode 100644 index 98a6cd2..0000000 --- a/0018-include-Move-some-extent-functions-to-nbdkit-common..patch +++ /dev/null @@ -1,77 +0,0 @@ -From 2282c37faa556339ff6ce0557866c171f2e9ee29 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sat, 31 May 2025 08:04:41 +0100 -Subject: [PATCH] include: Move some extent functions to nbdkit-common.h - -No existing plugins use the extent functions nbdkit_extents_new, -nbdkit_extents_free, etc, since they are mainly useful for filters so -they can build and manipulate new lists of extents. Nevertheless -there is nothing that prevents them from being used in plugins, so -move those functions to the common header (so they appear for users of -) - -There are a couple of helper functions which are really -filter-specific so leave those in nbdkit-filter.h. - -(cherry picked from commit 03792d04f270f2cffc589dd9703c9de9c3d5a65e) ---- - include/nbdkit-common.h | 15 +++++++++++++++ - include/nbdkit-filter.h | 15 +-------------- - 2 files changed, 16 insertions(+), 14 deletions(-) - -diff --git a/include/nbdkit-common.h b/include/nbdkit-common.h -index 43d674aa..bb5e3e55 100644 ---- a/include/nbdkit-common.h -+++ b/include/nbdkit-common.h -@@ -157,7 +157,22 @@ NBDKIT_EXTERN_DECL (const char *, nbdkit_vprintf_intern, - (const char *msg, va_list args) - ATTRIBUTE_FORMAT_PRINTF (1, 0)); - -+/* Extent functions. */ -+struct nbdkit_extent { -+ uint64_t offset; -+ uint64_t length; -+ uint32_t type; -+}; -+ - struct nbdkit_extents; -+ -+NBDKIT_EXTERN_DECL (struct nbdkit_extents *, nbdkit_extents_new, -+ (uint64_t start, uint64_t end)); -+NBDKIT_EXTERN_DECL (void, nbdkit_extents_free, (struct nbdkit_extents *)); -+NBDKIT_EXTERN_DECL (size_t, nbdkit_extents_count, -+ (const struct nbdkit_extents *)); -+NBDKIT_EXTERN_DECL (struct nbdkit_extent, nbdkit_get_extent, -+ (const struct nbdkit_extents *, size_t)); - NBDKIT_EXTERN_DECL (int, nbdkit_add_extent, - (struct nbdkit_extents *, - uint64_t offset, uint64_t length, uint32_t type)); -diff --git a/include/nbdkit-filter.h b/include/nbdkit-filter.h -index a4ac09d4..31520bf5 100644 ---- a/include/nbdkit-filter.h -+++ b/include/nbdkit-filter.h -@@ -121,20 +121,7 @@ struct nbdkit_next_ops { - */ - }; - --/* Extent functions. */ --struct nbdkit_extent { -- uint64_t offset; -- uint64_t length; -- uint32_t type; --}; -- --NBDKIT_EXTERN_DECL (struct nbdkit_extents *, nbdkit_extents_new, -- (uint64_t start, uint64_t end)); --NBDKIT_EXTERN_DECL (void, nbdkit_extents_free, (struct nbdkit_extents *)); --NBDKIT_EXTERN_DECL (size_t, nbdkit_extents_count, -- (const struct nbdkit_extents *)); --NBDKIT_EXTERN_DECL (struct nbdkit_extent, nbdkit_get_extent, -- (const struct nbdkit_extents *, size_t)); -+/* Extent helpers. */ - NBDKIT_EXTERN_DECL (struct nbdkit_extents *, nbdkit_extents_full, - (nbdkit_next *next, - uint32_t count, uint64_t offset, --- -2.47.1 - diff --git a/0019-vddk-Display-command-type-in-command-completed-messa.patch b/0019-vddk-Display-command-type-in-command-completed-messa.patch deleted file mode 100644 index 184d166..0000000 --- a/0019-vddk-Display-command-type-in-command-completed-messa.patch +++ /dev/null @@ -1,29 +0,0 @@ -From ae0556bd62bd7578986026321866e122bd228689 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Fri, 30 May 2025 13:29:28 +0100 -Subject: [PATCH] vddk: Display command type in command completed message - -Useful extra debugging. - -(cherry picked from commit 81d4d74fecf3c071e144a8ba016f43ba1de1b093) ---- - plugins/vddk/worker.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/plugins/vddk/worker.c b/plugins/vddk/worker.c -index c61c4d16..3bf1d5c2 100644 ---- a/plugins/vddk/worker.c -+++ b/plugins/vddk/worker.c -@@ -116,7 +116,8 @@ complete_command (void *vp, VixError result) - struct command *cmd = vp; - - if (vddk_debug_datapath) -- nbdkit_debug ("command %" PRIu64 " completed", cmd->id); -+ nbdkit_debug ("command %" PRIu64 " (%s) completed", -+ cmd->id, command_type_string (cmd->type)); - - ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&cmd->mutex); - --- -2.47.1 - diff --git a/0027-vddk-stats-Use-us-instead-of-Unicode-s-for-microseco.patch b/0027-vddk-stats-Use-us-instead-of-Unicode-s-for-microseco.patch deleted file mode 100644 index b1590e0..0000000 --- a/0027-vddk-stats-Use-us-instead-of-Unicode-s-for-microseco.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 72d9a049af483990d446de740e6da9f0420f723a Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sun, 8 Jun 2025 10:44:32 +0100 -Subject: [PATCH] =?UTF-8?q?vddk:=20stats:=20Use=20"us"=20instead=20of=20(U?= - =?UTF-8?q?nicode)=20"=C2=B5s"=20for=20microseconds?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -nbdkit_debug uses C-style escaping for non-ASCII characters in debug -strings, so in logs what we actually see is "\xc2\xb5s" which messes -up the columns. - -(cherry picked from commit 1f09bb4abefe8f3f052e8c0b6b34d314887b3c32) ---- - plugins/vddk/stats.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/plugins/vddk/stats.c b/plugins/vddk/stats.c -index 7f63333a..59cfee5a 100644 ---- a/plugins/vddk/stats.c -+++ b/plugins/vddk/stats.c -@@ -98,7 +98,7 @@ display_stats (void) - - nbdkit_debug ("VDDK function stats (-D vddk.stats=1):"); - nbdkit_debug ("%-24s %15s %5s %15s", -- "VixDiskLib_...", "µs", "calls", "bytes"); -+ "VixDiskLib_...", "us", "calls", "bytes"); - for (i = 0; i < stats.len; ++i) { - if (stats.ptr[i].usecs) { - if (stats.ptr[i].bytes > 0) --- -2.47.1 - diff --git a/0028-vddk-stats-Line-up-the-columns-correctly.patch b/0028-vddk-stats-Line-up-the-columns-correctly.patch deleted file mode 100644 index 5b262b2..0000000 --- a/0028-vddk-stats-Line-up-the-columns-correctly.patch +++ /dev/null @@ -1,26 +0,0 @@ -From a36ec14b115a84c9aa8a1341e5f0a8a4576c7e02 Mon Sep 17 00:00:00 2001 -From: "Richard W.M. Jones" -Date: Sun, 8 Jun 2025 11:04:41 +0100 -Subject: [PATCH] vddk: stats: Line up the columns correctly - -(cherry picked from commit 7da09b07148cc12c3214b18bc96c65ed45625dde) ---- - plugins/vddk/stats.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/plugins/vddk/stats.c b/plugins/vddk/stats.c -index 59cfee5a..b551fc5a 100644 ---- a/plugins/vddk/stats.c -+++ b/plugins/vddk/stats.c -@@ -97,7 +97,7 @@ display_stats (void) - qsort (stats.ptr, stats.len, sizeof stats.ptr[0], stat_compare); - - nbdkit_debug ("VDDK function stats (-D vddk.stats=1):"); -- nbdkit_debug ("%-24s %15s %5s %15s", -+ nbdkit_debug ("%-24s %15s %5s %15s", - "VixDiskLib_...", "us", "calls", "bytes"); - for (i = 0; i < stats.len; ++i) { - if (stats.ptr[i].usecs) { --- -2.47.1 - diff --git a/0031-server-Fix-off-by-one-for-maximum-block_status-lengt.patch b/0031-server-Fix-off-by-one-for-maximum-block_status-lengt.patch deleted file mode 100644 index eb3b927..0000000 --- a/0031-server-Fix-off-by-one-for-maximum-block_status-lengt.patch +++ /dev/null @@ -1,170 +0,0 @@ -From 50911e101dd707ba4586eef1a0542f00a35fd173 Mon Sep 17 00:00:00 2001 -From: Eric Blake -Date: Tue, 22 Apr 2025 17:01:12 -0500 -Subject: [PATCH] server: Fix off-by-one for maximum block_status length - [CVE-2025-47711] - -There has been an off-by-one bug in the code for .extents since the -introduction of that callback. Remember, internally the code allows -plugins to report on extents with 64-bit lengths, but the protocol -only supports 32-bit block status calls (nbdkit will need to create -plugin version 3 before it can support NBD's newer 64-bit block -status). As such, the server loop intentionally truncates a plugin's -large extent to 2**32-1 bytes. But in the process of checking whether -the loop should exit early, or if any additional extents should be -reported to the client, the server used 'pos > offset+count' instead -of >=, which is one byte too far. If the client has requested exactly -2**32-1 bytes, and the plugin's first extent has that same length, the -code erroneously proceeds on to the plugin's second extent. Worse, if -the plugin's first extent has 2**32 bytes or more, it was truncated to -2**31-1 bytes, but not completely handled, and the failure to exit the -loop early means that the server then fails the assertion: - -nbdkit: ../../server/protocol.c:505: extents_to_block_descriptors: -Assertion `e.length <= length' failed. - -The single-byte fix addresses both symptoms, while the added test -demonstrates both when run on older nbdkit (the protocol violation -when the plugin returns 2**32-1 bytes in the first extent, and the -assertion failure when the plugin returns 2**32 or more bytes in the -first extent). - -The problem can only be triggered by a client request for 2**32-1 -bytes; anything smaller is immune. The problem also does not occur -for plugins that do not return extents information beyond the client's -request, or if the first extent is smaller than the client's request. - -The ability to cause the server to die from an assertion failure can -be used as a denial of service attack against other clients. -Mitigations: if you require the use of TLS, then you can ensure that -you only have trusted clients that won't trigger a block status call -of length 2**32-1 bytes. Also, you can use "--filter=blocksize-policy -blocksize-minimum=512" to reject block status attempts from clients -that are not sector-aligned. - -Fixes: 26455d45 ('server: protocol: Implement Block Status "base:allocation".', v1.11.10) -Reported-by: Nikolay Ivanets -Signed-off-by: Eric Blake -Message-ID: <20250423211953.GR1450@redhat.com> -Reviewed-by: Richard W.M. Jones -(cherry picked from commit e6f96bd1b77c0cc927ce6aeff650b52238304f39) ---- - server/protocol.c | 2 +- - tests/Makefile.am | 2 ++ - tests/test-eval-extents.sh | 71 ++++++++++++++++++++++++++++++++++++++ - 3 files changed, 74 insertions(+), 1 deletion(-) - create mode 100755 tests/test-eval-extents.sh - -diff --git a/server/protocol.c b/server/protocol.c -index d428bfc8..b4b1c162 100644 ---- a/server/protocol.c -+++ b/server/protocol.c -@@ -499,7 +499,7 @@ extents_to_block_descriptors (struct nbdkit_extents *extents, - (*nr_blocks)++; - - pos += length; -- if (pos > offset + count) /* this must be the last block */ -+ if (pos >= offset + count) /* this must be the last block */ - break; - - /* If we reach here then we must have consumed this whole -diff --git a/tests/Makefile.am b/tests/Makefile.am -index 2b494b89..48cb84b5 100644 ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -877,6 +877,7 @@ TESTS += \ - test-eval.sh \ - test-eval-file.sh \ - test-eval-exports.sh \ -+ test-eval-extents.sh \ - test-eval-cache.sh \ - test-eval-dump-plugin.sh \ - test-eval-disconnect.sh \ -@@ -885,6 +886,7 @@ EXTRA_DIST += \ - test-eval.sh \ - test-eval-file.sh \ - test-eval-exports.sh \ -+ test-eval-extents.sh \ - test-eval-cache.sh \ - test-eval-dump-plugin.sh \ - test-eval-disconnect.sh \ -diff --git a/tests/test-eval-extents.sh b/tests/test-eval-extents.sh -new file mode 100755 -index 00000000..92b503e6 ---- /dev/null -+++ b/tests/test-eval-extents.sh -@@ -0,0 +1,71 @@ -+#!/usr/bin/env bash -+# nbdkit -+# Copyright Red Hat -+# -+# 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. -+ -+source ./functions.sh -+set -e -+set -x -+ -+requires_run -+requires_plugin eval -+requires_nbdsh_uri -+requires nbdsh --base-allocation --version -+ -+files="eval-extents.out" -+rm -f $files -+cleanup_fn rm -f $files -+ -+# Trigger an off-by-one bug introduced in v1.11.10 and fixed in v1.43.7 -+export script=' -+def f(context, offset, extents, status): -+ print(extents) -+ -+# First, probe where the server should return 2 extents. -+h.block_status(2**32-1, 2, f) -+ -+# Next, probe where the server has exactly 2**32-1 bytes in its first extent. -+h.block_status(2**32-1, 1, f) -+ -+# Now, probe where the first extent has to be truncated. -+h.block_status(2**32-1, 0, f) -+' -+nbdkit eval \ -+ get_size='echo 5G' \ -+ pread='dd if=/dev/zero count=$3 iflag=count_bytes' \ -+ extents='echo 0 4G 1; echo 4G 1G 2' \ -+ --run 'nbdsh --base-allocation --uri "$uri" -c "$script"' \ -+ > eval-extents.out -+cat eval-extents.out -+diff -u - eval-extents.out < -Date: Tue, 22 Apr 2025 19:53:39 -0500 -Subject: [PATCH] blocksize: Fix 32-bit overflow in .extents [CVE-2025-47712] - -If the original request is larger than 2**32 - minblock, then we were -calling nbdkit_extents_aligned() with a count that rounded up then -overflowed to 0 instead of the intended 4G because of overflowing a -32-bit type, which in turn causes an assertion failure: - -nbdkit: ../../server/backend.c:814: backend_extents: Assertion `backend_valid_range (c, offset, count)' failed. - -The fix is to force the rounding to be in a 64-bit type from the -get-go. - -The ability for a well-behaved client to cause the server to die from -an assertion failure can be used as a denial of service attack against -other clients. Mitigations: if you requrire the use of TLS, then you -can ensure that you only have trusted clients that won't trigger a -block status call that large. Also, the problem only occurs when -using the blocksize filter, although setting the filter's maxlen -parameter to a smaller value than its default of 2**32-1 does not -help. - -Fixes: 2680be00 ('blocksize: Fix .extents when plugin changes type within minblock', v1.21.16) -Signed-off-by: Eric Blake -Message-ID: <20250423210917.1784789-3-eblake@redhat.com> -Reviewed-by: Richard W.M. Jones -(cherry picked from commit a486f88d1eea653ea88b0bf8804c4825dab25ec7) ---- - filters/blocksize/blocksize.c | 5 +- - tests/Makefile.am | 2 + - tests/test-blocksize-extents-overflow.sh | 83 ++++++++++++++++++++++++ - 3 files changed, 88 insertions(+), 2 deletions(-) - create mode 100755 tests/test-blocksize-extents-overflow.sh - -diff --git a/filters/blocksize/blocksize.c b/filters/blocksize/blocksize.c -index 09195cea..e5c8b744 100644 ---- a/filters/blocksize/blocksize.c -+++ b/filters/blocksize/blocksize.c -@@ -482,8 +482,9 @@ blocksize_extents (nbdkit_next *next, - return -1; - } - -- if (nbdkit_extents_aligned (next, MIN (ROUND_UP (count, h->minblock), -- h->maxlen), -+ if (nbdkit_extents_aligned (next, -+ MIN (ROUND_UP ((uint64_t) count, h->minblock), -+ h->maxlen), - ROUND_DOWN (offset, h->minblock), flags, - h->minblock, extents2, err) == -1) - return -1; -diff --git a/tests/Makefile.am b/tests/Makefile.am -index 48cb84b5..00cb1618 100644 ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -1630,12 +1630,14 @@ test_layers_filter3_la_LIBADD = $(IMPORT_LIBRARY_ON_WINDOWS) - TESTS += \ - test-blocksize.sh \ - test-blocksize-extents.sh \ -+ test-blocksize-extents-overflow.sh \ - test-blocksize-default.sh \ - test-blocksize-sharding.sh \ - $(NULL) - EXTRA_DIST += \ - test-blocksize.sh \ - test-blocksize-extents.sh \ -+ test-blocksize-extents-overflow.sh \ - test-blocksize-default.sh \ - test-blocksize-sharding.sh \ - $(NULL) -diff --git a/tests/test-blocksize-extents-overflow.sh b/tests/test-blocksize-extents-overflow.sh -new file mode 100755 -index 00000000..844c3999 ---- /dev/null -+++ b/tests/test-blocksize-extents-overflow.sh -@@ -0,0 +1,83 @@ -+#!/usr/bin/env bash -+# nbdkit -+# Copyright Red Hat -+# -+# 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. -+ -+# Demonstrate a fix for a bug where blocksize overflowed 32 bits -+ -+source ./functions.sh -+set -e -+set -x -+ -+requires_run -+requires_plugin eval -+requires_nbdsh_uri -+requires nbdsh --base-allocation --version -+ -+# Script a sparse server that requires 512-byte aligned requests. -+exts=' -+if test $(( ($3|$4) & 511 )) != 0; then -+ echo "EINVAL request unaligned" 2>&1 -+ exit 1 -+fi -+echo 0 5G 0 -+' -+ -+# We also need an nbdsh script to parse all extents, coalescing adjacent -+# types for simplicity. -+# FIXME: Once nbdkit plugin version 3 allows 64-bit block extents, run -+# this test twice, once for each bit size (32-bit needs 2 extents, 64-bit -+# will get the same result with only 1 extent). -+export script=' -+size = h.get_size() -+offs = 0 -+entries = [] -+def f(metacontext, offset, e, err): -+ global entries -+ global offs -+ assert offs == offset -+ for length, flags in zip(*[iter(e)] * 2): -+ if entries and flags == entries[-1][1]: -+ entries[-1] = (entries[-1][0] + length, flags) -+ else: -+ entries.append((length, flags)) -+ offs = offs + length -+ -+# Test a loop over the entire device -+while offs < size: -+ len = min(size - offs, 2**32-1) -+ h.block_status(len, offs, f) -+assert entries == [(5 * 2**30, 0)] -+' -+ -+# Now run everything -+nbdkit --filter=blocksize eval minblock=512 \ -+ get_size='echo 5G' pread='exit 1' extents="$exts" \ -+ --run 'nbdsh --base-allocation -u "$uri" -c "$script"' --- -2.47.1 - diff --git a/nbdkit.spec b/nbdkit.spec index 5804c26..853d270 100644 --- a/nbdkit.spec +++ b/nbdkit.spec @@ -54,8 +54,8 @@ %global source_directory 1.42-stable Name: nbdkit -Version: 1.42.2 -Release: 8%{?dist} +Version: 1.42.5 +Release: 1%{?dist} Summary: NBD server License: BSD-3-Clause @@ -80,38 +80,17 @@ Source3: copy-patches.sh # https://gitlab.com/nbdkit/nbdkit/-/commits/rhel-10.1/ # Patches. -Patch0001: 0001-file-Add-debugging-if-sync_file_range-posix_fadvise-.patch -Patch0002: 0002-file-If-sync_file_range-fails-to-start-don-t-add-win.patch -Patch0003: 0003-tests-Add-tests-of-file-plugin-cache-none.patch -Patch0004: 0004-tests-Add-more-generic-tests-of-file-cache-none.patch -Patch0005: 0005-file-Hard-error-if-sync_file_range-fails.patch -Patch0006: 0006-file-Reduce-the-size-of-the-lock-around-write-evicti.patch -Patch0007: 0007-file-Document-implicit-assumption-about-eviction-win.patch -Patch0008: 0008-server-Turn-flush-into-a-controlpath-message.patch -Patch0009: 0009-file-Fix-minor-typo-in-debug-message.patch -Patch0010: 0010-file-Add-more-debugging-when-D-file.zero-1-is-used.patch -Patch0011: 0011-file-Fix-comment-style-in-a-few-places.patch -Patch0012: 0012-file-Fix-do_fallocate-debugging-on-Alpine.patch -Patch0013: 0013-file-Rename-h-can_zeroout-to-h-can_blkzeroout-to-ref.patch -Patch0014: 0014-file-zero-Document-implicit-order-that-we-will-try-z.patch -Patch0015: 0015-file-zero-Use-BLKDISCARD-method-if-may_trim-is-set.patch -Patch0016: 0016-vddk-Debug-length-of-extents-when-using-D-vddk.exten.patch -Patch0017: 0017-cacheextents-Mark-this-filter-as-deprecated.patch -Patch0018: 0018-include-Move-some-extent-functions-to-nbdkit-common..patch -Patch0019: 0019-vddk-Display-command-type-in-command-completed-messa.patch -Patch0020: 0020-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch -Patch0021: 0021-vddk-Move-minimum-version-of-VDDK-to-6.7.patch -Patch0022: 0022-vddk-Unconditionally-test-QueryAllocatedBlocks.patch -Patch0023: 0023-vddk-Pre-cache-the-extents-for-readonly-connections.patch -Patch0024: 0024-file-Save-the-filename-or-equivalent-in-the-file-han.patch -Patch0025: 0025-file-Add-the-filename-or-equivalent-to-error-message.patch -Patch0026: 0026-file-Add-offset-count-to-error-messages.patch -Patch0027: 0027-vddk-stats-Use-us-instead-of-Unicode-s-for-microseco.patch -Patch0028: 0028-vddk-stats-Line-up-the-columns-correctly.patch -Patch0029: 0029-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch -Patch0030: 0030-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch -Patch0031: 0031-server-Fix-off-by-one-for-maximum-block_status-lengt.patch -Patch0032: 0032-blocksize-Fix-32-bit-overflow-in-.extents-CVE-2025-4.patch +Patch0001: 0001-tests-Add-tests-of-file-plugin-cache-none.patch +Patch0002: 0002-tests-Add-more-generic-tests-of-file-cache-none.patch +Patch0003: 0003-vddk-Cache-the-readonly-flag-from-the-.open-call-in-.patch +Patch0004: 0004-vddk-Move-minimum-version-of-VDDK-to-6.7.patch +Patch0005: 0005-vddk-Unconditionally-test-QueryAllocatedBlocks.patch +Patch0006: 0006-vddk-Pre-cache-the-extents-for-readonly-connections.patch +Patch0007: 0007-file-Save-the-filename-or-equivalent-in-the-file-han.patch +Patch0008: 0008-file-Add-the-filename-or-equivalent-to-error-message.patch +Patch0009: 0009-file-Add-offset-count-to-error-messages.patch +Patch0010: 0010-vddk-stats-Record-the-byte-count-of-each-QueryAlloca.patch +Patch0011: 0011-vddk-stats-Collect-elapsed-time-for-ReadAsync-and-Wr.patch # For automatic RPM Provides generation. # See: https://rpm-software-management.github.io/rpm/manual/dependency_generators.html @@ -1554,12 +1533,12 @@ fi %changelog -* Mon Jun 09 2025 Richard W.M. Jones - 1.42.2-8 -- Rebase to nbdkit 1.42.2 +* Mon Jun 23 2025 Richard W.M. Jones - 1.42.5-1 +- Rebase to nbdkit 1.42.5 + resolves: RHEL-78830 - Synch the spec file with Fedora Rawhide. - nbdkit-ondemand-plugin moves into a new subpackage. - New nbdkit-time-limit-filter. - resolves: RHEL-78830 - Add extra system call checking and debugging to nbdkit-file-plugin resolves: RHEL-85515 - Allow nbdkit-file-plugin to zero and trim block devices @@ -1575,6 +1554,8 @@ fi - CVE-2025-47712 denial of service attack by client sending large unaligned size block status resolves: RHEL-95819 +- Add support for VDDK 9.0.0.0 + resolves: RHEL-99467 * Mon Jan 06 2025 Richard W.M. Jones - 1.40.4-3 - vddk: Avoid reading partial chunk beyond the end of the disk diff --git a/sources b/sources index cf82f3e..f207acc 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (nbdkit-1.42.2.tar.gz) = 007040b1a6e4653353305646af784aece194d6e8b66ce645774015a72ffb8863e70919fc13ec2b66bb762d7c963d5cbed02ac26b803b1202eff1a4183470ada3 -SHA512 (nbdkit-1.42.2.tar.gz.sig) = 8d356481c1005dc9d566e3de1ff9b695ae1c50182ebf4913476a6a15e7ad6ae2f529caef712b2a4156eda539236ba8f20896c335de27c91ef734d83ccc132050 +SHA512 (nbdkit-1.42.5.tar.gz) = 71cb0a287430b451aa200b0be5f440077c37b42c060db6c5ccbff34c2e6971c6fc411c0ff4921c8cb16b39c6091da24667524dccff5c578d3103a4ca9972e4d5 +SHA512 (nbdkit-1.42.5.tar.gz.sig) = bb2df86013951b86da60e65d313954ba76d72d82534f9fcff6d2808d40480ce81fbc8b65bc609155b3a8518bdeabb69ee4190b2e3668f52e8b40fc49027b7954