Add more upstream patches to fix tests.

This commit is contained in:
Richard W.M. Jones 2021-03-03 10:15:06 +00:00
parent c81b6ed16c
commit 41eaea3549
4 changed files with 246 additions and 2 deletions

View File

@ -1,7 +1,7 @@
From 8b20bbd329c07941f3e4aa00e14c05ed27b25435 Mon Sep 17 00:00:00 2001 From 8b20bbd329c07941f3e4aa00e14c05ed27b25435 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com> From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 2 Mar 2021 22:20:49 +0000 Date: Tue, 2 Mar 2021 22:20:49 +0000
Subject: [PATCH] copy: Stable sort in tests. Subject: [PATCH 1/3] copy: Stable sort in tests.
When running the tests in Koji they behaved differently from running 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 locally (under a UTF-8 locale). This turned out to be a difference in

170
0002-copy-Nicer-sort.patch Normal file
View File

@ -0,0 +1,170 @@
From bae7c41a5126c56da4ee77bce39955036fca8b5f Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Tue, 2 Mar 2021 16:31:39 -0600
Subject: [PATCH 2/3] 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

View File

@ -0,0 +1,71 @@
From 4e456ff6363580177ceffdad79b8fc1e8c7f35eb Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 3 Mar 2021 10:12:31 +0000
Subject: [PATCH 3/3] 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

View File

@ -25,7 +25,10 @@ Source2: libguestfs.keyring
# Maintainer script which helps with handling patches. # Maintainer script which helps with handling patches.
Source3: copy-patches.sh Source3: copy-patches.sh
Patch1: 0001-copy-Stable-sort-in-tests.patch # 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
%if 0%{patches_touch_autotools} %if 0%{patches_touch_autotools}
BuildRequires: autoconf, automake, libtool BuildRequires: autoconf, automake, libtool