Whamcloud - gitweb
LU-3285 merge: 'dom' branch merging
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 929fdc4..881a3d7 100755 (executable)
@@ -12,8 +12,8 @@ ONLY=${ONLY:-"$*"}
 ALWAYS_EXCEPT="                42a    42b      42c     45   68b $SANITY_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-# skipped tests: LU-2036 LU-8411 LU-9096 LU-9054
-ALWAYS_EXCEPT="  76     407     253     312 $ALWAYS_EXCEPT"
+# skipped tests: LU-8411 LU-9096 LU-9054 LU-10199
+ALWAYS_EXCEPT="  407     253     312     56xb     $ALWAYS_EXCEPT"
 
 # Check Grants after these tests
 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
@@ -1713,10 +1713,10 @@ test_27w() { # bug 10997
        $LFS setstripe -S 65536 $DIR/$tdir/f0 || error "setstripe failed"
        [ $($LFS getstripe -S $DIR/$tdir/f0) -ne 65536 ] &&
                error "stripe size $size != 65536" || true
-       [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -ne 1 ] &&
-               error "$LFS getstripe -d $DIR/$tdir failed" || true
+       [ $($LFS getstripe -d $DIR/$tdir | grep -c "stripe_count") -eq 0 ] &&
+               error "$LFS getstripe -d $DIR/$tdir no 'stripe_count'" || true
 }
