Whamcloud - gitweb
LU-5759 tests: use lfs getstripe -M instead of get_mds_num 63/12363/14
authorAndreas Dilger <andreas.dilger@intel.com>
Wed, 7 Jan 2015 01:37:06 +0000 (17:37 -0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 8 Jan 2015 05:16:42 +0000 (05:16 +0000)
The get_mds_num() helper function returned the MDS facet number,
but now that can be done via "lfs getdirstripe -M".

Remove this function and fix the few callers to use
"lfs getstripe -M" and create test directory with -c1
flag to prevent directory striping.

Fix some coding style issues in the affected functions.

Test-Parameters: alwaysuploadlogs \
envdefinitions=SLOW=yes,ENABLE_QUOTA=yes \
mdtfilesystemtype=ldiskfs mdsfilesystemtype=ldiskfs \
ostfilesystemtype=ldiskfs mdtcount=1 testlist=replay-dual

Test-Parameters: alwaysuploadlogs \
envdefinitions=SLOW=yes,ENABLE_QUOTA=yes \
mdtfilesystemtype=ldiskfs mdsfilesystemtype=ldiskfs \
ostfilesystemtype=ldiskfs mdtcount=1 testlist=sanity

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Mikhail Pershin <mike.pershin@intel.com>
Change-Id: I35d2ad5d859190c0292d3cc09df23fec40165751
Reviewed-on: http://review.whamcloud.com/12363
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Jian Yu <jian.yu@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/tests/replay-dual.sh
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index c0d8c2b..b8e5094 100755 (executable)
@@ -1,6 +1,4 @@
 #!/bin/bash
 #!/bin/bash
-# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
-# vim:shiftwidth=4:softtabstop=4:tabstop=4:
 
 set -e
 
 
 set -e
 
@@ -527,75 +525,76 @@ test_21a() {
 run_test 21a "commit on sharing"
 
 test_21b_sub () {
 run_test 21a "commit on sharing"
 
 test_21b_sub () {
-    local mds=$1 
-    do_node $CLIENT1 rm -f $MOUNT1/$tfile-*
+       local mds=$1
+       do_node $CLIENT1 rm -f $MOUNT1/$tfile-*
 
 
-    do_facet $mds sync
-    do_node $CLIENT1 touch  $MOUNT1/$tfile-1
-    do_node $CLIENT2 mv  $MOUNT1/$tfile-1 $MOUNT1/$tfile-2
-    do_node $CLIENT1 mv  $MOUNT1/$tfile-2 $MOUNT1/$tfile-3
+       do_facet $mds sync
+       do_node $CLIENT1 touch $MOUNT1/$tfile-1
+       do_node $CLIENT2 mv $MOUNT1/$tfile-1 $MOUNT1/$tfile-2
+       do_node $CLIENT1 mv $MOUNT1/$tfile-2 $MOUNT1/$tfile-3
 
 
-    replay_barrier_nosync $mds
-    shutdown_client $CLIENT2 $MOUNT1
+       replay_barrier_nosync $mds
+       shutdown_client $CLIENT2 $MOUNT1
 
 
-    facet_failover $mds
+       facet_failover $mds
 
 
-    # were renames replayed?
-    local rc=0
-    echo UNLINK $MOUNT1/$tfile-3 
-    do_node $CLIENT1 unlink  $MOUNT1/$tfile-3 || \
-        { echo "unlink $tfile-3 fail!" && rc=1; }
+       # were renames replayed?
+       local rc=0
+       echo UNLINK $MOUNT1/$tfile-3
+       do_node $CLIENT1 unlink  $MOUNT1/$tfile-3 ||
+               { echo "unlink $tfile-3 fail!" && rc=1; }
 
 
-    boot_node $CLIENT2
-    zconf_mount_clients $CLIENT2 $MOUNT1 || error "mount $CLIENT2 $MOUNT1 fail" 
+       boot_node $CLIENT2
+       zconf_mount_clients $CLIENT2 $MOUNT1 ||
+               error "mount $CLIENT2 $MOUNT1 fail"
 
 
-    return $rc
+       return $rc
 }
 
 test_21b() {
 }
 
 test_21b() {
-    [ -z "$CLIENTS" ] && skip "Need two or more clients." && return
-    [ $CLIENTCOUNT -lt 2 ] && \
-        { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
+       [ -z "$CLIENTS" ] && skip "Need two or more clients" && return
+       [ $CLIENTCOUNT -lt 2 ] &&
+               { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
 
 
-    if [ "$FAILURE_MODE" = "HARD" ] &&  mixed_mdt_devs; then
-        skip "Several mdt services on one mds node are used with FAILURE_MODE=$FAILURE_MODE. "
-        return 0
-    fi
+       if [ "$FAILURE_MODE" = "HARD" ] && mixed_mdt_devs; then
+               skip "Several MDTs on one MDS with FAILURE_MODE=$FAILURE_MODE"
+               return 0
+       fi
 
 
+       zconf_umount_clients $CLIENTS $MOUNT2
+       zconf_mount_clients $CLIENTS $MOUNT1
 
 
-    zconf_umount_clients $CLIENTS $MOUNT2
-    zconf_mount_clients $CLIENTS $MOUNT1
+       local param_file=$TMP/$tfile-params
 
 
-    local param_file=$TMP/$tfile-params
+       local mdtidx=$($LFS getstripe -M $MOUNT1)
+       local facet=mds$((mdtidx + 1))
 
 
-    local num=$(get_mds_dir $MOUNT1)
+       save_lustre_params $facet "mdt.*.commit_on_sharing" > $param_file
 
 
-       save_lustre_params mds$num "mdt.*.commit_on_sharing" > $param_file
+       # COS enabled
+       local COS=1
+       do_facet $facet lctl set_param mdt.*.commit_on_sharing=$COS
 
 
-    # COS enabled
-    local COS=1
-    do_facet mds$num lctl set_param mdt.*.commit_on_sharing=$COS
+       test_21b_sub $facet || error "Not all renames are replayed. COS=$COS"
 
 
-    test_21b_sub mds$num || error "Not all renames are replayed. COS=$COS"
+       # COS disabled (should fail)
+       COS=0
+       do_facet $facet lctl set_param mdt.*.commit_on_sharing=$COS
 
 
-    # COS disabled (should fail)
-    COS=0
-    do_facet mds$num lctl set_param mdt.*.commit_on_sharing=$COS
-
-    # there is still a window when transactions may be written to disk before
-    # the mds device is set R/O. To avoid such a rare test failure, the check
-    # is repeated several times.
-    local n_attempts=1
-    while true; do
-    test_21b_sub mds$num || break;
-    let n_attempts=n_attempts+1
-    [ $n_attempts -gt 3 ] &&
-        error "The test cannot check whether COS works or not: all renames are replied w/o COS"
-    done
-    zconf_mount_clients $CLIENTS $MOUNT2
-    restore_lustre_params < $param_file
-    rm -f $param_file
-    return 0
+       # there is still a window when transactions may be written to disk
+       # before the mds device is set R/O. To avoid such a rare test failure,
+       # the check is repeated several times.
+       local n_attempts=1
+       while true; do
+               test_21b_sub $facet || break
+               n_attempts=$((n_attempts + 1))
+               [ $n_attempts -gt 3 ] &&
+                       error "can't check if COS works: rename replied w/o COS"
+       done
+       zconf_mount_clients $CLIENTS $MOUNT2
+       restore_lustre_params < $param_file
+       rm -f $param_file
+       return 0
 }
 run_test 21b "commit on sharing, two clients"
 
 }
 run_test 21b "commit on sharing, two clients"
 
@@ -869,7 +868,7 @@ run_test 23d "c1 rmdir d1, M0 drop update reply and fail M0/M1, c2 mkdir d1"
 
 test_24 () {
        [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.5.2) ]] ||
 
 test_24 () {
        [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.5.2) ]] ||
-                { skip "Need MDS version newer than 2.5.2"; return 0; }
+               { skip "Need MDS version newer than 2.5.2"; return 0; }
 
        touch $MOUNT/$tfile
        stat $MOUNT/$tfile >&/dev/null
 
        touch $MOUNT/$tfile
        stat $MOUNT/$tfile >&/dev/null
index 8867c60..5accd1e 100644 (file)
@@ -1464,34 +1464,33 @@ exhaust_precreations() {
        local OSTIDX=$1
        local FAILLOC=$2
        local FAILIDX=${3:-$OSTIDX}
        local OSTIDX=$1
        local FAILLOC=$2
        local FAILIDX=${3:-$OSTIDX}
+       local ofacet=ost$((OSTIDX + 1))
 
 
-       test_mkdir -p $DIR/$tdir
-       local MDSIDX=$(get_mds_dir "$DIR/$tdir")
-       echo OSTIDX=$OSTIDX MDSIDX=$MDSIDX
+       test_mkdir -p -c1 $DIR/$tdir
+       local mdtidx=$($LFS getstripe -M $DIR/$tdir)
+       local mfacet=mds$((mdtidx + 1))
+       echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
 
        local OST=$(ostname_from_index $OSTIDX)
 
        local OST=$(ostname_from_index $OSTIDX)
-       local MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \
-                         sed -e 's/_UUID$//;s/^.*-//')
 
        # on the mdt's osc
 
        # on the mdt's osc
-       local mdtosc_proc1=$(get_mdtosc_proc_path mds${MDSIDX} $OST)
-       local last_id=$(do_facet mds${MDSIDX} lctl get_param -n \
+       local mdtosc_proc1=$(get_mdtosc_proc_path $mfacet $OST)
+       local last_id=$(do_facet $mfacet lctl get_param -n \
                        osc.$mdtosc_proc1.prealloc_last_id)
                        osc.$mdtosc_proc1.prealloc_last_id)
-       local next_id=$(do_facet mds${MDSIDX} lctl get_param -n \
+       local next_id=$(do_facet $mfacet lctl get_param -n \
                        osc.$mdtosc_proc1.prealloc_next_id)
 
                        osc.$mdtosc_proc1.prealloc_next_id)
 
-       local mdtosc_proc2=$(get_mdtosc_proc_path mds${MDSIDX})
-       do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
+       local mdtosc_proc2=$(get_mdtosc_proc_path $mfacet)
+       do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
 
        test_mkdir -p $DIR/$tdir/${OST}
        $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
 #define OBD_FAIL_OST_ENOSPC              0x215
 
        test_mkdir -p $DIR/$tdir/${OST}
        $SETSTRIPE -i $OSTIDX -c 1 $DIR/$tdir/${OST}
 #define OBD_FAIL_OST_ENOSPC              0x215
-       do_facet ost$((OSTIDX + 1)) lctl set_param fail_val=$FAILIDX
-       do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=0x215
+       do_facet $ofacet lctl set_param fail_val=$FAILIDX fail_loc=0x215
        echo "Creating to objid $last_id on ost $OST..."
        createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
        echo "Creating to objid $last_id on ost $OST..."
        createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
-       do_facet mds${MDSIDX} lctl get_param osc.$mdtosc_proc2.prealloc*
-       do_facet ost$((OSTIDX + 1)) lctl set_param fail_loc=$FAILLOC
+       do_facet $mfacet lctl get_param osc.$mdtosc_proc2.prealloc*
+       do_facet $ofacet lctl set_param fail_loc=$FAILLOC
        sleep_maxage
 }
 
        sleep_maxage
 }
 
