X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-gns.sh;h=e03b0dfdd8f21acae3f0157e9b4fbc7ee249e6a5;hb=bc1e9a6998086557e1006918eb0326b77d0aa0dc;hp=8c0318a0716944879fae39779a876056fdfbb663;hpb=8acfc41890ab8781df7c504362b28d8eaedf7f53;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-gns.sh b/lustre/tests/sanity-gns.sh index 8c0318a..e03b0df 100644 --- a/lustre/tests/sanity-gns.sh +++ b/lustre/tests/sanity-gns.sh @@ -97,7 +97,7 @@ check_kernel_version() { } run_one() { - if ! mount | grep -q $DIR; then + if ! cat /proc/mounts | grep -q $DIR; then $START fi echo $PTLDEBUG >/proc/sys/portals/debug @@ -189,7 +189,7 @@ rm -rf $DIR/[Rdfs][1-9]* build_test_filter echo preparing for tests involving mounts -EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP} +EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP} touch $EXT2_DEV mke2fs -j -F $EXT2_DEV 8000 >/dev/null 2>&1 @@ -245,11 +245,11 @@ setup_upcall() { local LOG=$3 local BG=$4 - test "x$BG" = "xBACKGROUND" && + test "x$BG" = "xBG" && BG="&" || BG="" - test "x$MODE" = "xDEADLOCK" && - INJECTION="touch \$MNTPATH/file" +# test "x$MODE" = "xDEADLOCK" && +# INJECTION="touch \$MNTPATH/file" cat > $UPCALL <<- EOF #!/bin/sh @@ -286,8 +286,24 @@ show_log() { } } +check_mnt() +{ + local OBJECT=$1 + local mnt="" + local p="" + + mnt="`cat /proc/mounts | grep $OBJECT | awk '{print \$2}'`" + test -z "$mnt" && return 1 + + for p in $mnt; do + test "x$p" = "x$OBJECT" || return 1 + done + + return 0 +} + check_gns() { - local LOG="/tmp/gns-log" + local LOG="$TMP/gns-log" local UPCALL_PATH="" local UPCALL=$1 @@ -297,9 +313,10 @@ check_gns() { local TICK=$5 local MODE=$6 local BG=$7 + local OP=$8 rm -fr $LOG >/dev/null 2>&1 - UPCALL_PATH="/tmp/gns-upcall-$UPCALL.sh" + UPCALL_PATH="$TMP/gns-upcall-$UPCALL.sh" echo "generating upcall $UPCALL_PATH" setup_upcall $UPCALL_PATH $UPCALL $LOG $BG || return $rc @@ -311,18 +328,40 @@ check_gns() { echo "$UPCALL_PATH" > /proc/fs/lustre/llite/fs0/gns_upcall || return $? echo "upcall: $(cat /proc/fs/lustre/llite/fs0/gns_upcall)" + echo -n "mount on $OP: " + + local OLD_PWD=$(pwd) + case "$MODE" in GENERIC) - echo -n "mount on open $OBJECT1/test_file1 (generic): " - echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 || return $? + case "$OP" in + OPEN) + echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 + ;; + CHDIR) + cd $OBJECT1 || return $? + ;; + *) + echo "invalid testing operation $OP" + return 1 + esac ;; CONCUR1) local i=1 local nr=20 - echo -n "mount on open $OBJECT1/test_file1 ($nr threads): " for ((;i<=$nr;i++)); do - echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 & + case "$OP" in + OPEN) + echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 & + ;; + CHDIR) + cd $OBJECT1 >/dev/null 2>&1 & + ;; + *) + echo "invalid testing operation $OP" + return 1 + esac done wait @@ -337,10 +376,19 @@ check_gns() { echo "not defined object2 for concurrent2 testing" return 1 } - echo -n "mount on open $OBJECT1/test_file1: " - echo -n "mount on open $OBJECT2/test_file1: " - echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 & - echo -n "test data" > $OBJECT2/test_file1 >/dev/null 2>&1 & + case "$OP" in + OPEN) + echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 & + echo -n "test data" > $OBJECT2/test_file1 >/dev/null 2>&1 & + ;; + CHDIR) + cd $OBJECT1 >/dev/null 2>&1 & + cd $OBJECT2 >/dev/null 2>&1 & + ;; + *) + echo "invalid testing operation $OP" + return 1 + esac wait @@ -350,15 +398,25 @@ check_gns() { return $RETVAL ;; CONCUR3) - echo -n "mount on open $OBJECT1/test_file1: " - local i=1 local nr=20 for ((;i<$nr;i++)); do - touch $OBJECT1/file$i & - echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 & - mkdir $OBJECT1/dir$i & + case "$OP" in + OPEN) + touch $OBJECT1/file$i & + echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 & + mkdir $OBJECT1/dir$i & + ;; + CHDIR) + touch $OBJECT1/file$i & + cd $OBJECT1 >/dev/null 2>&1 & + mkdir $OBJECT1/dir$i & + ;; + *) + echo "invalid testing operation $OP" + return 1 + esac done wait @@ -372,18 +430,17 @@ check_gns() { echo "invalid testing mode $MODE" return 1 esac + + test "x$OP" = "xCHDIR" && cd $OLD_PWD - local ENTRY1="`basename $OBJECT1`" - local ENTRY2="`basename $OBJECT2`" - - cat /proc/mounts | grep -q "$ENTRY1" || { + check_mnt $OBJECT1 || { echo "fail" show_log $LOG return 1 } if test "x$MODE" = "xCONCUR2"; then - cat /proc/mounts | grep -q "$ENTRY2" || { + check_mnt $OBJECT2 || { echo "fail" show_log $LOG return 1 @@ -396,14 +453,14 @@ check_gns() { let sleep_time+=$TICK*2 echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): " sleep $sleep_time - - cat /proc/mounts | grep -q "$ENTRY1" && { + + check_mnt $OBJECT1 && { echo "failed" return 2 } if test "x$MODE" = "xCONCUR2"; then - cat /proc/mounts | grep -q "$ENTRY2" && { + check_mnt $OBJECT2 && { echo "failed" return 2 } @@ -418,7 +475,6 @@ setup_object() { local OBJPATH=$1 local OBJECT=$2 local CONTENT=$3 - local EXTRA_OPT=$4 mkdir -p $OBJPATH || return $? echo -n $CONTENT > $OBJPATH/$OBJECT || return $? @@ -428,15 +484,14 @@ setup_object() { echo "" echo "=================================================================" - chmod u+s $OBJPATH $EXTRA_OPT + chmod u+s $OBJPATH return $? } cleanup_object() { local OBJPATH=$1 - local EXTRA_OPT=$2 - chmod u-s $OBJPATH $EXTRA_OPT + chmod u-s $OBJPATH umount $OBJPATH >/dev/null 2>&1 rm -fr $OBJPATH >/dev/null 2>&1 } @@ -472,7 +527,7 @@ disable_gns() test_1a() { local LOOP_DEV=$(find_free_loop 2>/dev/null) - local LOOP_FILE="/tmp/gns_loop_1a" + local LOOP_FILE="$TMP/gns_loop_1a" local OBJECT=".mntinfo" local TIMOUT=5 local TICK=1 @@ -496,8 +551,24 @@ test_1a() { echo "" echo "testing GNS with GENERIC upcall 3 times on the row" + + echo "" + echo "testing OPEN operation" + for ((i=0;i<3;i++)); do - check_gns GENERIC $DIR/gns_test_1a $DIR/gns_test_1a $TIMOUT $TICK GENERIC || { + check_gns GENERIC $DIR/gns_test_1a $DIR/gns_test_1a $TIMOUT $TICK GENERIC FG OPEN || { + disable_gns + cleanup_object $DIR/gns_test_1a + cleanup_loop $LOOP_DEV $LOOP_FILE + error + } + done + + echo "" + echo "testing CHDIR operation" + + for ((i=0;i<3;i++)); do + check_gns GENERIC $DIR/gns_test_1a $DIR/gns_test_1a $TIMOUT $TICK GENERIC FG CHDIR || { disable_gns cleanup_object $DIR/gns_test_1a cleanup_loop $LOOP_DEV $LOOP_FILE @@ -509,13 +580,14 @@ test_1a() { cleanup_object $DIR/gns_test_1a cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 } run_test 1a " general GNS test - mount/umount (GENERIC) ================" test_1b() { local LOOP_DEV=$(find_free_loop 2>/dev/null) - local LOOP_FILE="/tmp/gns_loop_1b" + local LOOP_FILE="$TMP/gns_loop_1b" local OBJECT=".mntinfo" local TIMOUT=5 local TICK=1 @@ -539,26 +611,23 @@ test_1b() { echo "" echo "testing GNS with DEADLOCK upcall 3 times on the row" + for ((i=0;i<3;i++)); do - check_gns DEADLOCK $DIR/gns_test_1b $DIR/gns_test_1b $TIMOUT $TICK GENERIC || { - disable_gns - cleanup_object $DIR/gns_test_1b - cleanup_loop $LOOP_DEV $LOOP_FILE - error - } + check_gns DEADLOCK $DIR/gns_test_1b $DIR/gns_test_1b $TIMOUT $TICK GENERIC FG OPEN done disable_gns cleanup_object $DIR/gns_test_1b cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 } run_test 1b " general GNS test - mount/umount (DEADLOCK) ===============" test_1c() { local LOOP_DEV=$(find_free_loop 2>/dev/null) - local LOOP_FILE="/tmp/gns_loop_1c" + local LOOP_FILE="$TMP/gns_loop_1c" local OBJECT=".mntinfo" local TIMOUT=5 local TICK=1 @@ -581,33 +650,35 @@ test_1c() { enable_gns echo "" - echo "testing GNS with DEADLOCK upcall 4 times on the row" + echo "testing GNS with GENERIC/DEADLOCK upcall 4 times on the row in GENERIC mode" local i=0 for ((;i<4;i++)); do - local MODE="GENERIC" - - test $(($i%2)) -eq 1 && MODE="DEADLOCK" - - check_gns $MODE $DIR/gns_test_1c $DIR/gns_test_1c $TIMOUT $TICK GENERIC || { - disable_gns - cleanup_object $DIR/gns_test_1c - cleanup_loop $LOOP_DEV $LOOP_FILE - error + test $(($i%2)) -eq 1 && { + check_gns DEADLOCK $DIR/gns_test_1c $DIR/gns_test_1c $TIMOUT $TICK GENERIC FG OPEN + } || { + check_gns GENERIC $DIR/gns_test_1c $DIR/gns_test_1c $TIMOUT $TICK GENERIC FG OPEN || { + disable_gns + cleanup_object $DIR/gns_test_1c + cleanup_loop $LOOP_DEV $LOOP_FILE + error "generic upcall does not work!" + } } + done disable_gns cleanup_object $DIR/gns_test_1c cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 } run_test 1c " general GNS test - mount/umount (GENERIC/DEADLOCK) ========" test_1d() { local LOOP_DEV=$(find_free_loop 2>/dev/null) - local LOOP_FILE="/tmp/gns_loop_1d" + local LOOP_FILE="$TMP/gns_loop_1d" local OBJECT=".mntinfo" local TIMOUT=5 local TICK=1 @@ -630,15 +701,11 @@ test_1d() { enable_gns echo "" - echo "testing GNS with GENERIC/DEADLOCK upcall 4 times on the row in CONCUR1 mode" + echo "testing GNS with GENERIC upcall 4 times on the row in CONCUR1 mode" local i=0 for ((;i<4;i++)); do - local MODE="GENERIC" - - test $(($i%2)) -eq 1 && MODE="DEADLOCK" - - check_gns $MODE $DIR/gns_test_1d $DIR/gns_test_1d $TIMOUT $TICK CONCUR1 || { + check_gns GENERIC $DIR/gns_test_1d $DIR/gns_test_1d $TIMOUT $TICK CONCUR1 FG OPEN || { disable_gns cleanup_object $DIR/gns_test_1d cleanup_loop $LOOP_DEV $LOOP_FILE @@ -650,13 +717,14 @@ test_1d() { cleanup_object $DIR/gns_test_1d cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 } run_test 1d " general GNS test - concurrent mount =======================" test_1e() { local LOOP_DEV=$(find_free_loop 2>/dev/null) - local LOOP_FILE="/tmp/gns_loop_1e" + local LOOP_FILE="$TMP/gns_loop_1e" local OBJECT=".mntinfo" local TIMOUT=5 local TICK=1 @@ -683,7 +751,8 @@ test_1e() { echo "" echo "testing GNS with GENERIC upcall in CONCUR2 mode" - check_gns GENERIC $DIR/gns_test_1e1 $DIR/gns_test_1e2 $TIMOUT $TICK CONCUR2 || { + + check_gns GENERIC $DIR/gns_test_1e1 $DIR/gns_test_1e2 $TIMOUT $TICK CONCUR2 FG OPEN || { disable_gns cleanup_object $DIR/gns_test_1e1 cleanup_object $DIR/gns_test_1e2 @@ -696,6 +765,7 @@ test_1e() { cleanup_object $DIR/gns_test_1e1 cleanup_object $DIR/gns_test_1e2 cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 } run_test 1e " general GNS test - concurrent mount of 2 GNS mounts =======" @@ -719,7 +789,8 @@ test_2a() { echo "" echo "testing GNS with GENERIC upcall" - check_gns GENERIC $DIR/gns_test_2a $DIR/gns_test_2a $TIMOUT $TICK GENERIC && { + + check_gns GENERIC $DIR/gns_test_2a $DIR/gns_test_2a $TIMOUT $TICK GENERIC FG OPEN && { disable_gns chmod u-s $DIR/gns_test_2a rm -fr $DIR/gns_test_2a @@ -729,6 +800,7 @@ test_2a() { disable_gns chmod u-s $DIR/gns_test_2a rm -fr $DIR/gns_test_2a + return 0 } run_test 2a " odd conditions (mount object is symlink) =============" @@ -751,7 +823,8 @@ test_2b() { echo "" echo "testing GNS with GENERIC upcall" - check_gns GENERIC $DIR/gns_test_2b $DIR/gns_test_2b $TIMOUT $TICK GENERIC && { + + check_gns GENERIC $DIR/gns_test_2b $DIR/gns_test_2b $TIMOUT $TICK GENERIC FG OPEN && { disable_gns chmod u-s $DIR/gns_test_2b rm -fr $DIR/gns_test_2b @@ -761,6 +834,7 @@ test_2b() { disable_gns chmod u-s $DIR/gns_test_2b rm -fr $DIR/gns_test_2b + return 0 } run_test 2b " odd conditions (mount object is directory) ===========" @@ -783,7 +857,8 @@ test_2c() { echo "" echo "testing GNS with GENERIC upcall" - check_gns GENERIC $DIR/gns_test_2c $DIR/gns_test_2c $TIMOUT $TICK GENERIC && { + + check_gns GENERIC $DIR/gns_test_2c $DIR/gns_test_2c $TIMOUT $TICK GENERIC FG OPEN && { disable_gns chmod u-s -R $DIR/gns_test_2c rm -fr $DIR/gns_test_2c @@ -791,8 +866,9 @@ test_2c() { } disable_gns - chmod u-s $DIR/gns_test_2c + chmod u-s -R $DIR/gns_test_2c rm -fr $DIR/gns_test_2c + return 0 } run_test 2c " odd conditions (mount object is recursive dir) =======" @@ -815,7 +891,8 @@ test_2d() { echo "" echo "testing GNS with GENERIC upcall" - check_gns GENERIC $DIR/gns_test_2d $DIR/gns_test_2d $TIMOUT $TICK GENERIC && { + + check_gns GENERIC $DIR/gns_test_2d $DIR/gns_test_2d $TIMOUT $TICK GENERIC FG OPEN && { disable_gns chmod u-s $DIR/gns_test_2d rm -fr $DIR/gns_test_2d @@ -825,6 +902,7 @@ test_2d() { disable_gns chmod u-s $DIR/gns_test_2d rm -fr $DIR/gns_test_2d + return 0 } run_test 2d " odd conditions (mount object is absent) ==============" @@ -852,13 +930,14 @@ test_2e() { echo "..a" > /proc/fs/lustre/llite/fs0/gns_object_name test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x..a" || error "'..a' is not set as mount object name" + return 0 } run_test 2e " odd conditions ('.' and '..' as mount object) =============" test_2f() { local LOOP_DEV=$(find_free_loop 2>/dev/null) - local LOOP_FILE="/tmp/gns_loop_2f" + local LOOP_FILE="$TMP/gns_loop_2f" local OBJECT=".mntinfo" local TIMOUT=5 local TICK=1 @@ -881,28 +960,27 @@ test_2f() { enable_gns echo "" - echo "testing GNS with DEADLOCK upcall in CONCUR3 mode" + echo "testing GNS with GENERIC upcall in CONCUR3 mode" - local MODE="DEADLOCK" - - check_gns $MODE $DIR/gns_test_2f $DIR/gns_test_2f $TIMOUT $TICK CONCUR3 || { + check_gns GENERIC $DIR/gns_test_2f $DIR/gns_test_2f $TIMOUT $TICK CONCUR3 FG OPEN || { disable_gns cleanup_object $DIR/gns_test_2f cleanup_loop $LOOP_DEV $LOOP_FILE - error + error "mount during modifying mount point does not work" } disable_gns cleanup_object $DIR/gns_test_2f cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 } run_test 2f " odd conditions (mount point is modifying during mount) ====" test_2g() { local LOOP_DEV=$(find_free_loop 2>/dev/null) - local LOOP_FILE="/tmp/gns_loop_2g" + local LOOP_FILE="$TMP/gns_loop_2g" local OBJECT=".mntinfo" local TIMOUT=5 local TICK=1 @@ -919,36 +997,52 @@ test_2g() { disable_gns - echo "preparing mount object at $DIR/gns_test_2g/$OBJECT..." + echo "preparing mount object at $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT..." setup_object $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT \ $OBJECT "-t ext2 $LOOP_DEV" || error + chmod u+s $DIR/gns_test_2g -R enable_gns echo "" - echo "testing GNS with DEADLOCK upcall in GENERIC mode" + echo "testing GNS with GENERIC upcall in GENERIC mode" - local MODE="DEADLOCK" - - check_gns $MODE $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT \ -$DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT $TIMOUT $TICK GENERIC || { + check_gns GENERIC $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT \ +$DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT $TIMOUT $TICK GENERIC FG OPEN || { disable_gns cleanup_object $DIR/gns_test_2g cleanup_loop $LOOP_DEV $LOOP_FILE - error + error "recursive mount point does not work" } disable_gns + echo "" + echo "turning SUID on $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT off" + chmod u-s $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT + + enable_gns + + check_gns GENERIC $DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT \ +$DIR/gns_test_2g/$OBJECT/$OBJECT/$OBJECT $TIMOUT $TICK GENERIC FG OPEN && { + disable_gns + cleanup_object $DIR/gns_test_2g + cleanup_loop $LOOP_DEV $LOOP_FILE + error "GNS works whereas mount point is not SUID marked dir" + } + + disable_gns + cleanup_object $DIR/gns_test_2g cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 } run_test 2g " odd conditions (mount point is recursive marked SUID dir) =" test_2h() { local LOOP_DEV=$(find_free_loop 2>/dev/null) - local LOOP_FILE="/tmp/gns_loop_2h" + local LOOP_FILE="$TMP/gns_loop_2h" local OBJECT=".mntinfo" local TIMOUT=5 local TICK=1 @@ -974,7 +1068,7 @@ test_2h() { echo "testing GNS with GENERIC upcall in GENERIC mode" check_gns GENERIC $DIR/gns_test_2h $DIR/gns_test_2h \ -$TIMOUT $TICK GENERIC BACKGROUND || { +$TIMOUT $TICK GENERIC BG OPEN || { disable_gns cleanup_object $DIR/gns_test_2h cleanup_loop $LOOP_DEV $LOOP_FILE @@ -985,10 +1079,68 @@ $TIMOUT $TICK GENERIC BACKGROUND || { cleanup_object $DIR/gns_test_2h cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 } run_test 2h " odd conditions (mounting in background) ===================" +test_3a() { + local LOOP_DEV=$(find_free_loop 2>/dev/null) + local LOOP_FILE="$TMP/gns_loop_3a" + local OBJECT=".mntinfo" + local TIMOUT=5 + local TICK=1 + + test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV || + error "can't find free loop device" + + echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..." + cleanup_loop $LOOP_DEV $LOOP_FILE + setup_loop $LOOP_DEV $LOOP_FILE || error + + echo "setting up GNS timeouts and mount object..." + setup_gns $OBJECT $TIMOUT $TICK || error + + disable_gns + + echo "preparing mount object at $DIR/gns_test_3a/$OBJECT..." + setup_object $DIR/gns_test_3a $OBJECT "-t ext2 $LOOP_DEV" || error + + enable_gns + + echo "" + echo "testing GNS with GENERIC upcall in GENERIC mode" + + check_gns GENERIC $DIR/gns_test_3a $DIR/gns_test_3a \ +$TIMOUT $TICK GENERIC FG OPEN || { + disable_gns + cleanup_object $DIR/gns_test_3a + cleanup_loop $LOOP_DEV $LOOP_FILE + error + } + + chmod u-s $DIR/gns_test_3a || { + disable_gns + cleanup_object $DIR/gns_test_3a + cleanup_loop $LOOP_DEV $LOOP_FILE + error "can't chmod u-s $DIR/gns_test_3a" + } + + check_mnt $DIR/gns_test_3a && { + disable_gns + cleanup_object $DIR/gns_test_3a + cleanup_loop $LOOP_DEV $LOOP_FILE + error "chmod u-s $DIR/gns_test_3a caused mounting" + } + + disable_gns + cleanup_object $DIR/gns_test_3a + cleanup_loop $LOOP_DEV $LOOP_FILE + return 0 +} + +run_test 3a " removing mnt by chmod u-s =================================" + TMPDIR=$OLDTMPDIR TMP=$OLDTMP HOME=$OLDHOME