aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2019-01-10 10:36:34 -0600
committerMark Salyzyn2019-01-10 16:49:24 -0600
commit60a716fe8c4bff137fad55943b5a172de0158020 (patch)
tree8706a7f742cb6cae109c9da11b5cc0363b1eb97d
parentc777eaa779fd171abb80640656e2164b15dbc63b (diff)
downloadplatform-build-60a716fe8c4bff137fad55943b5a172de0158020.tar.gz
platform-build-60a716fe8c4bff137fad55943b5a172de0158020.tar.xz
platform-build-60a716fe8c4bff137fad55943b5a172de0158020.zip
build_image: right-sizing add .2% margin for space and inodes
To address flakiness in image creation, add a .2% margin of safety for both inodes and space for ext filesystems. Test: build Bug: 122328872 Change-Id: I6665bd6fe642291b825dba58dfd09cc55628230f
-rwxr-xr-xtools/releasetools/build_image.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index f5163090f..29d363381 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -428,16 +428,21 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
428 else: 428 else:
429 size -= free_size 429 size -= free_size
430 size += reserved_size 430 size += reserved_size
431 if reserved_size == 0:
432 # add .2% margin
433 size = size * 1002 // 1000
434 # Use a minimum size, otherwise we will fail to calculate an AVB footer
435 # or fail to construct an ext4 image.
436 size = max(size, 256 * 1024)
431 if block_size <= 4096: 437 if block_size <= 4096:
432 size = common.RoundUpTo4K(size) 438 size = common.RoundUpTo4K(size)
433 else: 439 else:
434 size = ((size + block_size - 1) // block_size) * block_size 440 size = ((size + block_size - 1) // block_size) * block_size
435 # Use a minimum size, otherwise we will fail to calculate an AVB footer
436 # or fail to construct an ext4 image.
437 size = max(size, 256 * 1024)
438 extfs_inode_count = prop_dict["extfs_inode_count"] 441 extfs_inode_count = prop_dict["extfs_inode_count"]
439 inodes = int(fs_dict.get("Inode count", extfs_inode_count)) 442 inodes = int(fs_dict.get("Inode count", extfs_inode_count))
440 inodes -= int(fs_dict.get("Free inodes", "0")) 443 inodes -= int(fs_dict.get("Free inodes", "0"))
444 # add .2% margin
445 inodes = inodes * 1002 // 1000
441 prop_dict["extfs_inode_count"] = str(inodes) 446 prop_dict["extfs_inode_count"] = str(inodes)
442 prop_dict["partition_size"] = str(size) 447 prop_dict["partition_size"] = str(size)
443 logger.info( 448 logger.info(