From d1c04beb59e2645913de3f2d405c69867d60b06d Mon Sep 17 00:00:00 2001 From: grev Date: Thu, 12 Mar 2009 21:22:21 +0000 Subject: [PATCH] b=18623 i=Andrew.Perepechko ENABLE_QUOTA acc-sm patch --- lustre/tests/acceptance-small.sh | 1 + lustre/tests/cfg/local.sh | 4 ++ lustre/tests/sanity-quota.sh | 13 +------ lustre/tests/test-framework.sh | 83 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 11 deletions(-) diff --git a/lustre/tests/acceptance-small.sh b/lustre/tests/acceptance-small.sh index ceca69f..4c4029e 100755 --- a/lustre/tests/acceptance-small.sh +++ b/lustre/tests/acceptance-small.sh @@ -62,6 +62,7 @@ setup_if_needed() { local MOUNTED=$(mounted_lustre_filesystems) if $(echo $MOUNTED | grep -w -q $MOUNT); then check_config $MOUNT + init_facets_vars init_param_vars return fi diff --git a/lustre/tests/cfg/local.sh b/lustre/tests/cfg/local.sh index a436cef..1251777 100644 --- a/lustre/tests/cfg/local.sh +++ b/lustre/tests/cfg/local.sh @@ -44,6 +44,10 @@ PTLDEBUG=${PTLDEBUG:-0x33f0404} DEBUG_SIZE=${DEBUG_SIZE:-10} SUBSYSTEM=${SUBSYSTEM:- 0xffb7e3ff} +ENABLE_QUOTA=${ENABLE_QUOTA:-""} +QUOTA_TYPE=${QUOTA_TYPE:-"ug"} +QUOTA_USERS=${QUOTA_USERS:-"quota_usr quota_2usr sanityusr sanityusr1"} + MKFSOPT="" [ "x$MDSJOURNALSIZE" != "x" ] && MKFSOPT=$MKFSOPT" -J size=$MDSJOURNALSIZE" diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 9073678..4990882 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -41,6 +41,8 @@ IUNIT_SZ=${IUNIT_SZ:-10} # min inode quota unit MAX_DQ_TIME=604800 MAX_IQ_TIME=604800 +unset ENABLE_QUOTA + TRACE=${TRACE:-""} LUSTRE=${LUSTRE:-`dirname $0`/..} . $LUSTRE/tests/test-framework.sh @@ -1194,17 +1196,6 @@ test_14a() { # was test_14 b=12223 -- setting quota on root } run_test_with_stat 14a "test setting quota on root ===" -# save quota version (both administrative and operational quotas) -quota_save_version() { - do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdd.quota_type=$1" - local varsvc - local osts=$(get_facets OST) - for ost in ${osts//,/ }; do - varsvc=${ost}_svc - do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$1" - done -} - test_15(){ LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`" diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index bbfe6b6..ea88d8f 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -514,6 +514,83 @@ stop() { wait_exit_ST ${facet} } +# save quota version (both administrative and operational quotas) +quota_save_version() { + local fsname=${2:-$FSNAME} + do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$1" + local varsvc + local osts=$(get_facets OST) + for ost in ${osts//,/ }; do + varsvc=${ost}_svc + do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$1" + done +} + +# client could mount several lustre +quota_type () { + local fsname=${1:-$FSNAME} + local rc=0 + do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$? + do_nodes $(comma_list $(osts_nodes)) \ + lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$? + return $rc +} + +restore_quota_type () { + local mntpt=${1:-$MOUNT} + local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2) + if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then + return + fi + $LFS quotaoff $mntpt + quota_save_version $old_QUOTA_TYPE + $LFS quotacheck -ug $mntpt +} + +setup_quota(){ + local mntpt=$1 + + # We need: + # 1. run quotacheck only if quota is off + # 2. save the original quota_type params, restore them after testing + + # Suppose that quota type the same on mds and ost + local quota_type=$(quota_type | grep MDT | cut -d "=" -f2) + [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!" + if [ "$quota_type" != "$QUOTA_TYPE" ]; then + export old_QUOTA_TYPE=$quota_type + quota_save_version $QUOTA_TYPE + $LFS quotacheck -ug $mntpt + fi + + local quota_usrs=$QUOTA_USERS + + # get_filesystem_size + local disksz=$(lfs df | grep "filesystem summary:" | awk '{print $3}') + local blk_soft=$((disksz + 1024)) + local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over + + local Inodes=$(lfs df -i | grep "filesystem summary:" | awk '{print $3}') + local i_soft=$Inodes + local i_hard=$((i_soft + i_soft / 20)) + + echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit: + $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard" + + local cmd + for usr in $quota_usrs; do + echo "Setting up quota on $client:$mntpt for $usr..." + for type in u g; do + cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt" + echo "+ $cmd" + eval $cmd || error "$cmd FAILED!" + done + # display the quota status + echo "Quota settings for $usr : " + $LFS quota -v -u $usr $mntpt || true + done +} + zconf_mount() { local OPTIONS local client=$1 @@ -1511,6 +1588,11 @@ init_param_vars () { TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout") log "Using TIMEOUT=$TIMEOUT" + + if [ "$ENABLE_QUOTA" ]; then + setup_quota $MOUNT || return 2 + fi + } check_config () { @@ -1572,6 +1654,7 @@ cleanup_and_setup_lustre() { check_and_cleanup_lustre() { if [ "`mount | grep $MOUNT`" ]; then [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* + [ "$ENABLE_QUOTA" ] && restore_quota_type || true fi if [ "$I_MOUNTED" = "yes" ]; then cleanupall -f || error "cleanup failed" -- 1.8.3.1