Make max-online-resize an option.

In fb246a02eb we introduced an
ext4 option to allow root filesystems to be resized up to 1PB.
This appears to cause an ext4 resize2fs bug in some images.

When the issue occurs an image will hit a kernel bug when
cloud-init runs the resize2fs command during first boot:

  kernel BUG at fs/ext4/resize.c:409!

In this commit we add a new option for max-online-resize
which can be used if a really large root partition is
desirable.

The root cause of all this is really a design problem in
DIB/TripleO at the moment in that we shouldn't have to worry about the
max size of the root file system when creating our images.  Ideally we'd
just mkfs on the root file system itself. Much more efficient,
avoids this problem altogether...

I think the best thing to do today to avoid this is make setting
max-online-resize an option in DIB. This will allow us to stick
to the (well tested) ext4 defaults for most cases, and if someone has
need for a large root filesystem they can easily bump the setting. This
may be temporary until we either fix the design... or the ext4 fix is
released.

Change-Id: I371f62555d2753cec48790c8fd811c4342af925c
Closes-bug: #1280709
This commit is contained in:
Dan Prince 2014-02-15 23:06:11 -05:00
parent 21c1a6205b
commit ea555476cc

View File

@ -52,6 +52,12 @@ function show_options () {
echo " -c -- clear environment before starting work"
echo " --image-size size -- image size in GB for the created image"
echo " --image-cache directory -- location for cached images(default ~/.cache/image-create)"
echo " --max-online-resize size -- max number of filesystem blocks to support when resizing."
echo " Useful if you want a really large root partition when the image is deployed."
echo " Using a very large value may run into a known bug in resize2fs."
echo " Setting the value to 274877906944 will get you a 1PB root file system."
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 " --no-tmpfs -- do not use tmpfs to speed image build"
echo " --offline -- do not update cached resources"
@ -78,7 +84,7 @@ function show_options () {
INSTALL_PACKAGES=""
COMPRESS_IMAGE="true"
TEMP=`getopt -o a:ho:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache: -n $SCRIPTNAME -- "$@"`
TEMP=`getopt -o a:ho:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize: -n $SCRIPTNAME -- "$@"`
if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
@ -96,6 +102,7 @@ while true ; do
-p) IFS="," read -a INSTALL_PACKAGES <<< "$2"; export INSTALL_PACKAGES ; shift 2 ;;
--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;;
--min-tmpfs) export DIB_MIN_TMPFS=$2; shift 2;;
--no-tmpfs) shift; export DIB_NO_TMPFS=1;;
--offline) shift; export DIB_OFFLINE=1;;
@ -158,8 +165,10 @@ else
MKFS_OPTS="-i 4096 -J size=64"
fi
fi
# allow up to 1PB of 4KB blocks.
MKFS_OPTS="$MKFS_OPTS -E resize=274877906944"
if [ -n "$MAX_ONLINE_RESIZE" ]; then
MKFS_OPTS="$MKFS_OPTS -E resize=$MAX_ONLINE_RESIZE"
fi
LOOPDEV=$(sudo losetup --show -f $TMP_IMAGE_PATH)
export EXTRA_UNMOUNT="detach_loopback $LOOPDEV"