@@ -4989,16 +4988,17 @@ test_57b() {
        fi
 
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
        fi
 
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       local dir=$DIR/d57b
+       local dir=$DIR/$tdir
 
        local FILECOUNT=100
        local FILE1=$dir/f1
        local FILEN=$dir/f$FILECOUNT
 
        rm -rf $dir || error "removing $dir"
 
        local FILECOUNT=100
        local FILE1=$dir/f1
        local FILEN=$dir/f$FILECOUNT
 
        rm -rf $dir || error "removing $dir"
-       test_mkdir -p $dir || error "creating $dir"
-       local num=$(get_mds_dir $dir)
-       local mymds=mds$num
+       test_mkdir -p -c1 $dir || error "creating $dir"
+       local mdtidx=$($LFS getstripe -M $dir)
+       local mdtname=MDT$(printf %04x $mdtidx)
+       local facet=mds$((mdtidx + 1))
 
        echo "mcreating $FILECOUNT files"
        createmany -m $dir/f 1 $FILECOUNT || \
 
        echo "mcreating $FILECOUNT files"
        createmany -m $dir/f 1 $FILECOUNT || \
@@ -5011,9 +5011,9 @@ test_57b() {
        sync
        sleep 1
        df $dir  #make sure we get new statfs data
        sync
        sleep 1
        df $dir  #make sure we get new statfs data
-       local MDSFREE=$(do_facet $mymds \
-               lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
-       local MDCFREE=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
+       local MDSFREE=$(do_facet $facet \
+               lctl get_param -n osd*.*$mdtname.kbytesfree)
+       local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
        echo "opening files to create objects/EAs"
        local FILE
        for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
        echo "opening files to create objects/EAs"
        local FILE
        for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
@@ -5026,9 +5026,9 @@ test_57b() {
 
        sleep 1  #make sure we get new statfs data
        df $dir
 
        sleep 1  #make sure we get new statfs data
        df $dir
-       local MDSFREE2=$(do_facet $mymds \
-               lctl get_param -n osd*.*MDT000$((num -1)).kbytesfree)
-       local MDCFREE2=$(lctl get_param -n mdc.*MDT000$((num -1))-mdc-*.kbytesfree)
+       local MDSFREE2=$(do_facet $facet \
+               lctl get_param -n osd*.*$mdtname.kbytesfree)
+       local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
        if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
                if [ "$MDSFREE" != "$MDSFREE2" ]; then
                        error "MDC before $MDCFREE != after $MDCFREE2"
        if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
                if [ "$MDSFREE" != "$MDSFREE2" ]; then
                        error "MDC before $MDCFREE != after $MDCFREE2"
@@ -8901,15 +8901,16 @@ som_mode_switch() {
 
 test_132() { #1028, SOM
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
 
 test_132() { #1028, SOM
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        remote_mds_nodsh && skip "remote MDS with nodsh" && return
-        local num=$(get_mds_dir $DIR)
-        local mymds=mds${num}
-        local MOUNT_OPTS_SAVE=$MOUNT_OPTS
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       local mdtidx=$($LFS getstripe -M $DIR)
+       local facet=mds$((mdtidx + 1))
 
 
-        dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
-        cancel_lru_locks osc
+       local MOUNTOPT_SAVE=$MOUNTOPT
 
 
-        som1=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
+       dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
+       cancel_lru_locks osc
+       som1=$(do_facet $facet "$LCTL get_param mdt.*.som" |
+              awk -F= ' {print $2}' | head -n 1)
 
         gl1=$(get_ost_param "ldlm_glimpse_enqueue")
         stat $DIR/$tfile >/dev/null
 
         gl1=$(get_ost_param "ldlm_glimpse_enqueue")
         stat $DIR/$tfile >/dev/null
@@ -8921,7 +8922,8 @@ test_132() { #1028, SOM
         dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
         cancel_lru_locks osc
 
         dd if=/dev/zero of=$DIR/$tfile count=1 2>/dev/null
         cancel_lru_locks osc
 
-        som2=$(do_facet $mymds "$LCTL get_param -n mdt.*.som" | head -n 1)
+       som2=$(do_facet $facet "$LCTL get_param mdt.*.som" |
+              awk -F= ' {print $2}' | head -n 1)
         if [ $som1 == $som2 ]; then
             error "som is still "$som2
             if [ x$som2 = x"enabled" ]; then
         if [ $som1 == $som2 ]; then
             error "som is still "$som2
             if [ x$som2 = x"enabled" ]; then
index 6d52df9..13d02b9 100755 (executable)
@@ -370,7 +370,7 @@ module_loaded () {
 
 # Load a module on the system where this is running.
 #
 
 # Load a module on the system where this is running.
 #
-# Synopsis: load_module module_name [module arguments for insmod/modprobe]
+# usage: load_module module_name [module arguments for insmod/modprobe]
 #
 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
 # will be used as the arguments.  Otherwise arguments will be obtained from
 #
 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
 # will be used as the arguments.  Otherwise arguments will be obtained from
@@ -5666,27 +5666,6 @@ fi;
 exit \\\$rc"
 }
 
 exit \\\$rc"
 }
 
-# CMD: determine mds index where directory inode presents
-get_mds_dir() {
-    local dir=$1
-    local SEQ
-
-    SEQ=$(lfs path2fid $dir | tr '[:]' ' '|cut -f2 -d ' ')
-    if [ "$SEQ" == "" ]; then
-       error "can't get sequence for $dir"
-       return 1
-    fi
-    export SEQ
-
-    do_facet mds1 "cat /proc/fs/lustre/fld/srv-*-MDT0000/fldb" | \
-       tr '[)]:-' ' ' |                                \
-       while read SS EE IDX TYP; do                    \
-               if let "SEQ >= SS && SEQ < EE"; then    \
-                       echo $IDX;                      \
-               fi;                                     \
-       done
-}
-
 mdsrate_cleanup () {
        if [ -d $4 ]; then
                mpi_run ${MACHINEFILE_OPTION} $2 -np $1 ${MDSRATE} --unlink \
 mdsrate_cleanup () {
        if [ -d $4 ]; then
                mpi_run ${MACHINEFILE_OPTION} $2 -np $1 ${MDSRATE} --unlink \