[Ovirt-devel] [PATCH node] Changed how max swap size is calculated.
Darryl L. Pierce
dpierce at redhat.com
Wed Jan 14 21:56:16 UTC 2009
NOTE: this version removes the upper limit on swap size and only uses
the calculated value if no size was specified.
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 | 24 ++++++++++++++++++++----
scripts/ovirt-early | 13 ++++++++++++-
2 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
index c7538a5..8e7cc14 100755
--- a/scripts/ovirt-config-storage
+++ b/scripts/ovirt-config-storage
@@ -289,10 +289,26 @@ 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}
+CALC_SWAP_SIZE=$(echo "scale=0; (${BASE_SWAP_SIZE} + ${OVERCOMMIT_SWAP_SIZE}) * 1024;" | bc -l)
+SWAP_SIZE=${OVIRT_VOL_SWAP_SIZE:-$CALC_SWAP_SIZE}
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