Allow specification of filesystem journal size

In many cases, the statically sized 64MB journal is far below the
e2fstools default calculation[0] which calls for a 64MB journal only
on filesystems smaller than 16GB. On bare metal in particular, the
correct default journal size will often be in the 512MB-1GB range.

Since we cannot know what the target system is, this should be a
tunable parameter that the user can set depending on the intended
image usage.

Add a DIB_JOURNAL_SIZE envvar and --mkfs-journal-size parameter
to the image creation so users can override the default journal
size.

[0] https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/tree/lib/ext2fs/mkjournal.c#n333

Change-Id: I65fa13a088eecdfe61636678578577ea2cfb3c0c
This commit is contained in:
Logan V 2019-01-26 14:02:54 -06:00 committed by Ian Wienand
parent d18e73147e
commit 11142f75b4
3 changed files with 21 additions and 2 deletions

View File

@ -70,6 +70,7 @@ function show_options () {
echo " Making this value unnecessarily large will consume extra disk space "
echo " on the root partition with extra file system inodes."
echo " --min-tmpfs size -- minimum size in GB needed in tmpfs to build the image"
echo " --mkfs-journal-size -- filesystem journal size in MB to pass to mkfs."
echo " --mkfs-options -- option flags to be passed directly to mkfs."
echo " Options should be passed as a single string value."
echo " --no-tmpfs -- do not use tmpfs to speed image build"
@ -149,6 +150,7 @@ while true ; do
--image-size) export DIB_IMAGE_SIZE=$2; shift 2;;
--image-cache) export DIB_IMAGE_CACHE=$2; shift 2;;
--max-online-resize) export MAX_ONLINE_RESIZE=$2; shift 2;;
--mkfs-journal-size) export DIB_JOURNAL_SIZE=$2; shift 2;;
--mkfs-options) MKFS_OPTS=$2; shift 2;;
--min-tmpfs) export DIB_MIN_TMPFS=$2; shift 2;;
--no-tmpfs) shift; export DIB_NO_TMPFS=1;;
@ -417,15 +419,21 @@ fi
rm -f ${du_output}
if [ -n "$DIB_JOURNAL_SIZE" ]; then
journal_size="$DIB_JOURNAL_SIZE"
else
journal_size=64
fi
if [ "$DIB_ROOT_FSTYPE" = "ext4" ] ; then
# Very conservative to handle images being resized a lot
# We set journal size to 64M so our journal is large enough when we
# perform an FS resize.
MKFS_OPTS="-i 4096 -J size=64 $MKFS_OPTS"
MKFS_OPTS="-i 4096 -J size=$journal_size $MKFS_OPTS"
# Grow the image size to account for the journal, only if the user
# has not asked for a specific size.
if [ -z "$DIB_IMAGE_SIZE" ]; then
du_size=$(( $du_size + 65536 ))
du_size=$(( $du_size + ($journal_size * 1024) ))
fi
fi

View File

@ -660,6 +660,13 @@ configuration:
default can be overridden by passing ``'-i 16384'`` as a
``--mkfs-options`` argument.
``--mkfs-journal-size``
Only valid for ``FS_TYPE==ext4``. This value set the filesystem
journal size in MB; overriding the default of 64MiB. Note the
image size will be grown to fit the journal, unless
``DIB_IMAGE_SIZE`` is explicitly set. Can also set
``DIB_JOURNAL_SIZE``.
``--max-online-resize``
Only valid for ``FS_TYPE==ext4``; this value sets the maximum
filesystem blocks when resizing. Can also set

View File

@ -0,0 +1,4 @@
---
features:
- The ``--mkfs-journal-size`` option is added to override the default
journal size for basic ext4 root partitions.