From 11142f75b49be50ba16034f8e1296150763ee45a Mon Sep 17 00:00:00 2001 From: Logan V Date: Sat, 26 Jan 2019 14:02:54 -0600 Subject: [PATCH] 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 --- diskimage_builder/lib/disk-image-create | 12 ++++++++++-- doc/source/user_guide/building_an_image.rst | 7 +++++++ .../notes/root-journal-size-618e064d6681699a.yaml | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/root-journal-size-618e064d6681699a.yaml diff --git a/diskimage_builder/lib/disk-image-create b/diskimage_builder/lib/disk-image-create index 1b06c250..c90dcedb 100644 --- a/diskimage_builder/lib/disk-image-create +++ b/diskimage_builder/lib/disk-image-create @@ -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 diff --git a/doc/source/user_guide/building_an_image.rst b/doc/source/user_guide/building_an_image.rst index b3d3e64b..299cd953 100644 --- a/doc/source/user_guide/building_an_image.rst +++ b/doc/source/user_guide/building_an_image.rst @@ -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 diff --git a/releasenotes/notes/root-journal-size-618e064d6681699a.yaml b/releasenotes/notes/root-journal-size-618e064d6681699a.yaml new file mode 100644 index 00000000..e0971f6e --- /dev/null +++ b/releasenotes/notes/root-journal-size-618e064d6681699a.yaml @@ -0,0 +1,4 @@ +--- +features: + - The ``--mkfs-journal-size`` option is added to override the default + journal size for basic ext4 root partitions.