Rebase to libnbd 1.22.2

resolves: RHEL-78831
This commit is contained in:
Richard W.M. Jones 2025-04-22 22:19:36 +01:00
parent 854fda48eb
commit 8080daee4f
12 changed files with 40 additions and 228 deletions

View File

@ -1,4 +1,4 @@
From 782f779854de0665be8fd80af820091634985fa4 Mon Sep 17 00:00:00 2001
From de3038e45dde22cf85961966bfe9bcf6b45e2b14 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 29 Mar 2025 11:46:52 +0000
Subject: [PATCH] copy: Add --blkhash option
@ -36,20 +36,20 @@ Thanks: Nir Soffer
create mode 100755 copy/copy-blkhash-randfile.sh
diff --git a/copy/Makefile.am b/copy/Makefile.am
index c42accab..403f98ba 100644
index 0ca76450..c7e37058 100644
--- a/copy/Makefile.am
+++ b/copy/Makefile.am
@@ -18,6 +18,9 @@
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
@@ -22,6 +22,9 @@ EXTRA_DIST = \
copy-allocated-synch.sh \
copy-allocated-destination-zero-asynch.sh \
copy-allocated-destination-zero-synch.sh \
+ copy-blkhash-known.sh \
+ copy-blkhash-pattern.sh \
+ copy-blkhash-randfile.sh \
copy-block-to-nbd.sh \
copy-file-to-file.sh \
copy-file-to-nbd.sh \
@@ -65,6 +68,7 @@ TESTS =
copy-destination-zero-asynch.sh \
copy-destination-zero-synch.sh \
@@ -72,6 +75,7 @@ TESTS =
nbdcopy_SOURCES = \
nbdcopy.h \
@ -57,7 +57,7 @@ index c42accab..403f98ba 100644
file-ops.c \
main.c \
multi-thread-copying.c \
@@ -82,8 +86,10 @@ nbdcopy_CPPFLAGS = \
@@ -89,8 +93,10 @@ nbdcopy_CPPFLAGS = \
nbdcopy_CFLAGS = \
$(WARNINGS_CFLAGS) \
$(PTHREAD_CFLAGS) \
@ -68,7 +68,7 @@ index c42accab..403f98ba 100644
$(PTHREAD_LIBS) \
$(top_builddir)/common/utils/libutils.la \
$(top_builddir)/lib/libnbd.la \
@@ -150,6 +156,12 @@ TESTS += \
@@ -164,6 +170,12 @@ TESTS += \
endif
if HAVE_GNUTLS
@ -773,7 +773,7 @@ index 00000000..029237c4
+
+$VG nbdcopy --blkhash=md5/512 $randfile null:
diff --git a/copy/main.c b/copy/main.c
index 447dc948..1a854d5f 100644
index 3886a528..8f943b30 100644
--- a/copy/main.c
+++ b/copy/main.c
@@ -32,12 +32,15 @@
@ -956,7 +956,7 @@ index a75fb265..89588e6e 100644
/* If sparseness detection (see below) is turned off then we write
* the whole command.
diff --git a/copy/nbdcopy.h b/copy/nbdcopy.h
index 1b082f63..b107b72f 100644
index 7c54463d..91289c32 100644
--- a/copy/nbdcopy.h
+++ b/copy/nbdcopy.h
@@ -25,6 +25,10 @@
@ -1079,10 +1079,10 @@ index 940e37ad..3efe2b1b 100644
=head1 AUTHORS
diff --git a/copy/synch-copying.c b/copy/synch-copying.c
index 200c97f6..4c65c86d 100644
index 5d21423d..09f05be2 100644
--- a/copy/synch-copying.c
+++ b/copy/synch-copying.c
@@ -49,6 +49,7 @@ synch_copying (void)
@@ -83,6 +83,7 @@ synch_copying (void)
size_t r;
while ((r = src->ops->synch_read (src, buf, request_size, offset)) > 0) {
@ -1090,15 +1090,15 @@ index 200c97f6..4c65c86d 100644
dst->ops->synch_write (dst, buf, r, offset);
offset += r;
progress_bar (offset, src->size);
@@ -82,6 +83,7 @@ synch_copying (void)
@@ -116,6 +117,7 @@ synch_copying (void)
assert (exts.ptr[i].length <= count);
if (exts.ptr[i].zero) {
+ update_blkhash (NULL, offset, exts.ptr[i].length);
if (!dst->ops->synch_zero (dst, offset, exts.ptr[i].length, false) &&
!dst->ops->synch_zero (dst, offset, exts.ptr[i].length, true)) {
/* If efficient zeroing (punching a hole or allocating
@@ -103,6 +105,7 @@ synch_copying (void)
fill_dst_range_with_zeroes(offset, exts.ptr[i].length, buf);
offset += exts.ptr[i].length;
}
@@ -130,6 +132,7 @@ synch_copying (void)
exit (EXIT_FAILURE);
}

View File

@ -1,73 +0,0 @@
From 7e75a5666bf4078030a7334def14c67c2eeab1f6 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 10 Mar 2025 15:18:06 +0000
Subject: [PATCH] info: Use magenta for export headings, instead of black
Use of black foreground text makes the text invisible when using a
dark theme. Use a magenta colour instead which works on both light
and dark background.
Reported-by: Ming Xie
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2221199
Fixes: https://issues.redhat.com/browse/RHEL-7119
---
info/main.c | 2 --
info/show.c | 6 ++----
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/info/main.c b/info/main.c
index 8aa6cb74..1ee9e329 100644
--- a/info/main.c
+++ b/info/main.c
@@ -358,7 +358,6 @@ main (int argc, char *argv[])
if (!json_output) {
if (protocol) {
- ansi_colour (ANSI_FG_GREY, fp);
fprintf (fp, "protocol: %s", protocol);
if (tls_negotiated >= 0)
fprintf (fp, " %s TLS", tls_negotiated ? "with" : "without");
@@ -367,7 +366,6 @@ main (int argc, char *argv[])
eh_negotiated ? "extended" :
sr_negotiated ? "structured" : "simple");
fprintf (fp, "\n");
- ansi_restore (fp);
}
}
else {
diff --git a/info/show.c b/info/show.c
index 1596eb77..4886dad5 100644
--- a/info/show.c
+++ b/info/show.c
@@ -131,7 +131,7 @@ show_one_export (struct nbd_handle *nbd, const char *desc,
content = get_content (nbd, size);
if (!json_output) {
- ansi_colour (ANSI_FG_BOLD_BLACK, fp);
+ ansi_colour (ANSI_FG_BRIGHT_MAGENTA, fp);
fprintf (fp, "export=");
/* Might as well use the JSON function to get an escaped string here ... */
print_json_string (export_name);
@@ -148,10 +148,9 @@ show_one_export (struct nbd_handle *nbd, const char *desc,
fprintf (fp, "\texport-size: %s\n", size_str);
if (content)
fprintf (fp, "\tcontent: %s\n", content);
+ ansi_restore (fp);
if (uri)
fprintf (fp, "\turi: %s\n", uri);
- ansi_restore (fp);
- ansi_colour (ANSI_FG_GREY, fp);
if (show_context) {
fprintf (fp, "\tcontexts:\n");
for (i = 0; i < contexts.len; ++i)
@@ -160,7 +159,6 @@ show_one_export (struct nbd_handle *nbd, const char *desc,
if (is_rotational >= 0)
fprintf (fp, "\t%s: %s\n", "is_rotational",
is_rotational ? "true" : "false");
- ansi_restore (fp);
if (is_read_only >= 0)
fprintf (fp, "\t%s: %s\n", "is_read_only",
is_read_only ? "true" : "false");
--
2.47.1

View File

@ -1,4 +1,4 @@
From bf2babeaea87958f587e67ff73b27e9bfe7544a1 Mon Sep 17 00:00:00 2001
From 2dd76033ddf81ac21fc1113e1b99ff9c8c354ee5 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 7 Apr 2025 11:35:25 +0100
Subject: [PATCH] copy: Fix crash when blkhash size is not a power of 2
@ -16,7 +16,7 @@ Fixes: https://issues.redhat.com/browse/RHEL-85513
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/copy/main.c b/copy/main.c
index 1a854d5f..07897e79 100644
index 8f943b30..9afb627c 100644
--- a/copy/main.c
+++ b/copy/main.c
@@ -220,7 +220,7 @@ main (int argc, char *argv[])

View File

@ -1,33 +0,0 @@
From 6e95cddb80399429569a02c29479cb96175f0291 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 29 Mar 2025 13:56:36 +0000
Subject: [PATCH] copy: progress: Add a comment about size and pipes
I think this is a bug of sorts, although the progress_bar subfunctions
happen to handle it fine. Add a comment so I remember to do something
about this later.
(cherry picked from commit 363437af152d037b909de6b1ef7f91da921e073c)
---
copy/progress.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/copy/progress.c b/copy/progress.c
index cc0910d6..3c010320 100644
--- a/copy/progress.c
+++ b/copy/progress.c
@@ -100,6 +100,11 @@ progress_bar (off_t pos, int64_t size)
if (size == 0)
return;
+ /* XXX Synchronous mode, when the source is a pipe, passes size ==
+ * -1 here. We should deal with this by displaying some sort of
+ * spinner.
+ */
+
pthread_mutex_lock (&lock);
if (progress_fd == -1)
do_progress_bar (pos, size);
--
2.47.1

View File

@ -1,4 +1,4 @@
From acc2ec1028879327dde9874b2969c20cd5f50842 Mon Sep 17 00:00:00 2001
From d6518adef678ac1676d30f2b6fa9297b6f32db73 Mon Sep 17 00:00:00 2001
From: Nir Soffer <nsoffer@redhat.com>
Date: Sun, 13 Apr 2025 14:51:09 +0000
Subject: [PATCH] copy: Define block_type outside of block struct

View File

@ -1,49 +0,0 @@
From f2f54e2dc61c7d7fbfc7ee53d70629937967e84a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 29 Mar 2025 14:00:39 +0000
Subject: [PATCH] copy: Set the total size in bytes copied
Ensure that src->size contains the total size in bytes copied. There
is (only) one place where this is not known in advance, which is when
we are reading from a pipe.
(cherry picked from commit afe4f390a65a0d1b9f3625bf90c73726866e0a64)
---
copy/main.c | 3 +++
copy/synch-copying.c | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/copy/main.c b/copy/main.c
index 200b7756..447dc948 100644
--- a/copy/main.c
+++ b/copy/main.c
@@ -479,6 +479,9 @@ main (int argc, char *argv[])
/* Always set the progress bar to 100% at the end of the copy. */
progress_bar (1, 1);
+ /* We should always know the total size copied here. */
+ assert (src->size >= 0);
+
/* Shut down the source side. */
src->ops->close (src);
diff --git a/copy/synch-copying.c b/copy/synch-copying.c
index 2f6627bf..200c97f6 100644
--- a/copy/synch-copying.c
+++ b/copy/synch-copying.c
@@ -53,6 +53,12 @@ synch_copying (void)
offset += r;
progress_bar (offset, src->size);
}
+
+ /* Record the total amount of data that was copied. In all other
+ * cases, src->size will already be set to the true size, so here
+ * is the only place we have to set this.
+ */
+ src->size = offset;
}
/* Otherwise we know how much we're copying, so we can copy in whole
--
2.47.1

View File

@ -1,4 +1,4 @@
From d2a40df593c1f3ebd9d61277c1c4d336e27f1596 Mon Sep 17 00:00:00 2001
From 7546ba20ec4ddf7e4b1137b294873c4c49b52c99 Mon Sep 17 00:00:00 2001
From: Nir Soffer <nsoffer@redhat.com>
Date: Sun, 13 Apr 2025 14:54:31 +0000
Subject: [PATCH] copy: Shrink struct block

View File

@ -1,29 +0,0 @@
From 3a4305f0f26e9a0257256fa2326ff8976cb005d0 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 29 Mar 2025 21:30:26 +0000
Subject: [PATCH] info/info-uri-nbds.sh: Fix test if compiled without GnuTLS
Fixes: commit 37ee81ea12eec0dafd677c439710d63579652586
(cherry picked from commit 35683f8236adead4c76f268a67528df634394dce)
---
info/info-uri-nbds.sh | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/info/info-uri-nbds.sh b/info/info-uri-nbds.sh
index 4fbfc64c..9b618fb8 100755
--- a/info/info-uri-nbds.sh
+++ b/info/info-uri-nbds.sh
@@ -28,6 +28,10 @@ requires $NBDKIT null --version
requires $NBDKIT --tls-verify-peer -U - null --run 'exit 0'
requires jq --version
+# Requires that this build has TLS.
+requires nbdsh --version
+requires nbdsh -c 'exit(not h.supports_tls())'
+
# Requires that the test certificates were created.
pki=../tests/pki
requires test -f $pki/stamp-pki
--
2.47.1

View File

@ -1,4 +1,4 @@
From c92dab9825cc4234777583d56dbd11e27b61637f Mon Sep 17 00:00:00 2001
From 46d67e16fd65aad6f9f795dfcefcfc19a0e419eb Mon Sep 17 00:00:00 2001
From: Nir Soffer <nsoffer@redhat.com>
Date: Sun, 13 Apr 2025 23:39:15 +0000
Subject: [PATCH] copy: Enable zero optimization for allocated extents

View File

@ -1,4 +1,4 @@
From 692d28fd6dc3a74855b25173b39d5e2ad6ddc30f Mon Sep 17 00:00:00 2001
From a15fc80c4fd558509a3a8b5cf96bec27c483e656 Mon Sep 17 00:00:00 2001
From: Nir Soffer <nsoffer@redhat.com>
Date: Mon, 14 Apr 2025 21:40:16 +0000
Subject: [PATCH] copy: Fix corrupted hash on incomplete read
@ -22,10 +22,10 @@ the code.
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/copy/synch-copying.c b/copy/synch-copying.c
index 4c65c86d..b030a85a 100644
index 09f05be2..2aa67df6 100644
--- a/copy/synch-copying.c
+++ b/copy/synch-copying.c
@@ -49,7 +49,7 @@ synch_copying (void)
@@ -83,7 +83,7 @@ synch_copying (void)
size_t r;
while ((r = src->ops->synch_read (src, buf, request_size, offset)) > 0) {

View File

@ -20,8 +20,8 @@
%global source_directory 1.22-stable
Name: libnbd
Version: 1.22.1
Release: 4%{?dist}
Version: 1.22.2
Release: 1%{?dist}
Summary: NBD client library in userspace
License: LGPL-2.0-or-later AND BSD-3-Clause
@ -41,16 +41,12 @@ Source3: copy-patches.sh
# https://gitlab.com/nbdkit/libnbd/-/commits/rhel-10.1/
# Patches.
Patch0001: 0001-info-Use-magenta-for-export-headings-instead-of-blac.patch
Patch0002: 0002-copy-progress-Add-a-comment-about-size-and-pipes.patch
Patch0003: 0003-copy-Set-the-total-size-in-bytes-copied.patch
Patch0004: 0004-info-info-uri-nbds.sh-Fix-test-if-compiled-without-G.patch
Patch0005: 0005-copy-Add-blkhash-option.patch
Patch0006: 0006-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch
Patch0007: 0007-copy-Define-block_type-outside-of-block-struct.patch
Patch0008: 0008-copy-Shrink-struct-block.patch
Patch0009: 0009-copy-Enable-zero-optimization-for-allocated-extents.patch
Patch0010: 0010-copy-Fix-corrupted-hash-on-incomplete-read.patch
Patch0001: 0001-copy-Add-blkhash-option.patch
Patch0002: 0002-copy-Fix-crash-when-blkhash-size-is-not-a-power-of-2.patch
Patch0003: 0003-copy-Define-block_type-outside-of-block-struct.patch
Patch0004: 0004-copy-Shrink-struct-block.patch
Patch0005: 0005-copy-Enable-zero-optimization-for-allocated-extents.patch
Patch0006: 0006-copy-Fix-corrupted-hash-on-incomplete-read.patch
%if 0%{verify_tarball_signature}
BuildRequires: gnupg2
@ -391,8 +387,8 @@ make %{?_smp_mflags} check || {
%changelog
* Tue Apr 15 2025 Richard W.M. Jones <rjones@redhat.com> - 1.22.1-4
- Rebase to libnbd 1.22.1
* Tue Apr 22 2025 Richard W.M. Jones <rjones@redhat.com> - 1.22.2-1
- Rebase to libnbd 1.22.2
- Synch spec file with Fedora Rawhide.
resolves: RHEL-78831
- Fix nbdinfo with dark theme

View File

@ -1,2 +1,2 @@
SHA512 (libnbd-1.22.1.tar.gz) = 3f265ed59020c394c5e1f46c51d0ae7f3e7e54461739da964ac92b5c4c8bc98ea9813b93342e025f5f770b688d16d155d6e74d715beab482a040115df6be5afa
SHA512 (libnbd-1.22.1.tar.gz.sig) = fd56b7ff28c3c8ecc39dc8433fe8b8e3852b2ce66fe003cb614957f3d6f09850c042f820098fe4a3039863320faf037657cfbafbc3a902ecc0849f771ea544c4
SHA512 (libnbd-1.22.2.tar.gz) = 5ece4cdc41cafefbe27ddaeafc2b6b390b0cf25f38f80c1b10ec2e17ee1dcda92964891faf4abca4c8aa5827c9eec6e0b38162871e8c72b2af8e769287cd603d
SHA512 (libnbd-1.22.2.tar.gz.sig) = 0b0d6cd4e5b900aef73820f53dc87e3d7dbd80a056efbb8c6236750c91fc570b529a3bddcbb446ebbb517f279daf90d6fa7e9ffca16901b5568ac395c1b6eda2