Merge "build_image: right-sizing at least some spare inode"
This commit is contained in:
commit
f2f1854ca4
1 changed files with 14 additions and 5 deletions
|
@ -76,7 +76,12 @@ def GetInodeUsage(path):
|
||||||
cmd = ["find", path, "-print"]
|
cmd = ["find", path, "-print"]
|
||||||
output = common.RunAndCheckOutput(cmd, verbose=False)
|
output = common.RunAndCheckOutput(cmd, verbose=False)
|
||||||
# increase by > 4% as number of files and directories is not whole picture.
|
# increase by > 4% as number of files and directories is not whole picture.
|
||||||
return output.count('\n') * 25 // 24
|
inodes = output.count('\n')
|
||||||
|
spare_inodes = inodes * 4 // 100
|
||||||
|
min_spare_inodes = 8
|
||||||
|
if spare_inodes < min_spare_inodes:
|
||||||
|
spare_inodes = min_spare_inodes
|
||||||
|
return inodes + spare_inodes
|
||||||
|
|
||||||
|
|
||||||
def GetFilesystemCharacteristics(image_path, sparse_image=True):
|
def GetFilesystemCharacteristics(image_path, sparse_image=True):
|
||||||
|
@ -436,8 +441,8 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
|
||||||
size -= free_size
|
size -= free_size
|
||||||
size += reserved_size
|
size += reserved_size
|
||||||
if reserved_size == 0:
|
if reserved_size == 0:
|
||||||
# add .2% margin
|
# add .3% margin
|
||||||
size = size * 1002 // 1000
|
size = size * 1003 // 1000
|
||||||
# Use a minimum size, otherwise we will fail to calculate an AVB footer
|
# Use a minimum size, otherwise we will fail to calculate an AVB footer
|
||||||
# or fail to construct an ext4 image.
|
# or fail to construct an ext4 image.
|
||||||
size = max(size, 256 * 1024)
|
size = max(size, 256 * 1024)
|
||||||
|
@ -448,8 +453,12 @@ def BuildImage(in_dir, prop_dict, out_file, target_out=None):
|
||||||
extfs_inode_count = prop_dict["extfs_inode_count"]
|
extfs_inode_count = prop_dict["extfs_inode_count"]
|
||||||
inodes = int(fs_dict.get("Inode count", extfs_inode_count))
|
inodes = int(fs_dict.get("Inode count", extfs_inode_count))
|
||||||
inodes -= int(fs_dict.get("Free inodes", "0"))
|
inodes -= int(fs_dict.get("Free inodes", "0"))
|
||||||
# add .2% margin
|
# add .2% margin or 1 inode, whichever is greater
|
||||||
inodes = inodes * 1002 // 1000
|
spare_inodes = inodes * 2 // 1000
|
||||||
|
min_spare_inodes = 1
|
||||||
|
if spare_inodes < min_spare_inodes:
|
||||||
|
spare_inodes = min_spare_inodes
|
||||||
|
inodes += spare_inodes
|
||||||
prop_dict["extfs_inode_count"] = str(inodes)
|
prop_dict["extfs_inode_count"] = str(inodes)
|
||||||
prop_dict["partition_size"] = str(size)
|
prop_dict["partition_size"] = str(size)
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
Loading…
Reference in a new issue