libnbd/0003-Revert-copy-file-ops.c-Remove-unneeded-check.patch
DistroBaker fc5a1dabcb Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/libnbd.git#8c37651ac69f29390463002bd07996f1f4b2a553
2021-03-11 20:12:46 +00:00

72 lines
2.5 KiB
Diff

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/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