Add nbdcopy --blkhash option

resolves: RHEL-85509
This commit is contained in:
Richard W.M. Jones 2025-03-31 14:17:27 +01:00
parent 0ce2ddf562
commit 2b223e5817
9 changed files with 1173 additions and 7 deletions

View File

@ -187,5 +187,5 @@ index 45893a8b..6c7cc45c 100644
return 0;
}
--
2.43.0
2.47.1

View File

@ -34,5 +34,5 @@ index 600265a0..5872dd54 100644
}
return r;
--
2.43.0
2.47.1

View File

@ -39,5 +39,5 @@ index 3945411e..699e24aa 100644
nbd_internal_free_option (h);
SET_NEXT_STATE (%.NEGOTIATING);
--
2.43.0
2.47.1

View File

@ -171,5 +171,5 @@ index 6c7cc45c..8c483bd2 100644
return 0;
}
--
2.43.0
2.47.1

View File

@ -23,5 +23,5 @@ index 8c483bd2..1e026a8a 100644
fprintf (fp, ": ");
for (i = 0; i < replylen; ++i) {
--
2.43.0
2.47.1

View File

@ -0,0 +1,49 @@
From 1c9d65c6100edfd6050b34dcf29a7a1bbdf5e89a 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 ae9840ae..cd7b2fd2 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

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ set -e
# directory. Use it like this:
# ./copy-patches.sh
rhel_version=9.6
rhel_version=9.7
# Check we're in the right directory.
if [ ! -f libnbd.spec ]; then

View File

@ -21,7 +21,7 @@
Name: libnbd
Version: 1.20.3
Release: 1%{?dist}
Release: 2%{?dist}
Summary: NBD client library in userspace
License: LGPL-2.0-or-later AND BSD-3-Clause
@ -46,6 +46,8 @@ Patch0002: 0002-lib-Don-t-overwrite-error-in-nbd_opt_-go-info.patch
Patch0003: 0003-generator-Restore-assignment-to-local-err.patch
Patch0004: 0004-generator-states-newstyle.c-Quote-untrusted-string-f.patch
Patch0005: 0005-generator-states-newstyle.c-Don-t-sign-extend-escape.patch
Patch0006: 0006-copy-Set-the-total-size-in-bytes-copied.patch
Patch0007: 0007-copy-Add-blkhash-option.patch
%if 0%{verify_tarball_signature}
BuildRequires: gnupg2
@ -390,6 +392,10 @@ make %{?_smp_mflags} check || {
%changelog
* Mon Mar 31 2025 Richard W.M. Jones <rjones@redhat.com> - 1.20.3-2
- Add nbdcopy --blkhash option
resolves: RHEL-85509
* Sat Sep 28 2024 Richard W.M. Jones <rjones@redhat.com> - 1.20.3-1
- Rebase to libnbd 1.20.3