Skip to content

Commit 7b51473

Browse files
Myself5RakeshBatra
authored andcommitted
build_image: Allow disabling custom inode count calculation
This allows us to skip custom inode count calculation by setting BOARD_*IMAGE_EXTFS_INODE_COUNT to -1, this will end up letting mke2fs calculate appropriate inode count on its own. While build_image only allocates exact number of needed inodes plus 4% spare with .2% margin, mke2fs will allocate as many inodes as it thinks is appropriate given the filesystem size. Change-Id: If03d5edae8378be3b305346176067b01163f6f3d
1 parent cdedda1 commit 7b51473

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

tools/releasetools/build_image.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config):
271271
base_fs_file = ConvertBlockMapToBaseFs(prop_dict["base_fs_file"])
272272
build_command.extend(["-d", base_fs_file])
273273
build_command.extend(["-L", prop_dict["mount_point"]])
274-
if "extfs_inode_count" in prop_dict:
274+
if "extfs_inode_count" in prop_dict and int(prop_dict["extfs_inode_count"]) >= 0:
275275
build_command.extend(["-i", prop_dict["extfs_inode_count"]])
276276
if "extfs_rsv_pct" in prop_dict:
277277
build_command.extend(["-M", prop_dict["extfs_rsv_pct"]])
@@ -448,19 +448,20 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
448448
size = common.RoundUpTo4K(size)
449449
else:
450450
size = ((size + block_size - 1) // block_size) * block_size
451-
extfs_inode_count = prop_dict["extfs_inode_count"]
452-
inodes = int(fs_dict.get("Inode count", extfs_inode_count))
453-
inodes -= int(fs_dict.get("Free inodes", "0"))
454-
# add .2% margin or 1 inode, whichever is greater
455-
spare_inodes = inodes * 2 // 1000
456-
min_spare_inodes = 1
457-
if spare_inodes < min_spare_inodes:
458-
spare_inodes = min_spare_inodes
459-
inodes += spare_inodes
460-
prop_dict["extfs_inode_count"] = str(inodes)
451+
if int(prop_dict["extfs_inode_count"]) >= 0:
452+
extfs_inode_count = prop_dict["extfs_inode_count"]
453+
inodes = int(fs_dict.get("Inode count", extfs_inode_count))
454+
inodes -= int(fs_dict.get("Free inodes", "0"))
455+
# add .2% margin or 1 inode, whichever is greater
456+
spare_inodes = inodes * 2 // 1000
457+
min_spare_inodes = 1
458+
if spare_inodes < min_spare_inodes:
459+
spare_inodes = min_spare_inodes
460+
inodes += spare_inodes
461+
prop_dict["extfs_inode_count"] = str(inodes)
462+
logger.info(
463+
"Allocating %d Inodes for %s.", inodes, out_file)
461464
prop_dict["partition_size"] = str(size)
462-
logger.info(
463-
"Allocating %d Inodes for %s.", inodes, out_file)
464465
if verity_image_builder:
465466
size = verity_image_builder.CalculateDynamicPartitionSize(size)
466467
prop_dict["partition_size"] = str(size)

0 commit comments

Comments
 (0)