Whamcloud - gitweb
LU-1227 tests: mds-survey.sh should check ost's space
authorMinh Diep <mdiep@whamcloud.com>
Fri, 23 Mar 2012 00:40:30 +0000 (17:40 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 7 Apr 2012 01:31:47 +0000 (21:31 -0400)
When we run the test with stripe_count=1, we need to
reduce the file_count to be the min of both mdt's inode
and ost's inode

Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Change-Id: I04a558c277ebf9a1e1526a7d507faab8b66e740c
Reviewed-on: http://review.whamcloud.com/2372
Tested-by: Hudson
Reviewed-by: Yu Jian <yujian@whamcloud.com>
Reviewed-by: wangdi <di.wang@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/mds-survey.sh

index 9d98c69..26987c2 100644 (file)
@@ -11,7 +11,7 @@ init_logging
 build_test_filter
 check_and_setup_lustre
 
 build_test_filter
 check_and_setup_lustre
 
-file_count=${file_count:-100000}
+file_count=${file_count:-150000}
 dir_count=${dir_count:-4}
 thrhi=${thrhi:-8}
 thrlo=${thrlo:-1}
 dir_count=${dir_count:-4}
 thrhi=${thrhi:-8}
 thrlo=${thrlo:-1}
@@ -26,24 +26,37 @@ if [ -z ${MDSSURVEY} ]; then
     skip_env "mds-survey not found" && exit
 fi
 
     skip_env "mds-survey not found" && exit
 fi
 
-# check for available inode, reduce to fit
-inode_per_thr=$((dir_count * file_count))
-require_inode=$((inode_per_thr * thrhi * 11/10))
-avail_inode=$($LFS df -i $MOUNT | grep "filesystem summary:"  | \
-    awk '{print $5}')
-
-while [ $require_inode -ge $avail_inode  ]; do
-    echo "Require $require_inode inode to run, only have $avail_inode"
-    # reduce 20%
-    file_count=$((file_count * 8 / 10))
-    inode_per_thr=$((dir_count * file_count))
-    require_inode=$((inode_per_thr * thrhi * 11 / 10))
-done
-
-if [ $require_inode -eq 0 ]; then
-    skip_env "Not enough inode to run" && exit
-fi
+adjust_inode() {
+    local require_inode=0
+    local avail_mdt_inode=0
+    local avail_ost_inode=0
+
+    require_inode=$((file_count * thrhi))
+    # get available inode for mdt
+    avail_mdt_inode=$($LFS df -i $MOUNT | grep "filesystem summary:"  | \
+        awk '{print $5}')
+    avail_mdt_inode=$((avail_mdt_inode * 9 / 10))
+
+    # get available inode for ost
+    for i in $($LFS df -i | grep ${FSNAME}-OST | awk '{print $4}'); do
+        avail_ost_inode=$((avail_ost_inode + i))
+    done
+    avail_ost_inode=$((avail_ost_inode * 9 / 10))
+
+    ((require_inode > avail_mdt_inode)) && require_inode=$avail_mdt_inode
+    ((require_inode > avail_ost_inode)) && require_inode=$avail_ost_inode
+
+    if ((require_inode == 0)); then
+        error "Fail to get the inode count"
+    fi
+    # convert it back to per thread inode
+    require_inode=$((require_inode / thrhi))
+
+    echo $require_inode
+}
+
 
 
+file_count=$(adjust_inode)
 ost_count=$($LCTL dl | grep -c osc)
 
 # first unmount all the lustre clients
 ost_count=$($LCTL dl | grep -c osc)
 
 # first unmount all the lustre clients
@@ -60,19 +73,20 @@ mds_survey_run() {
     local layer=${1:-mdd}
     local stripe_count=${2:-0}
     local mds=$(facet_host $SINGLEMDS)
     local layer=${1:-mdd}
     local stripe_count=${2:-0}
     local mds=$(facet_host $SINGLEMDS)
+    local rc=0
 
     rm -f ${TMP}/mds_survey*
 
     local target=$(get_target)
 
     rm -f ${TMP}/mds_survey*
 
     local target=$(get_target)
-    local cmd1="file_count=$file_count thrlo=$thrlo thrhi=$thrhi"
-    local cmd2="dir_count=$dir_count layer=$layer stripe_count=$stripe_count"
-    local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
-    local cmd="$cmd1 $cmd2 $cmd3"
+    local cmd="file_count=$file_count thrlo=$thrlo thrhi=$thrhi"
+    local cmd+=" dir_count=$dir_count layer=$layer stripe_count=$stripe_count"
+    local cmd+=" rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
 
     echo + $cmd
 
     echo + $cmd
-    eval $cmd || error "mds-survey failed"
+    eval $cmd || rc=$?
     cat ${TMP}/mds_survey*
     rm -f ${TMP}/mds_survey*
     cat ${TMP}/mds_survey*
     rm -f ${TMP}/mds_survey*
+    ((rc == 0)) || error "mds-survey failed"
 }
 
 test_1() {
 }
 
 test_1() {