From: Rob Browning Date: Mon, 24 Aug 2015 20:44:15 +0000 (-0500) Subject: thashsplit: don't assume MINCORE_INCORE is defined X-Git-Tag: 0.28-rc1~70 X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;ds=sidebyside;h=df18bd0224fca3726099c3a60b46d4245288f011;p=bup.git thashsplit: don't assume MINCORE_INCORE is defined 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 Tested-by: Rob Browning --- diff --git a/lib/bup/hashsplit.py b/lib/bup/hashsplit.py index 9631605..3868179 100644 --- a/lib/bup/hashsplit.py +++ b/lib/bup/hashsplit.py @@ -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: diff --git a/lib/bup/t/thashsplit.py b/lib/bup/t/thashsplit.py index 1b69cc2..ca2cb6b 100644 --- a/lib/bup/t/thashsplit.py +++ b/lib/bup/t/thashsplit.py @@ -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():