Whamcloud - gitweb
LU-3503 test: only create single directory by test_mkdir()
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index ff194e5..97b7aad 100644 (file)
@@ -491,6 +491,7 @@ load_modules_local() {
         grep -q crc16 $SYMLIST || { modprobe crc16 2>/dev/null || true; }
         grep -q -w jbd $SYMLIST || { modprobe jbd 2>/dev/null || true; }
         grep -q -w jbd2 $SYMLIST || { modprobe jbd2 2>/dev/null || true; }
+               load_module lfsck/lfsck
                [ "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
                if [[ $(node_fstypes $HOSTNAME) == *zfs* ]]; then
                        modprobe zfs
@@ -592,7 +593,7 @@ fs_log_size() {
        local size=0
        case $fstype in
                ldiskfs) size=50;; # largest seen is 44, leave some headroom
-               zfs)     size=256;;
+               zfs)     size=400;; # largest seen is 384
        esac
 
        echo -n $size
@@ -3461,19 +3462,10 @@ check_and_setup_lustre() {
 
        if [ $(lower $OSD_TRACK_DECLARES_LBUG) == 'yes' ] ; then
                local facets="$(get_facets OST),$(get_facets MDS),mgs"
-               local facet
-               local nodes
-               local node
-               for facet in ${facets//,/ }; do
-                       if [ $(facet_fstype $node) == "ldiskfs" ] ; then
-                               node=$(facet_host ${facet})
-                               nodes="$nodes $node"
-                       fi
-               done
+               local nodes="$(facets_hosts ${facets})"
                if [ -n "$nodes" ] ; then
-                       nodes=$(for i in $nodes; do echo $i; done | sort -u)
-                       do_nodes $(comma_list $nodes) "$LCTL set_param \
-                                osd-ldiskfs.track_declares_assert=1"
+                       do_nodes $nodes "$LCTL set_param \
+                                osd-ldiskfs.track_declares_assert=1 || true"
                fi
        fi
 
@@ -5938,19 +5930,18 @@ run_llverfs()
 
 #Remove objects from OST
 remove_ost_objects() {
-       shift
-       local ostdev=$1
-       local group=$2
-       shift 2
+       local facet=$1
+       local ostdev=$2
+       local group=$3
+       shift 3
        local objids="$@"
-       local facet=ost$((OSTIDX + 1))
        local mntpt=$(facet_mntpt $facet)
        local opts=$OST_MOUNT_OPTS
        local i
        local rc
 
        echo "removing objects from $ostdev on $facet: $objids"
-       if ! do_facet $facet test -b $ostdev; then
+       if ! test -b $ostdev; then
                opts=$(csa_add "$opts" -o loop)
        fi
        mount -t $(facet_fstype $facet) $opts $ostdev $mntpt ||
@@ -6237,41 +6228,28 @@ generate_logname() {
        echo "$TESTLOG_PREFIX.$TESTNAME.$logname.$(hostname -s).log"
 }
 
-# mkdir directory on different MDTs
+# make directory on different MDTs
 test_mkdir() {
        local option
        local parent
        local child
        local path
-       local dir
        local rc=0
 
-       if [ $# -eq 2 ]; then
-               option=$1
-               path=$2
-       else
-               path=$1
-       fi
-
-       child=${path##*/}
-       parent=${path%/*}
+       case $# in
+               1) path=$1;;
+               2) option=$1
+                  path=$2;;
+               *) error "Only creating single directory is supported";;
+       esac
 
-       if [ "$parent" == "$child" ]; then
-               parent=$(pwd)
-       fi
+       child=$(basename $path)
+       parent=$(dirname $path)
 
-       if [ "$option" == "-p" -a -d ${parent}/${child} ]; then
+       if [ "$option" == "-p" -a -d $parent/$child ]; then
                return $rc
        fi
 
-       # it needs to check whether there is further / in child
-       dir=$(echo $child | awk -F '/' '{print $2}')
-       if [ ! -z "$dir" ]; then
-               local subparent=$(echo $child | awk -F '/' '{ print $1 }')
-               parent=${parent}"/"${subparent}
-               child=$dir
-       fi
-
        if [ ! -d ${parent} ]; then
                if [ "$option" == "-p" ]; then
                        mkdir -p ${parent}
@@ -6281,19 +6259,18 @@ test_mkdir() {
        fi
 
        if [ $MDSCOUNT -le 1 ]; then
-               mkdir $option ${parent}/${child} || rc=$?
+               mkdir $option $parent/$child || rc=$?
        else
                local mdt_idx=$($LFS getstripe -M $parent)
+               local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
 
                if [ "$mdt_idx" -ne 0 ]; then
-                       mkdir $option ${parent}/${child} || rc=$?
-                       return $rc
+                       mkdir $option $parent/$child || rc=$?
+               else
+                       mdt_idx=$((test_num % MDSCOUNT))
+                       echo "mkdir $mdt_idx for $parent/$child"
+                       $LFS setdirstripe -i $mdt_idx $parent/$child || rc=$?
                fi
-
-               local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
-               local mdt_idx=$((test_num % MDSCOUNT))
-               echo "mkdir $mdt_idx for ${parent}/${child}"
-               $LFS setdirstripe -i $mdt_idx ${parent}/${child} || rc=$?
        fi
        return $rc
 }