]> arthur.barton.de Git - bup.git/commitdiff
thashsplit: don't assume MINCORE_INCORE is defined
authorRob Browning <rlb@defaultvalue.org>
Mon, 24 Aug 2015 20:44:15 +0000 (15:44 -0500)
committerRob Browning <rlb@defaultvalue.org>
Mon, 24 Aug 2015 20:55:45 +0000 (15:55 -0500)
We had intended to guard the use of MINCORE_INCORE with tests for the
presence of the underlying function call, but we missed the hashsplit
tests.

Fix it by allowing the tests to pass in the mask value they already
depend on (i.e. 1).

Thanks to Michael March for reporting the problem, Patrick Rouleau for
confirming it, and Markus for proposing an alternate solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/hashsplit.py
lib/bup/t/thashsplit.py

index 9631605a4b9b9281271bb2eb75bf27f661f81674..38681793ded155326863211872a12bf4d89b0fc2 100644 (file)
@@ -53,7 +53,7 @@ def _fadvise_pages_done(fd, first_page, count):
                               count * sc_page_size)
 
 
-def _nonresident_page_regions(status_bytes, max_region_len=None):
+def _nonresident_page_regions(status_bytes, incore_mask, max_region_len=None):
     """Return (start_page, count) pairs in ascending start_page order for
     each contiguous region of nonresident pages indicated by the
     mincore() status_bytes.  Limit the number of pages in each region
@@ -61,7 +61,7 @@ def _nonresident_page_regions(status_bytes, max_region_len=None):
     assert(max_region_len is None or max_region_len > 0)
     start = None
     for i, x in enumerate(status_bytes):
-        in_core = x & helpers.MINCORE_INCORE
+        in_core = x & incore_mask
         if start is None:
             if not in_core:
                 start = i
@@ -97,7 +97,8 @@ def readfile_iter(files, progress=None):
         if _fmincore and hasattr(f, 'fileno'):
             fd = f.fileno()
             max_chunk = max(1, (8 * 1024 * 1024) / sc_page_size)
-            rpr = _nonresident_page_regions(_fmincore(fd), max_chunk)
+            rpr = _nonresident_page_regions(_fmincore(fd),
+                                            helpers.MINCORE_INCORE, max_chunk)
             rstart, rlen = next(rpr, (None, None))
         while 1:
             if progress:
index 1b69cc2ad9361eef0c52edf20f3c9cf971df0d9e..ca2cb6b51cc361539f2bd13d61e09f72635c55ec 100644 (file)
@@ -6,7 +6,8 @@ from bup import hashsplit, _helpers, helpers
 
 
 def nr_regions(x, max_count=None):
-    return list(hashsplit._nonresident_page_regions(bytearray(x), max_count))
+    return list(hashsplit._nonresident_page_regions(bytearray(x), 1, max_count))
+
 
 @wvtest
 def test_nonresident_page_regions():