forked from openkylin/platform_build
build_image: default extfs reserved size to 0 on RO partitions.
Defaults the reserved blocks for root to 0% on read only partitions (system, system_other, vendor, oem). It also adds support for explicitly specifying the extfs reserved percentage via BOARD_{SYSTEM,VENDOR,OEM,PRODUCT}IMAGE_EXTFS_RSV_PCT. This eventually translates down to the -m option for mkfs. Removing the reserved space can save at least 5% from the default. dumpe2fs system: Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) Bug: 75975085 Test: Build, verify reserved space is changed accordingly Change-Id: I212d82741908b636db0d658a1c4847bbaadfd5ba
This commit is contained in:
parent
c6063bf93c
commit
5ff758799c
|
@ -1087,6 +1087,7 @@ $(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMA
|
|||
$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1))
|
||||
$(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
|
||||
$(if $(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "system_extfs_inode_count=$(BOARD_SYSTEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
|
||||
$(if $(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "system_extfs_rsv_pct=$(BOARD_SYSTEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
|
||||
$(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1))
|
||||
$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
|
||||
$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
|
||||
|
@ -1103,6 +1104,7 @@ $(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CA
|
|||
$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
|
||||
$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
|
||||
$(if $(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT),$(hide) echo "vendor_extfs_inode_count=$(BOARD_VENDORIMAGE_EXTFS_INODE_COUNT)" >> $(1))
|
||||
$(if $(BOARD_VENDORIMAGE_EXTFS_RSV_PCT),$(hide) echo "vendor_extfs_rsv_pct=$(BOARD_VENDORIMAGE_EXTFS_RSV_PCT)" >> $(1))
|
||||
$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1))
|
||||
$(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1))
|
||||
$(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
|
||||
|
@ -1112,6 +1114,7 @@ $(if $(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_squashf
|
|||
$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1))
|
||||
$(if $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "product_fs_type=$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
|
||||
$(if $(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT),$(hide) echo "product_extfs_inode_count=$(BOARD_PRODUCTIMAGE_EXTFS_INODE_COUNT)" >> $(1))
|
||||
$(if $(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT),$(hide) echo "product_extfs_rsv_pct=$(BOARD_PRODUCTIMAGE_EXTFS_RSV_PCT)" >> $(1))
|
||||
$(if $(BOARD_PRODUCTIMAGE_PARTITION_SIZE),$(hide) echo "product_size=$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)" >> $(1))
|
||||
$(if $(BOARD_PRODUCTIMAGE_JOURNAL_SIZE),$(hide) echo "product_journal_size=$(BOARD_PRODUCTIMAGE_JOURNAL_SIZE)" >> $(1))
|
||||
$(if $(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "product_squashfs_compressor=$(BOARD_PRODUCTIMAGE_SQUASHFS_COMPRESSOR)" >> $(1))
|
||||
|
@ -1122,6 +1125,7 @@ $(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PRODUCT_BASE_FS_PATH),$(hide) echo "
|
|||
$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
|
||||
$(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
|
||||
$(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
|
||||
$(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
|
||||
$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1))
|
||||
$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1))
|
||||
$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1)
|
||||
|
|
|
@ -545,6 +545,8 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
|
|||
build_command.extend(["-L", prop_dict["mount_point"]])
|
||||
if "extfs_inode_count" in prop_dict:
|
||||
build_command.extend(["-i", prop_dict["extfs_inode_count"]])
|
||||
if "extfs_rsv_pct" in prop_dict:
|
||||
build_command.extend(["-M", prop_dict["extfs_rsv_pct"]])
|
||||
if "flash_erase_block_size" in prop_dict:
|
||||
build_command.extend(["-e", prop_dict["flash_erase_block_size"]])
|
||||
if "flash_logical_block_size" in prop_dict:
|
||||
|
@ -686,8 +688,18 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
|
|||
d["timestamp"] = bp["ro.build.date.utc"]
|
||||
|
||||
def copy_prop(src_p, dest_p):
|
||||
"""Copy a property from the global dictionary.
|
||||
|
||||
Args:
|
||||
src_p: The source property in the global dictionary.
|
||||
dest_p: The destination property.
|
||||
Returns:
|
||||
True if property was found and copied, False otherwise.
|
||||
"""
|
||||
if src_p in glob_dict:
|
||||
d[dest_p] = str(glob_dict[src_p])
|
||||
return True
|
||||
return False
|
||||
|
||||
common_props = (
|
||||
"extfs_sparse_flag",
|
||||
|
@ -732,6 +744,8 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
|
|||
copy_prop("system_squashfs_disable_4k_align", "squashfs_disable_4k_align")
|
||||
copy_prop("system_base_fs_file", "base_fs_file")
|
||||
copy_prop("system_extfs_inode_count", "extfs_inode_count")
|
||||
if not copy_prop("system_extfs_rsv_pct", "extfs_rsv_pct"):
|
||||
d["extfs_rsv_pct"] = "0"
|
||||
elif mount_point == "system_other":
|
||||
# We inherit the selinux policies of /system since we contain some of its
|
||||
# files.
|
||||
|
@ -751,6 +765,8 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
|
|||
copy_prop("system_squashfs_block_size", "squashfs_block_size")
|
||||
copy_prop("system_base_fs_file", "base_fs_file")
|
||||
copy_prop("system_extfs_inode_count", "extfs_inode_count")
|
||||
if not copy_prop("system_extfs_rsv_pct", "extfs_rsv_pct"):
|
||||
d["extfs_rsv_pct"] = "0"
|
||||
elif mount_point == "data":
|
||||
# Copy the generic fs type first, override with specific one if available.
|
||||
copy_prop("fs_type", "fs_type")
|
||||
|
@ -778,6 +794,8 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
|
|||
copy_prop("vendor_squashfs_disable_4k_align", "squashfs_disable_4k_align")
|
||||
copy_prop("vendor_base_fs_file", "base_fs_file")
|
||||
copy_prop("vendor_extfs_inode_count", "extfs_inode_count")
|
||||
if not copy_prop("vendor_extfs_rsv_pct", "extfs_rsv_pct"):
|
||||
d["extfs_rsv_pct"] = "0"
|
||||
elif mount_point == "product":
|
||||
copy_prop("avb_product_hashtree_enable", "avb_hashtree_enable")
|
||||
copy_prop("avb_product_add_hashtree_footer_args",
|
||||
|
@ -794,11 +812,15 @@ def ImagePropFromGlobalDict(glob_dict, mount_point):
|
|||
copy_prop("product_squashfs_disable_4k_align", "squashfs_disable_4k_align")
|
||||
copy_prop("product_base_fs_file", "base_fs_file")
|
||||
copy_prop("product_extfs_inode_count", "extfs_inode_count")
|
||||
if not copy_prop("product_extfs_rsv_pct", "extfs_rsv_pct"):
|
||||
d["extfs_rsv_pct"] = "0"
|
||||
elif mount_point == "oem":
|
||||
copy_prop("fs_type", "fs_type")
|
||||
copy_prop("oem_size", "partition_size")
|
||||
copy_prop("oem_journal_size", "journal_size")
|
||||
copy_prop("oem_extfs_inode_count", "extfs_inode_count")
|
||||
if not copy_prop("oem_extfs_rsv_pct", "extfs_rsv_pct"):
|
||||
d["extfs_rsv_pct"] = "0"
|
||||
d["partition_name"] = mount_point
|
||||
return d
|
||||
|
||||
|
|
Loading…
Reference in New Issue