From f61b3d09065705b4d58fa9c74cadfdad6eb64548 Mon Sep 17 00:00:00 2001 From: Elena Gryaznova Date: Tue, 24 Aug 2021 14:23:22 +0300 Subject: [PATCH 1/1] LU-14961 tests: set Pool Quotas We are interested in running some tests on fs with pool quotas set for some users. For instance, setting pool quotas limits for mpiuser allows to stress pool quotas code with mpi tests. Patch adds ability to set pool quotas block hard limits for specific users via POOLS_QUOTA_USERS_SET. Example: POOLS_QUOTA_USERS_SET="quota15_1:20M quota15_2:1G:gpool0 quota15_4:200M:gpool0 quota15_4:200M:gpool1" For quota15_1 limit 20M will be set for all existing pools. Test-Parameters: env=FS_POOL="glo",POOLS_QUOTA_USERS_SET="mpiuser:200M quota15_1:2000M:glo1",FS_NPOOLS="2",ENABLE_QUOTA="yes" Signed-off-by: Elena Gryaznova HPE-bug-id: LUS-10059 Reviewed-by: Vladimir Saveliev Reviewed-by: Sergey Cheremencev Change-Id: Ia9ee540ca77e70f37aa849e5e555e3c057e2052d Reviewed-on: https://review.whamcloud.com/44740 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/tests/test-framework.sh | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 0380a3d..d6b5ce3 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -5450,6 +5450,65 @@ create_pools () { done } +set_pools_quota () { + local u + local o + local p + local i + local j + + [[ $ENABLE_QUOTA ]] || error "Required Pool Quotas: \ + $POOLS_QUOTA_USERS_SET, but ENABLE_QUOTA not set!" + + # POOLS_QUOTA_USERS_SET= + # "quota15_1:20M -- for all of the found pools + # quota15_2:1G:gpool0 + # quota15_3 -- for global limit only + # quota15_4:200M:gpool0 + # quota15_4:200M:gpool1" + + declare -a pq_userset=(${POOLS_QUOTA_USERS_SET="mpiuser"}) + declare -a pq_users + declare -A pq_limits + + for ((i=0; i<${#pq_userset[@]}; i++)); do + u=${pq_userset[i]%%:*} + o="" + # user gets no pool limits if + # POOLS_QUOTA_USERS_SET does not specify it + [[ ${pq_userset[i]} =~ : ]] && o=${pq_userset[i]##$u:} + pq_limits[$u]+=" $o" + done + pq_users=(${!pq_limits[@]}) + + declare -a opts + local pool + + for ((i=0; i<${#pq_users[@]}; i++)); do + u=${pq_users[i]} + # set to max limit (_u64) + $LFS setquota -u $u -B $((2**24 - 1))T $DIR + opts=(${pq_limits[$u]}) + for ((j=0; j<${#opts[@]}; j++)); do + p=${opts[j]##*:} + o=${opts[j]%%:*} + # Set limit for all existing pools if + # no pool specified + if [ $p == $o ]; then + p=$(list_pool $FSNAME | sed "s/$FSNAME.//") + echo "No pool specified for $u, + set limit $o for all existing pools" + fi + for pool in $p; do + $LFS setquota -u $u -B $o --pool $pool $DIR || + error "setquota -u $u -B $o \ + --pool $pool failed" + done + done + $LFS quota -uv $u --pool $DIR + done +} + check_and_setup_lustre() { sanitize_parameters nfs_client_mode && return @@ -5542,6 +5601,9 @@ check_and_setup_lustre() { create_pools $FS_POOL $FS_POOL_NOSTS fi + if [[ -n "$POOLS_QUOTA_USERS_SET" ]]; then + set_pools_quota + fi if [ "$ONLY" == "setup" ]; then exit 0 fi -- 1.8.3.1