[Ovirt-devel] [PATCH node] Changed how max swap size is calculated.
Darryl L. Pierce
dpierce at redhat.com
Wed Jan 14 21:37:41 UTC 2009
Swap partition size is based on a calculated value added to a base value
defined in <http://kbase.redhat.com/faq/docs/DOC-15252>. The calculated
value is an overcommit value multiplied by the amount of memory on the
device.
If no overcommit value is specified then the default is 0.5.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-config-storage | 30 +++++++++++++++++++++++++-----
scripts/ovirt-early | 13 ++++++++++++-
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
index b3d87ae..7448452 100755
--- a/scripts/ovirt-config-storage
+++ b/scripts/ovirt-config-storage
@@ -80,7 +80,7 @@ get_dev_name()
done
# if we didn't find any devices using HAL, so check for virtual devices
- if [ -z $devices ]; then devices=$(ls -l /dev/[shv]d?); fi
+ if [ -z "$devices" ]; then devices=$(ls -l /dev/[shv]d?); fi
# If there's only one device, use it.
case $devices in
@@ -285,14 +285,34 @@ do_confirm()
done
}
+if [ -z "$OVIRT_OVERCOMMIT" ]; then OVIRT_OVERCOMMIT="1.5"; fi
MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal:/ { print $2 }')
case $MEM_SIZE in
''|*[^0-9]*) die failed to get system memory size;;
esac
+MEM_SIZE=$(echo "scale=0; $MEM_SIZE / 1024;" | bc -l)
+# we multiply the overcommit coefficient by 10 then divide the
+# product by 10 to avoid decimals in the result
+OVERCOMMIT_SWAP_SIZE=$(echo "scale=0; (${MEM_SIZE} * (${OVIRT_OVERCOMMIT} * 10))/10;" | bc -l)
+
+# add to the swap the amounts from http://kbase.redhat.com/faq/docs/DOC-15252
+mgb=$(echo "scale=0; $MEM_SIZE/1024;" | bc -l)
+if [ $mgb -le 4 ]; then
+ BASE_SWAP_SIZE=2
+elif [ $mgb -le 16 ]; then
+ BASE_SWAP_SIZE=4
+elif [ $mgb -le 64 ]; then
+ BASE_SWAP_SIZE=8
+else
+ BASE_SWAP_SIZE=16
+fi
-MEM_SIZE=$(echo "scale=0; m=($MEM_SIZE / 1024 * 2); if (m < 2048) { m } else { 2048 }" | bc -l)
-SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$MEM_SIZE}
+MAX_SWAP_SIZE=$(echo "scale=0; (${BASE_SWAP_SIZE} + ${OVERCOMMIT_SWAP_SIZE}) * 1024;" | bc -l)
+SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$MAX_SWAP_SIZE}
+if [ $SWAP_SIZE -gt $MAX_SWAP_SIZE ]; then
+ SWAP_SIZE=$MAX_SWAP_SIZE
+fi
BOOT_SIZE=${OVIRT_VOL_BOOT_SIZE:-$default_boot_size}
ROOT_SIZE=${OVIRT_VOL_ROOT_SIZE:-$default_root_size}
CONFIG_SIZE=${OVIRT_VOL_CONFIG_SIZE:-$default_config_size}
diff --git a/scripts/ovirt-early b/scripts/ovirt-early
index 153c0c7..95cf609 100755
--- a/scripts/ovirt-early
+++ b/scripts/ovirt-early
@@ -117,6 +117,7 @@ start() {
# BOOTIF=link|eth*|<MAC> (appended by pxelinux)
# ovirt_init=usb|scsi[:serial#]
# ovirt_vol=BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB
+ # ovirt_overcommit
# ovirt_local_boot
# ovirt_standalone
# pxelinux format: ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask>
@@ -156,6 +157,10 @@ start() {
# install/update oVirt Node image on the local installation target disk
local_boot=0
+ # ovirt_overcommit
+ # set the swap size coefficient
+ overcommit=0.5
+
# ovirt_standalone
# force oVirt Node standalone mode
standalone=0
@@ -245,6 +250,12 @@ start() {
standalone=1
bootparams="$bootparams $i"
;;
+
+ ovirt_overcommit*)
+ i=${i#ovirt_overcommit=}
+ eval $(printf $i|awk -F: '{print "overcommit="$1;}')
+ ;;
+
ip=*)
i=${i#ip=}
eval $(printf $i|awk -F: '{print "ip_address="$1; print "ip_gateway="$3; print "ip_netmask="$4}')
@@ -278,7 +289,7 @@ start() {
ip_gateway=$gateway
fi
# save boot parameters as defaults for ovirt-config-*
- params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname"
+ params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 syslog_server syslog_port bootparams hostname"
mount_config
if [ -e $OVIRT_DEFAULTS ]; then
echo "update ovirt defaults"
--
1.6.0.6
More information about the ovirt-devel
mailing list