From: Andreas Dilger Date: Wed, 7 Jan 2015 01:37:06 +0000 (-0800) Subject: LU-5759 tests: use lfs getstripe -M instead of get_mds_num X-Git-Tag: 2.6.93~74 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=9804f872d28315a7ddfe835138bb33e2206ffe52;ds=inline LU-5759 tests: use lfs getstripe -M instead of get_mds_num 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 Signed-off-by: Mikhail Pershin Change-Id: I35d2ad5d859190c0292d3cc09df23fec40165751 Reviewed-on: http://review.whamcloud.com/12363 Reviewed-by: Jian Yu Tested-by: Jian Yu Tested-by: Jenkins Tested-by: Maloo --- diff --git a/lustre/tests/replay-dual.sh b/lustre/tests/replay-dual.sh index c0d8c2b..b8e5094 100755 --- a/lustre/tests/replay-dual.sh +++ b/lustre/tests/replay-dual.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*- -# vim:shiftwidth=4:softtabstop=4:tabstop=4: set -e @@ -527,75 +525,76 @@ test_21a() { 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() { - [ -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" @@ -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) ]] || - { 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 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 8867c60..5accd1e 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -1464,34 +1464,33 @@ exhaust_precreations() { 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 MDT_INDEX=$(lfs df | grep "\[MDT:$((MDSIDX - 1))\]" | awk '{print $1}' | \ - sed -e 's/_UUID$//;s/^.*-//') # 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) - 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) - 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 - 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)) - 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 } @@ -4989,16 +4988,17 @@ test_57b() { 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" - 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 || \ @@ -5011,9 +5011,9 @@ test_57b() { 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 @@ -5026,9 +5026,9 @@ test_57b() { 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" @@ -8901,15 +8901,16 @@ som_mode_switch() { 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 @@ -8921,7 +8922,8 @@ test_132() { #1028, SOM 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 diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 6d52df9..13d02b9 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -370,7 +370,7 @@ module_loaded () { # 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_ is set, then its value # will be used as the arguments. Otherwise arguments will be obtained from @@ -5666,27 +5666,6 @@ fi; 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 \