diff --git a/0001-copy-Stable-sort-in-tests.patch b/0001-copy-Stable-sort-in-tests.patch new file mode 100644 index 0000000..93b3ecd --- /dev/null +++ b/0001-copy-Stable-sort-in-tests.patch @@ -0,0 +1,74 @@ +From 8b20bbd329c07941f3e4aa00e14c05ed27b25435 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Tue, 2 Mar 2021 22:20:49 +0000 +Subject: [PATCH 1/5] copy: Stable sort in tests. + +When running the tests in Koji they behaved differently from running +locally (under a UTF-8 locale). This turned out to be a difference in +sorting under the different locales. + +Thanks: Eric Blake +--- + copy/copy-sparse-request-size.sh | 2 +- + copy/copy-sparse.sh | 8 ++++---- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/copy/copy-sparse-request-size.sh b/copy/copy-sparse-request-size.sh +index b539f5e..f2e2b61 100755 +--- a/copy/copy-sparse-request-size.sh ++++ b/copy/copy-sparse-request-size.sh +@@ -50,7 +50,7 @@ $VG nbdcopy --no-extents -S 0 --request-size=1048576 -- \ + trim=" echo \$@ >> $out " \ + zero=" echo \$@ >> $out " ] + +-sort -n -o $out $out ++LC_ALL=C sort -n -o $out $out + + echo Output: + cat $out +diff --git a/copy/copy-sparse.sh b/copy/copy-sparse.sh +index c43b41a..5f12bad 100755 +--- a/copy/copy-sparse.sh ++++ b/copy/copy-sparse.sh +@@ -50,7 +50,7 @@ $VG nbdcopy -S 0 -- \ + + # Order of the output could vary because requests are sent in + # parallel. +-sort -n -o $out $out ++LC_ALL=C sort -n -o $out $out + + echo Output: + cat $out +@@ -65,8 +65,8 @@ zero 134184960 4160749568 may_trim + zero 134184960 939524096 may_trim + zero 134217728 1073741824 may_trim + zero 134217728 1207959552 may_trim +-zero 134217728 1342177280 may_trim + zero 134217728 134217728 may_trim ++zero 134217728 1342177280 may_trim + zero 134217728 1476395008 may_trim + zero 134217728 1610612736 may_trim + zero 134217728 1744830464 may_trim +@@ -76,8 +76,8 @@ zero 134217728 2147483648 may_trim + zero 134217728 2281701376 may_trim + zero 134217728 2415919104 may_trim + zero 134217728 2550136832 may_trim +-zero 134217728 2684354560 may_trim + zero 134217728 268435456 may_trim ++zero 134217728 2684354560 may_trim + zero 134217728 2818572288 may_trim + zero 134217728 2952790016 may_trim + zero 134217728 3087007744 may_trim +@@ -87,8 +87,8 @@ zero 134217728 3489660928 may_trim + zero 134217728 3623878656 may_trim + zero 134217728 3758096384 may_trim + zero 134217728 3892314112 may_trim +-zero 134217728 4026531840 may_trim + zero 134217728 402653184 may_trim ++zero 134217728 4026531840 may_trim + zero 134217728 536870912 may_trim + zero 134217728 671088640 may_trim + zero 134217728 805306368 may_trim" ]; then +-- +2.29.0.rc2 + diff --git a/0002-copy-Nicer-sort.patch b/0002-copy-Nicer-sort.patch new file mode 100644 index 0000000..7ea1409 --- /dev/null +++ b/0002-copy-Nicer-sort.patch @@ -0,0 +1,170 @@ +From bae7c41a5126c56da4ee77bce39955036fca8b5f Mon Sep 17 00:00:00 2001 +From: Eric Blake +Date: Tue, 2 Mar 2021 16:31:39 -0600 +Subject: [PATCH 2/5] copy: Nicer sort + +Tell sort where the numbers live, so we can get columns in ascending +numeric order. Improves 8b20bbd329. +--- + copy/copy-sparse-no-extents.sh | 12 ++++++------ + copy/copy-sparse-request-size.sh | 20 ++++++++++---------- + copy/copy-sparse.sh | 18 +++++++++--------- + 3 files changed, 25 insertions(+), 25 deletions(-) + +diff --git a/copy/copy-sparse-no-extents.sh b/copy/copy-sparse-no-extents.sh +index cdc132b..4dc5c88 100755 +--- a/copy/copy-sparse-no-extents.sh ++++ b/copy/copy-sparse-no-extents.sh +@@ -50,22 +50,21 @@ $VG nbdcopy --no-extents -S 0 -- \ + trim=" echo \$@ >> $out " \ + zero=" echo \$@ >> $out " ] + +-sort -n -o $out $out ++LC_ALL=C sort -k1,1 -k2,2n -k3,3n -o $out $out + + echo Output: + cat $out + + if [ "$(cat $out)" != "pwrite 33554432 0 ++pwrite 33554432 33554432 ++pwrite 33554432 67108864 + pwrite 33554432 100663296 +-pwrite 33554432 1006632960 +-pwrite 33554432 1040187392 + pwrite 33554432 134217728 + pwrite 33554432 167772160 + pwrite 33554432 201326592 + pwrite 33554432 234881024 + pwrite 33554432 268435456 + pwrite 33554432 301989888 +-pwrite 33554432 33554432 + pwrite 33554432 335544320 + pwrite 33554432 369098752 + pwrite 33554432 402653184 +@@ -76,7 +75,6 @@ pwrite 33554432 536870912 + pwrite 33554432 570425344 + pwrite 33554432 603979776 + pwrite 33554432 637534208 +-pwrite 33554432 67108864 + pwrite 33554432 671088640 + pwrite 33554432 704643072 + pwrite 33554432 738197504 +@@ -86,7 +84,9 @@ pwrite 33554432 838860800 + pwrite 33554432 872415232 + pwrite 33554432 905969664 + pwrite 33554432 939524096 +-pwrite 33554432 973078528" ]; then ++pwrite 33554432 973078528 ++pwrite 33554432 1006632960 ++pwrite 33554432 1040187392" ]; then + echo "$0: output does not match expected" + exit 1 + fi +diff --git a/copy/copy-sparse-request-size.sh b/copy/copy-sparse-request-size.sh +index f2e2b61..78a066a 100755 +--- a/copy/copy-sparse-request-size.sh ++++ b/copy/copy-sparse-request-size.sh +@@ -50,13 +50,21 @@ $VG nbdcopy --no-extents -S 0 --request-size=1048576 -- \ + trim=" echo \$@ >> $out " \ + zero=" echo \$@ >> $out " ] + +-LC_ALL=C sort -n -o $out $out ++LC_ALL=C sort -k1,1 -k2,2n -k3,3n -o $out $out + + echo Output: + cat $out + + if [ "$(cat $out)" != "pwrite 1048576 0 + pwrite 1048576 1048576 ++pwrite 1048576 2097152 ++pwrite 1048576 3145728 ++pwrite 1048576 4194304 ++pwrite 1048576 5242880 ++pwrite 1048576 6291456 ++pwrite 1048576 7340032 ++pwrite 1048576 8388608 ++pwrite 1048576 9437184 + pwrite 1048576 10485760 + pwrite 1048576 11534336 + pwrite 1048576 12582912 +@@ -67,7 +75,6 @@ pwrite 1048576 16777216 + pwrite 1048576 17825792 + pwrite 1048576 18874368 + pwrite 1048576 19922944 +-pwrite 1048576 2097152 + pwrite 1048576 20971520 + pwrite 1048576 22020096 + pwrite 1048576 23068672 +@@ -78,15 +85,8 @@ pwrite 1048576 27262976 + pwrite 1048576 28311552 + pwrite 1048576 29360128 + pwrite 1048576 30408704 +-pwrite 1048576 3145728 + pwrite 1048576 31457280 +-pwrite 1048576 32505856 +-pwrite 1048576 4194304 +-pwrite 1048576 5242880 +-pwrite 1048576 6291456 +-pwrite 1048576 7340032 +-pwrite 1048576 8388608 +-pwrite 1048576 9437184" ]; then ++pwrite 1048576 32505856" ]; then + echo "$0: output does not match expected" + exit 1 + fi +diff --git a/copy/copy-sparse.sh b/copy/copy-sparse.sh +index 5f12bad..1a6da86 100755 +--- a/copy/copy-sparse.sh ++++ b/copy/copy-sparse.sh +@@ -50,7 +50,7 @@ $VG nbdcopy -S 0 -- \ + + # Order of the output could vary because requests are sent in + # parallel. +-LC_ALL=C sort -n -o $out $out ++LC_ALL=C sort -k1,1 -k2,2n -k3,3n -o $out $out + + echo Output: + cat $out +@@ -61,11 +61,16 @@ pwrite 32768 0 + pwrite 32768 1073709056 + pwrite 32768 4294934528 + zero 134184960 32768 may_trim +-zero 134184960 4160749568 may_trim + zero 134184960 939524096 may_trim ++zero 134184960 4160749568 may_trim ++zero 134217728 134217728 may_trim ++zero 134217728 268435456 may_trim ++zero 134217728 402653184 may_trim ++zero 134217728 536870912 may_trim ++zero 134217728 671088640 may_trim ++zero 134217728 805306368 may_trim + zero 134217728 1073741824 may_trim + zero 134217728 1207959552 may_trim +-zero 134217728 134217728 may_trim + zero 134217728 1342177280 may_trim + zero 134217728 1476395008 may_trim + zero 134217728 1610612736 may_trim +@@ -76,7 +81,6 @@ zero 134217728 2147483648 may_trim + zero 134217728 2281701376 may_trim + zero 134217728 2415919104 may_trim + zero 134217728 2550136832 may_trim +-zero 134217728 268435456 may_trim + zero 134217728 2684354560 may_trim + zero 134217728 2818572288 may_trim + zero 134217728 2952790016 may_trim +@@ -87,11 +91,7 @@ zero 134217728 3489660928 may_trim + zero 134217728 3623878656 may_trim + zero 134217728 3758096384 may_trim + zero 134217728 3892314112 may_trim +-zero 134217728 402653184 may_trim +-zero 134217728 4026531840 may_trim +-zero 134217728 536870912 may_trim +-zero 134217728 671088640 may_trim +-zero 134217728 805306368 may_trim" ]; then ++zero 134217728 4026531840 may_trim" ]; then + echo "$0: output does not match expected" + exit 1 + fi +-- +2.29.0.rc2 + diff --git a/0003-Revert-copy-file-ops.c-Remove-unneeded-check.patch b/0003-Revert-copy-file-ops.c-Remove-unneeded-check.patch new file mode 100644 index 0000000..b45d880 --- /dev/null +++ b/0003-Revert-copy-file-ops.c-Remove-unneeded-check.patch @@ -0,0 +1,71 @@ +From 4e456ff6363580177ceffdad79b8fc1e8c7f35eb Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 3 Mar 2021 10:12:31 +0000 +Subject: [PATCH 3/5] Revert "copy: file-ops.c: Remove unneeded check" + +This reverts commit 0f6e4f38bc440fc52c20a3a448ef031f806ec5e2. + +This fails on ppc64le only with: + +lt-nbdcopy: file-ops.c:136: page_was_cached: Assertion `page < rwf->cached_pages.size' failed. + +Coincidentally this is the only architecture on Fedora that uses a 64K +page size, although I don't know if that is connected. I was not able +to make this fail on x86. +--- + copy/file-ops.c | 21 ++++++++++----------- + 1 file changed, 10 insertions(+), 11 deletions(-) + +diff --git a/copy/file-ops.c b/copy/file-ops.c +index 47ec768..ea725a4 100644 +--- a/copy/file-ops.c ++++ b/copy/file-ops.c +@@ -102,7 +102,7 @@ page_size_init (void) + /* Load the page cache map for a particular file into + * rwf->cached_pages. Only used when reading files. This doesn't + * fail: if a system call fails then rwf->cached_pages.size will be +- * zero which is handled in page_cache_evict. ++ * zero which is handled in page_was_cached. + */ + static inline void + page_cache_map (struct rw_file *rwf) +@@ -126,16 +126,19 @@ page_cache_map (struct rw_file *rwf) + munmap (ptr, rwf->rw.size); + } + +-/* Test if a single page of the file was cached before nbdcopy ran. +- * Valid only if we mapped the cached pages. +- */ ++/* Test if a single page of the file was cached before nbdcopy ran. */ + static inline bool + page_was_cached (struct rw_file *rwf, uint64_t offset) + { + uint64_t page = offset / page_size; +- assert (page < rwf->cached_pages.size); +- +- return (rwf->cached_pages.ptr[page] & 1) != 0; ++ if (page < rwf->cached_pages.size) ++ return (rwf->cached_pages.ptr[page] & 1) != 0; ++ else ++ /* This path is taken if we didn't manage to map the input file ++ * for any reason. In this case assume that pages were mapped so ++ * we will not evict them: essentially fall back to doing nothing. ++ */ ++ return true; + } + + /* Evict file contents from the page cache if they were not present in +@@ -147,10 +150,6 @@ page_cache_evict (struct rw_file *rwf, uint64_t orig_offset, size_t orig_len) + uint64_t offset, n; + size_t len; + +- /* If we didn't manage to map the input file for any reason, assume +- * that pages were mapped so we will not evict them: essentially fall +- * back to doing nothing. +- */ + if (rwf->cached_pages.size == 0) return; + + /* Only bother with whole pages. */ +-- +2.29.0.rc2 + diff --git a/0004-copy-file-ops.c-Remove-unneeded-check.patch b/0004-copy-file-ops.c-Remove-unneeded-check.patch new file mode 100644 index 0000000..7c5cc03 --- /dev/null +++ b/0004-copy-file-ops.c-Remove-unneeded-check.patch @@ -0,0 +1,67 @@ +From 94a78764d80b6dc41ff2ae8a0e5f1b35c2fd8e78 Mon Sep 17 00:00:00 2001 +From: Nir Soffer +Date: Sat, 27 Feb 2021 05:36:38 +0200 +Subject: [PATCH 4/5] copy: file-ops.c: Remove unneeded check + +This function is called only from page_cache_evict(), which already +check that we could map the cached pages. Add an assert to document this +assumption. + +Signed-off-by: Nir Soffer +--- + copy/file-ops.c | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +diff --git a/copy/file-ops.c b/copy/file-ops.c +index ea725a4..47ec768 100644 +--- a/copy/file-ops.c ++++ b/copy/file-ops.c +@@ -102,7 +102,7 @@ page_size_init (void) + /* Load the page cache map for a particular file into + * rwf->cached_pages. Only used when reading files. This doesn't + * fail: if a system call fails then rwf->cached_pages.size will be +- * zero which is handled in page_was_cached. ++ * zero which is handled in page_cache_evict. + */ + static inline void + page_cache_map (struct rw_file *rwf) +@@ -126,19 +126,16 @@ page_cache_map (struct rw_file *rwf) + munmap (ptr, rwf->rw.size); + } + +-/* Test if a single page of the file was cached before nbdcopy ran. */ ++/* Test if a single page of the file was cached before nbdcopy ran. ++ * Valid only if we mapped the cached pages. ++ */ + static inline bool + page_was_cached (struct rw_file *rwf, uint64_t offset) + { + uint64_t page = offset / page_size; +- if (page < rwf->cached_pages.size) +- return (rwf->cached_pages.ptr[page] & 1) != 0; +- else +- /* This path is taken if we didn't manage to map the input file +- * for any reason. In this case assume that pages were mapped so +- * we will not evict them: essentially fall back to doing nothing. +- */ +- return true; ++ assert (page < rwf->cached_pages.size); ++ ++ return (rwf->cached_pages.ptr[page] & 1) != 0; + } + + /* Evict file contents from the page cache if they were not present in +@@ -150,6 +147,10 @@ page_cache_evict (struct rw_file *rwf, uint64_t orig_offset, size_t orig_len) + uint64_t offset, n; + size_t len; + ++ /* If we didn't manage to map the input file for any reason, assume ++ * that pages were mapped so we will not evict them: essentially fall ++ * back to doing nothing. ++ */ + if (rwf->cached_pages.size == 0) return; + + /* Only bother with whole pages. */ +-- +2.29.0.rc2 + diff --git a/0005-copy-file-ops.c-Fix-page-eviction-when-len-page_size.patch b/0005-copy-file-ops.c-Fix-page-eviction-when-len-page_size.patch new file mode 100644 index 0000000..9430c05 --- /dev/null +++ b/0005-copy-file-ops.c-Fix-page-eviction-when-len-page_size.patch @@ -0,0 +1,32 @@ +From 107eb605cfb75238020332b5a5461d0e09d62bec Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Wed, 3 Mar 2021 12:51:51 +0100 +Subject: [PATCH 5/5] copy/file-ops.c: Fix page eviction when len < page_size. + +On Fedora ppc64le at the moment page size is 64K. When asked to evict +a range with length < 64K the length calculation wrapped around and it +tried to evict a huge number of pages beyond the end of the file. + +With Nir's commit 0f6e4f38b this (correctly) resulted in an assertion +failure. + +Fix this by checking for the overflow and returning early. +--- + copy/file-ops.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/copy/file-ops.c b/copy/file-ops.c +index 47ec768..6bad50c 100644 +--- a/copy/file-ops.c ++++ b/copy/file-ops.c +@@ -155,6 +155,7 @@ page_cache_evict (struct rw_file *rwf, uint64_t orig_offset, size_t orig_len) + + /* Only bother with whole pages. */ + offset = ROUND_UP (orig_offset, page_size); ++ if (orig_len < offset - orig_offset) return; + len = orig_len - (offset - orig_offset); + len = ROUND_DOWN (len, page_size); + +-- +2.29.0.rc2 + diff --git a/libnbd.spec b/libnbd.spec index d44fac7..785c0d7 100644 --- a/libnbd.spec +++ b/libnbd.spec @@ -8,7 +8,7 @@ %global source_directory 1.7-development Name: libnbd -Version: 1.7.2 +Version: 1.7.3 Release: 1%{?dist} Summary: NBD client library in userspace @@ -25,6 +25,13 @@ Source2: libguestfs.keyring # Maintainer script which helps with handling patches. Source3: copy-patches.sh +# Upstream patches to fix tests. +Patch0001: 0001-copy-Stable-sort-in-tests.patch +Patch0002: 0002-copy-Nicer-sort.patch +Patch0003: 0003-Revert-copy-file-ops.c-Remove-unneeded-check.patch +Patch0004: 0004-copy-file-ops.c-Remove-unneeded-check.patch +Patch0005: 0005-copy-file-ops.c-Fix-page-eviction-when-len-page_size.patch + %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool %endif @@ -62,7 +69,9 @@ BuildRequires: coreutils BuildRequires: gcc-c++ BuildRequires: gnutls-utils BuildRequires: jq +%if !0%{?rhel} BuildRequires: nbd +%endif BuildRequires: util-linux # On RHEL, maybe even in Fedora in future, we do not build qemu-img or @@ -299,6 +308,15 @@ make %{?_smp_mflags} check || { %changelog +* Tue Mar 2 2021 Richard W.M. Jones - 1.7.3-1 +- New upstream version 1.7.3. + +* Mon Mar 1 2021 Richard W.M. Jones - 1.7.2-3 +- OCaml 4.12.0 build + +* Wed Feb 24 2021 Richard W.M. Jones - 1.7.2-2 +- Disable nbd BR on RHEL. + * Mon Feb 22 2021 Richard W.M. Jones - 1.7.2-1 - New upstream version 1.7.2. diff --git a/sources b/sources index fbc84b0..2a25167 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (libnbd-1.7.2.tar.gz) = e6b25c97f4c0675879ab665674ea83fb3e3dd34a9a11ec0c72c38b49ddd1cb886f7d33e2eb8ac0a7428c5ecb7f53c2fa1e3d68b60fb95d2655b6c775199ac50a -SHA512 (libnbd-1.7.2.tar.gz.sig) = 7d70f0fd6366bc897e9fd43e73c4f358195bef0142c1f8421b70d883a7cac2932970461fbd12791bea89e315c0f4c3ed7f13044b8ba719c47483a52505dbfa6f +SHA512 (libnbd-1.7.3.tar.gz) = 1d7a0e6a5797d1df2e40b5e211ccea78926e2df882423a557acbc3c040f1b4c3f782a4754340be64d1176f0fd3524b094b9266186e25a80668494c7f72e3ef13 +SHA512 (libnbd-1.7.3.tar.gz.sig) = 0d693add7361b29dab7f744d24dce56518f64c0f3133847e685175d711e281c924850046a573d64d8354b5acd21bee34815163f7a8eb9f41266026435f1ba892