Merge "Fix calculation of stashed blocks."
This commit is contained in:
commit
db08d835d0
|
@ -338,8 +338,8 @@ class BlockImageDiff(object):
|
||||||
sid = next_stash_id
|
sid = next_stash_id
|
||||||
next_stash_id += 1
|
next_stash_id += 1
|
||||||
stashes[s] = sid
|
stashes[s] = sid
|
||||||
stashed_blocks += sr.size()
|
|
||||||
if self.version == 2:
|
if self.version == 2:
|
||||||
|
stashed_blocks += sr.size()
|
||||||
out.append("stash %d %s\n" % (sid, sr.to_string_raw()))
|
out.append("stash %d %s\n" % (sid, sr.to_string_raw()))
|
||||||
else:
|
else:
|
||||||
sh = self.HashBlocks(self.src, sr)
|
sh = self.HashBlocks(self.src, sr)
|
||||||
|
@ -347,12 +347,14 @@ class BlockImageDiff(object):
|
||||||
stashes[sh] += 1
|
stashes[sh] += 1
|
||||||
else:
|
else:
|
||||||
stashes[sh] = 1
|
stashes[sh] = 1
|
||||||
|
stashed_blocks += sr.size()
|
||||||
out.append("stash %s %s\n" % (sh, sr.to_string_raw()))
|
out.append("stash %s %s\n" % (sh, sr.to_string_raw()))
|
||||||
|
|
||||||
if stashed_blocks > max_stashed_blocks:
|
if stashed_blocks > max_stashed_blocks:
|
||||||
max_stashed_blocks = stashed_blocks
|
max_stashed_blocks = stashed_blocks
|
||||||
|
|
||||||
free_string = []
|
free_string = []
|
||||||
|
free_size = 0
|
||||||
|
|
||||||
if self.version == 1:
|
if self.version == 1:
|
||||||
src_str = xf.src_ranges.to_string_raw() if xf.src_ranges else ""
|
src_str = xf.src_ranges.to_string_raw() if xf.src_ranges else ""
|
||||||
|
@ -371,7 +373,6 @@ class BlockImageDiff(object):
|
||||||
mapped_stashes = []
|
mapped_stashes = []
|
||||||
for s, sr in xf.use_stash:
|
for s, sr in xf.use_stash:
|
||||||
sid = stashes.pop(s)
|
sid = stashes.pop(s)
|
||||||
stashed_blocks -= sr.size()
|
|
||||||
unstashed_src_ranges = unstashed_src_ranges.subtract(sr)
|
unstashed_src_ranges = unstashed_src_ranges.subtract(sr)
|
||||||
sh = self.HashBlocks(self.src, sr)
|
sh = self.HashBlocks(self.src, sr)
|
||||||
sr = xf.src_ranges.map_within(sr)
|
sr = xf.src_ranges.map_within(sr)
|
||||||
|
@ -384,11 +385,13 @@ class BlockImageDiff(object):
|
||||||
# and lead to OTA failures.
|
# and lead to OTA failures.
|
||||||
# Bug: 23119955
|
# Bug: 23119955
|
||||||
free_string.append("free %d\n" % (sid,))
|
free_string.append("free %d\n" % (sid,))
|
||||||
|
free_size += sr.size()
|
||||||
else:
|
else:
|
||||||
assert sh in stashes
|
assert sh in stashes
|
||||||
src_str.append("%s:%s" % (sh, sr.to_string_raw()))
|
src_str.append("%s:%s" % (sh, sr.to_string_raw()))
|
||||||
stashes[sh] -= 1
|
stashes[sh] -= 1
|
||||||
if stashes[sh] == 0:
|
if stashes[sh] == 0:
|
||||||
|
free_size += sr.size()
|
||||||
free_string.append("free %s\n" % (sh))
|
free_string.append("free %s\n" % (sh))
|
||||||
stashes.pop(sh)
|
stashes.pop(sh)
|
||||||
heapq.heappush(free_stash_ids, sid)
|
heapq.heappush(free_stash_ids, sid)
|
||||||
|
@ -492,6 +495,7 @@ class BlockImageDiff(object):
|
||||||
|
|
||||||
if free_string:
|
if free_string:
|
||||||
out.append("".join(free_string))
|
out.append("".join(free_string))
|
||||||
|
stashed_blocks -= free_size
|
||||||
|
|
||||||
if self.version >= 2 and common.OPTIONS.cache_size is not None:
|
if self.version >= 2 and common.OPTIONS.cache_size is not None:
|
||||||
# Sanity check: abort if we're going to need more stash space than
|
# Sanity check: abort if we're going to need more stash space than
|
||||||
|
|
Loading…
Reference in New Issue