-run_test 27w "check $LFS setstripe -S option"
+run_test 27w "check $LFS setstripe -S and getstrip -d options"
 
 test_27wa() {
        [[ $OSTCOUNT -lt 2 ]] &&
@@ -4154,11 +4154,13 @@ test_51b() {
        [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
                return
 
-       trap cleanup_print_lfsdf EXIT
+       trap cleanup_print_lfs_df EXIT
 
        # create files
-       createmany -d $dir/d $nrdirs ||
+       createmany -d $dir/d $nrdirs || {
+               unlinkmany $dir/d $nrdirs
                error "failed to create $nrdirs subdirs in MDT$mdtidx:$dir"
+       }
 
        # really created :
        nrdirs=$(ls -U $dir | wc -l)
@@ -4267,8 +4269,10 @@ test_51f() {
                echo "left ulimit at $ulimit_old"
        fi
 
-       createmany -o -k -t 120 $DIR/$tdir/f $numfree ||
+       createmany -o -k -t 120 $DIR/$tdir/f $numfree || {
+               unlinkmany $DIR/$tdir/f $numfree
                error "create+open $numfree files in $DIR/$tdir failed"
+       }
        ulimit -n $ulimit_old
 
        # if createmany exits at 120s there will be fewer than $numfree files
@@ -5151,16 +5155,15 @@ test_56x() {
        check_swap_layouts_support && return 0
        [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
 
-       local dir0=$DIR/$tdir/$testnum
-       test_mkdir -p $dir0
-
+       local dir0=$DIR/$tdir
        local ref1=/etc/passwd
        local file1=$dir0/file1
 
-       $SETSTRIPE -c 2 $file1
+       test_mkdir $dir0 || error "creating dir $dir0"
+       $LFS setstripe -c 2 $file1
        cp $ref1 $file1
        $LFS migrate -c 1 $file1 || error "migrate failed rc = $?"
-       stripe=$($GETSTRIPE -c $file1)
+       stripe=$($LFS getstripe -c $file1)
        [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
        cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
 
@@ -5179,10 +5182,10 @@ test_56xa() {
        local ref1=/etc/passwd
        local file1=$dir0/file1
 
-       $SETSTRIPE -c 2 $file1
+       $LFS setstripe -c 2 $file1
        cp $ref1 $file1
        $LFS migrate --block -c 1 $file1 || error "migrate failed rc = $?"
-       local stripe=$($GETSTRIPE -c $file1)
+       local stripe=$($LFS getstripe -c $file1)
        [[ $stripe == 1 ]] || error "stripe of $file1 is $stripe != 1"
        cmp $file1 $ref1 || error "content mismatch $file1 differs from $ref1"
 
@@ -5191,6 +5194,110 @@ test_56xa() {
 }
 run_test 56xa "lfs migration --block support"
 
+check_migrate_links() {
+       local dir="$1"
+       local file1="$dir/file1"
+       local begin="$2"
+       local count="$3"
+       local total_count=$(($begin + $count - 1))
+       local symlink_count=10
+       local uniq_count=10
+
+       if [ ! -f "$file1" ]; then
+               echo -n "creating initial file..."
+               $LFS setstripe -c 1 -S "512k" "$file1" ||
+                       error "cannot setstripe initial file"
+               echo "done"
+
+               echo -n "creating symlinks..."
+               for s in $(seq 1 $symlink_count); do
+                       ln -s "$file1" "$dir/slink$s" ||
+                               error "cannot create symlinks"
+               done
+               echo "done"
+
+               echo -n "creating nonlinked files..."
+               createmany -o "$dir/uniq" 1 10 &> /dev/null ||
+                       error "cannot create nonlinked files"
+               echo "done"
+       fi
+
+       # create hard links
+       if [ ! -f "$dir/file$total_count" ]; then
+               echo -n "creating hard links $begin:$total_count..."
+               createmany -l"$file1" "$dir/file" "$begin" "$count" &>  \
+                       /dev/null || error "cannot create hard links"
+               echo "done"
+       fi
+
+       echo -n "checking number of hard links listed in xattrs..."
+       local fid=$($LFS getstripe -F "$file1")
+       local paths=($($LFS fid2path "$MOUNT" "$fid" 2> /dev/null))
+
+       echo "${#paths[*]}"
+       if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2  ]; then
+                       echo "hard link list has unexpected size, skipping test"
+                       return 0
+       fi
+       if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2  ]; then
+                       error "link names should exceed xattrs size"
+       fi
+
+       echo -n "migrating files..."
+       local migrate_out=$($LFS_MIGRATE -y -S '1m' $dir)
+       local rc=$?
+       [ $rc -eq 0 ] || error "migrate failed rc = $rc"
+       echo "done"
+
+       # make sure all links have been properly migrated
+       echo -n "verifying files..."
+       fid=$($LFS getstripe -F "$file1") ||
+               error "cannot get fid for file $file1"
+       for i in $(seq 2 $total_count); do
+               local fid2=$($LFS getstripe -F $dir/file$i)
+               [ "$fid2" == "$fid" ] ||
+                       error "migrated hard link has mismatched FID"
+       done
+
+       # make sure hard links were properly detected, and migration was
+       # performed only once for the entire link set; nonlinked files should
+       # also be migrated
+       local actual=$(grep -c 'done migrate' <<< "$migrate_out")
+       local expected=$(($uniq_count + 1))
+       [ "$actual" -eq  "$expected" ] ||
+               error "hard links individually migrated ($actual != $expected)"
+
+       # make sure the correct number of hard links are present
+       local hardlinks=$(stat -c '%h' "$file1")
+       [ $hardlinks -eq $total_count ] ||
+               error "num hard links $hardlinks != $total_count"
+       echo "done"
+
+       return 0
+}
+
+test_56xb() {
+       local dir0="$DIR/$tdir"
+
+       test_mkdir "$dir0" || error "cannot create dir $dir0"
+
+       echo "testing lfs migrate mode when all links fit within xattrs"
+       LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 2 99
+
+       echo "testing rsync mode when all links fit within xattrs"
+       LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 2 99
+
+       echo "testing lfs migrate mode when all links do not fit within xattrs"
+       LFS_MIGRATE_RSYNC=false check_migrate_links "$dir0" 101 100
+
+       echo "testing rsync mode when all links do not fit within xattrs"
+       LFS_MIGRATE_RSYNC=true check_migrate_links "$dir0" 101 100
+
+       # clean up
+       rm -rf $dir0
+}
+run_test 56xb "lfs migration hard link support"
+
 test_56y() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
                skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
@@ -6008,21 +6115,9 @@ num_inodes() {
        awk '/lustre_inode_cache/ {print $2; exit}' /proc/slabinfo
 }
 
-get_inode_slab_tunables() {
-       awk '/lustre_inode_cache/ {print $9," ",$10," ",$11; exit}' /proc/slabinfo
-}
-
-set_inode_slab_tunables() {
-       echo "lustre_inode_cache $1" > /proc/slabinfo
-}
-
 test_76() { # Now for bug 20433, added originally in bug 1443
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       local SLAB_SETTINGS=$(get_inode_slab_tunables)
        local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
-       # we cannot set limit below 1 which means 1 inode in each
-       # per-cpu cache is still allowed
-       set_inode_slab_tunables "1 1 0"
        cancel_lru_locks osc
        BEFORE_INODES=$(num_inodes)
        echo "before inodes: $BEFORE_INODES"
@@ -6045,7 +6140,6 @@ test_76() { # Now for bug 20433, added originally in bug 1443
                        error "inode slab grew from $BEFORE_INODES to $AFTER_INODES"
                fi
        done
-       set_inode_slab_tunables "$SLAB_SETTINGS"
 }
 run_test 76 "confirm clients recycle inodes properly ===="
 
@@ -6933,7 +7027,7 @@ setup_test102() {
        done
 
        cd $DIR
-       $1 $TAR cf $TMP/f102.tar $tdir --xattrs
+       $1 tar cf $TMP/f102.tar $tdir --xattrs
 }
 
 cleanup_test102() {
@@ -7092,20 +7186,17 @@ compare_stripe_info1() {
        return 0
 }
 
-find_lustre_tar() {
-       [ -n "$(which tar 2>/dev/null)" ] &&
-               strings $(which tar) | grep -q "lustre" && echo tar
+have_xattrs_include() {
+       tar --help | grep -q xattrs-include &&
+               echo --xattrs-include="lustre.*"
 }
 
 test_102d() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       # b10930: tar test for trusted.lov xattr
-       TAR=$(find_lustre_tar)
-       [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
        [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       XINC=$(have_xattrs_include)
        setup_test102
-       test_mkdir $DIR/$tdir
-       $TAR xf $TMP/$tfile.tar -C $DIR/$tdir --xattrs
+       tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
        cd $DIR/$tdir/$tdir
        compare_stripe_info1
 }
@@ -7113,14 +7204,13 @@ run_test 102d "tar restore stripe info from tarfile,not keep osts"
 
 test_102f() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       # b10930: tar test for trusted.lov xattr
-       TAR=$(find_lustre_tar)
-       [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
        [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       XINC=$(have_xattrs_include)
        setup_test102
        test_mkdir $DIR/$tdir.restore
        cd $DIR
-       $TAR cf - --xattrs $tdir | $TAR xf - --xattrs -C $DIR/$tdir.restore
+       tar cf - --xattrs $tdir | tar xf - \
+               -C $DIR/$tdir.restore --xattrs $XINC
        cd $DIR/$tdir.restore/$tdir
        compare_stripe_info1
 }
@@ -7194,13 +7284,11 @@ run_test 102i "lgetxattr test on symbolic link ============"
 
 test_102j() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       TAR=$(find_lustre_tar)
-       [ -z "$TAR" ] && skip_env "lustre-aware tar is not installed" && return
        [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       XINC=$(have_xattrs_include)
        setup_test102 "$RUNAS"
-       test_mkdir $DIR/$tdir
        chown $RUNAS_ID $DIR/$tdir
-       $RUNAS $TAR xf $TMP/f102.tar -C $DIR/$tdir --xattrs
+       $RUNAS tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
        cd $DIR/$tdir/$tdir
        compare_stripe_info1 "$RUNAS"
 }
@@ -12617,16 +12705,12 @@ run_test 214 "hash-indexed directory test - bug 20133"
 
 # having "abc" as 1st arg, creates $TMP/lnet_abc.out and $TMP/lnet_abc.sys
 create_lnet_proc_files() {
-       lctl get_param -n $1 >$TMP/lnet_$1.out || error "cannot read lnet.$1"
-       sysctl lnet.$1 >$TMP/lnet_$1.sys_tmp || error "cannot read lnet.$1"
-
-       sed "s/^lnet.$1\ =\ //g" "$TMP/lnet_$1.sys_tmp" >$TMP/lnet_$1.sys
-       rm -f "$TMP/lnet_$1.sys_tmp"
+       lctl get_param -n $1 >$TMP/lnet_$1.sys || error "cannot read lnet.$1"
 }
 
 # counterpart of create_lnet_proc_files
 remove_lnet_proc_files() {
-       rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
+       rm -f $TMP/lnet_$1.sys
 }
 
 # uses 1st arg as trailing part of filename, 2nd arg as description for reports,
@@ -12736,7 +12820,6 @@ test_215() { # for bugs 18102, 21079, 21517
 
        # can we successfully write to lnet.stats?
        lctl set_param -n stats=0 || error "cannot write to lnet.stats"
-       sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
 }
 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
 
@@ -13972,9 +14055,10 @@ test_239() {
        mkdir -p $DIR/$tdir
        createmany -o $DIR/$tdir/f- 5000
        unlinkmany $DIR/$tdir/f- 5000
-       do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
-       changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
-                       osc.*MDT*.sync_in_flight" | calc_sum)
+       [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.10.53) ] &&
+               do_nodes $list "lctl set_param -n osp.*.force_sync=1"
+       changes=$(do_nodes $list "lctl get_param -n osp.*MDT*.sync_changes \
+                       osp.*MDT*.sync_in_flight" | calc_sum)
        [ "$changes" -eq 0 ] || error "$changes not synced"
 }
 run_test 239 "osp_sync test"
@@ -14903,11 +14987,12 @@ test_256() {
 
        #after mount new plainllog is used
        touch $DIR/$tdir/{11..19}
-       local TEMP256FILE=$(mktemp TEMP256XXXXXX)
+       do_facet mds1 sync
+       local TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
        cat_sl=$(do_facet mds1 \
        "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
         llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
-       rm $TEMP256FILE
+       do_facet mds1 rm $TEMP256FILE
 
        if (( cat_sl != 2 )); then
                do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
@@ -14916,11 +15001,12 @@ test_256() {
 
        $LFS changelog_clear $MDT0 $cl_user 0
 
-       TEMP256FILE=$(mktemp TEMP256XXXXXX)
+       do_facet mds1 sync
+       TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
        cat_sl=$(do_facet mds1 \
        "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
         llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
-       rm $TEMP256FILE
+       do_facet mds1 rm $TEMP256FILE
 
        do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
 
@@ -15685,17 +15771,17 @@ test_300g() {
        $LFS setdirstripe -D -i1 $DIR/$tdir/striped_dir ||
                error "create striped_dir failed"
 
+       $LFS setdirstripe -i0 $DIR/$tdir/striped_dir/dir0 ||
+               error "create dir0 fails"
+       stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir0)
+       [ $stripe_index -eq 0 ] ||
+               error "dir0 expect index 0 got $stripe_index"
+
        mkdir $DIR/$tdir/striped_dir/dir1 ||
                error "create dir1 fails"
        stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir1)
        [ $stripe_index -eq 1 ] ||
-               error "dir1 expect 1 got $stripe_index"
-
-       $LFS setdirstripe -i2 $DIR/$tdir/striped_dir/dir2 ||
-               error "create dir2 fails"
-       stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir/dir2)
-       [ $stripe_index -eq 2 ] ||
-               error "dir2 expect 2 got $stripe_index"
+               error "dir1 expect index 1 got $stripe_index"
 
        #check default stripe count/stripe index
        test_300_check_default_striped_dir normal_dir $MDSCOUNT 1