From: Jakob Cornell Date: Mon, 18 Apr 2022 18:01:57 +0000 (-0500) Subject: Verify tool: fix worklist sorting bug X-Git-Url: https://jcornell.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=d70e52849ca29ed37ab08724620c713638a3e69a;p=eros.git Verify tool: fix worklist sorting bug --- diff --git a/disk_jumble/src/disk_jumble/verify.py b/disk_jumble/src/disk_jumble/verify.py index 2e4d708..d10fb0b 100644 --- a/disk_jumble/src/disk_jumble/verify.py +++ b/disk_jumble/src/disk_jumble/verify.py @@ -48,6 +48,10 @@ class _Run: hash: bytes +def _run_sort_key(run: _Run): + return run.block_ranges[0].start + + @dataclass class _V1Run(_Run): piece_length: int # for the entity overall @@ -173,7 +177,7 @@ def _get_v1_worklist(conn, disk_id: int, target_ranges: List[NumericRange]) -> L if sum(map(len, run.block_ranges)) == math.ceil(run_length / BLOCK_SIZE): runs.append(run) - runs.sort(key = lambda r: r.block_ranges) + runs.sort(key = _run_sort_key) return runs @@ -284,7 +288,7 @@ def _do_verify(conn, disk_id: int, target_ranges: Optional[List[range]], disk_fi worklist = list(heapq.merge( _get_v1_worklist(conn, disk_id, pg_target_ranges), _get_v2_worklist(conn, disk_id, pg_target_ranges), - key = lambda run: run.block_ranges, + key = _run_sort_key, )) if target_ranges is not None: