diff options
author | Tao Bao <tbao@google.com> | 2015-07-09 17:37:49 -0700 |
---|---|---|
committer | Tao Bao <tbao@google.com> | 2015-07-10 12:16:56 -0700 |
commit | 2fd2c9bfd6c9beeaeccb4632b785227fe56c6006 (patch) | |
tree | b9b83541c4147f5719742c8bf55afbcbde9f4324 /tools/releasetools/sparse_img.py | |
parent | 2a3a2dc33c7e5cbd9da95ece2eec0c100e9fbc14 (diff) | |
download | build-2fd2c9bfd6c9beeaeccb4632b785227fe56c6006.zip build-2fd2c9bfd6c9beeaeccb4632b785227fe56c6006.tar.gz build-2fd2c9bfd6c9beeaeccb4632b785227fe56c6006.tar.bz2 |
Zero out blocks that may be touched by dm-verity.
dm-verity may touch some blocks that are not in the care_map due to
block device read-ahead. It will fail if such blocks contain
non-zeroes. As a workaround, we mark them as extended blocks and
zero out explicitly to avoid dm-verity failures.
Bug: 20881595
Change-Id: I54e24e70ad822c0d6d7af43301f74d24505f4461
Diffstat (limited to 'tools/releasetools/sparse_img.py')
-rw-r--r-- | tools/releasetools/sparse_img.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/releasetools/sparse_img.py b/tools/releasetools/sparse_img.py index 7019f00..07f3c1c 100644 --- a/tools/releasetools/sparse_img.py +++ b/tools/releasetools/sparse_img.py @@ -110,6 +110,17 @@ class SparseImage(object): self.care_map = rangelib.RangeSet(care_data) self.offset_index = [i[0] for i in offset_map] + # Bug: 20881595 + # Introduce extended blocks as a workaround for the bug. dm-verity may + # touch blocks that are not in the care_map due to block device + # read-ahead. It will fail if such blocks contain non-zeroes. We zero out + # the extended blocks explicitly to avoid dm-verity failures. 512 blocks + # are the maximum read-ahead we configure for dm-verity block devices. + extended = self.care_map.extend(512) + all_blocks = rangelib.RangeSet(data=(0, self.total_blocks)) + extended = extended.intersect(all_blocks).subtract(self.care_map) + self.extended = extended + if file_map_fn: self.LoadFileBlockMap(file_map_fn, self.clobbered_blocks) else: |