Set stripe_width and stride params in make_ext4fs
If available, make_ext4fs will use flash erase & logical block
sizes to tune stride and stripe_width.
Test: Build userdata w/ make_ext4fs, flash, check stride & stripe values
Bug: 33243520
Change-Id: I54f95d822cc1ccc0ebb5edec023560cd9e30e259
Signed-off-by: Connor O'Brien <connoro@google.com>
diff --git a/ext4_utils/ext4_utils.c b/ext4_utils/ext4_utils.c
index fa5f673..550181f 100644
--- a/ext4_utils/ext4_utils.c
+++ b/ext4_utils/ext4_utils.c
@@ -352,10 +352,14 @@
sb->s_want_extra_isize = sizeof(struct ext4_inode) -
EXT4_GOOD_OLD_INODE_SIZE;
sb->s_flags = 2;
- sb->s_raid_stride = 0;
+ sb->s_raid_stride = info.flash_logical_block_size / info.block_size;
+ // stride should be the max of 8kb and logical block size
+ if (info.flash_logical_block_size != 0 && info.flash_logical_block_size < 8192) {
+ sb->s_raid_stride = 8192 / info.block_size;
+ }
sb->s_mmp_interval = 0;
sb->s_mmp_block = 0;
- sb->s_raid_stripe_width = 0;
+ sb->s_raid_stripe_width = info.flash_erase_block_size / info.block_size;
sb->s_log_groups_per_flex = 0;
sb->s_kbytes_written = 0;
diff --git a/ext4_utils/include/ext4_utils/ext4_sb.h b/ext4_utils/include/ext4_utils/ext4_sb.h
index 11b8971..45e0ec9 100644
--- a/ext4_utils/include/ext4_utils/ext4_sb.h
+++ b/ext4_utils/include/ext4_utils/ext4_sb.h
@@ -33,6 +33,8 @@
* end of the partition, else use the size given. */
uint32_t block_size;
uint32_t blocks_per_group;
+ uint32_t flash_erase_block_size;
+ uint32_t flash_logical_block_size;
uint32_t inodes_per_group;
uint32_t inode_size;
uint32_t inodes;
diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c
index 87cb53e..77930cd 100644
--- a/ext4_utils/make_ext4fs_main.c
+++ b/ext4_utils/make_ext4fs_main.c
@@ -54,6 +54,7 @@
{
fprintf(stderr, "%s [ -l <len> ] [ -j <journal size> ] [ -b <block_size> ]\n", basename(path));
fprintf(stderr, " [ -g <blocks per group> ] [ -i <inodes> ] [ -I <inode size> ]\n");
+ fprintf(stderr, " [ -e <flash erase block size> ] [ -o <flash logical block size> ]\n");
fprintf(stderr, " [ -L <label> ] [ -f ] [ -a <android mountpoint> ] [ -u ]\n");
fprintf(stderr, " [ -S file_contexts ] [ -C fs_config ] [ -T timestamp ]\n");
fprintf(stderr, " [ -z | -s ] [ -w ] [ -c ] [ -J ] [ -v ] [ -B <block_list_file> ]\n");
@@ -87,7 +88,7 @@
struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "" } };
#endif
- while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:S:T:C:B:d:D:fwzJsctvu")) != -1) {
+ while ((opt = getopt(argc, argv, "l:j:b:g:i:I:e:o:L:a:S:T:C:B:d:D:fwzJsctvu")) != -1) {
switch (opt) {
case 'l':
info.len = parse_num(optarg);
@@ -107,6 +108,12 @@
case 'I':
info.inode_size = parse_num(optarg);
break;
+ case 'e':
+ info.flash_erase_block_size = parse_num(optarg);
+ break;
+ case 'o':
+ info.flash_logical_block_size = parse_num(optarg);
+ break;
case 'L':
info.label = optarg;
break;
diff --git a/ext4_utils/mkuserimg.sh b/ext4_utils/mkuserimg.sh
index 08c75be..06c68d4 100755
--- a/ext4_utils/mkuserimg.sh
+++ b/ext4_utils/mkuserimg.sh
@@ -8,7 +8,7 @@
mkuserimg.sh [-s] SRC_DIR OUTPUT_FILE EXT_VARIANT MOUNT_POINT SIZE [-j <journal_size>]
[-T TIMESTAMP] [-C FS_CONFIG] [-D PRODUCT_OUT] [-B BLOCK_LIST_FILE]
[-d BASE_ALLOC_FILE_IN ] [-A BASE_ALLOC_FILE_OUT ] [-L LABEL]
- [-i INODES ] [FILE_CONTEXTS]
+ [-i INODES ] [-e ERASE_BLOCK_SIZE] [-o FLASH_BLOCK_SIZE] [FILE_CONTEXTS]
EOT
}
@@ -92,6 +92,18 @@
INODES=$2
shift; shift
fi
+
+ERASE_SIZE=
+if [[ "$1" == "-e" ]]; then
+ ERASE_SIZE=$2
+ shift; shift
+fi
+
+FLASH_BLOCK_SIZE=
+if [[ "$1" == "-o" ]]; then
+ FLASH_BLOCK_SIZE=$2
+ shift; shift
+fi
FC=$1
case $EXT_VARIANT in
@@ -131,6 +143,12 @@
if [ -n "$INODES" ]; then
OPT="$OPT -i $INODES"
fi
+if [ -n "$ERASE_SIZE" ]; then
+ OPT="$OPT -e $ERASE_SIZE"
+fi
+if [ -n "$FLASH_BLOCK_SIZE" ]; then
+ OPT="$OPT -o $FLASH_BLOCK_SIZE"
+fi
MAKE_EXT4FS_CMD="make_ext4fs $ENABLE_SPARSE_IMAGE -T $TIMESTAMP $OPT -l $SIZE $JOURNAL_FLAGS -a $MOUNT_POINT $OUTPUT_FILE $SRC_DIR $PRODUCT_OUT"
echo $MAKE_EXT4FS_CMD