Whamcloud - gitweb
LU-10337 mdt: Allow open of open orphans
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 2ddbef3..4e192ec 100755 (executable)
@@ -15,9 +15,13 @@ ALWAYS_EXCEPT="$SANITY_EXCEPT  42a     42b     42c     77k"
 # skipped tests: LU-8411 LU-9096 LU-9054 ..
 ALWAYS_EXCEPT="  407     253     312     $ALWAYS_EXCEPT"
 
+if $SHARED_KEY; then
+# bug number for skipped tests:        LU-9795 (all below)
+       ALWAYS_EXCEPT="$ALWAYS_EXCEPT   17n     60a     133g    300f"
+fi
+
 # Check Grants after these tests
 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
-
 SRCDIR=$(cd $(dirname $0); echo $PWD)
 export PATH=$PATH:/sbin
 
@@ -5515,7 +5519,7 @@ test_56wb() {
 run_test 56wb "check lfs_migrate pool support"
 
 test_56wc() {
-       local file1="$DIR/$tdir/file 1"
+       local file1="$DIR/$tdir/file1"
 
        echo -n "Creating test dir..."
        test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
@@ -10680,7 +10684,6 @@ check_stats() {
                 ;;
        *) error "Wrong facet '$facet'" ;;
        esac
-       echo $res
        [ "$res" ] || error "The counter for $op on $facet was not incremented"
        # if the argument $3 is zero, it means any stat increment is ok.
        if [[ $want -gt 0 ]]; then
@@ -10739,6 +10742,8 @@ test_133a() {
 run_test 133a "Verifying MDT stats ========================================"
 
 test_133b() {
+       local res
+
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
        remote_ost_nodsh && skip "remote OST with nodsh"
        remote_mds_nodsh && skip "remote MDS with nodsh"
@@ -10771,9 +10776,25 @@ test_133b() {
        # Sleep to avoid a cached response.
        #define OBD_STATFS_CACHE_SECONDS 1
        sleep 2
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
+       do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
        $LFS df || error "lfs failed"
        check_stats $SINGLEMDS "statfs" 1
 
+       # check aggregated statfs (LU-10018)
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.54) ] &&
+               return 0
+       [ $(lustre_version_code client) -lt $(version_code 2.11.54) ] &&
+               return 0
+       sleep 2
+       do_facet $SINGLEMDS $LCTL set_param mdt.*.md_stats=clear
+       do_facet ost1 $LCTL set_param obdfilter.*.stats=clear
+       df $DIR
+       check_stats $SINGLEMDS "statfs" 1
+       res=$(do_facet ost1 \
+             $LCTL get_param obdfilter.$FSNAME-OST0000.stats | grep "statfs")
+       [ "$res" ] && error "OST got STATFS"
+
        return 0
 }
 run_test 133b "Verifying extra MDT stats =================================="
@@ -11015,7 +11036,7 @@ test_133f() {
        find $proc_dirs -exec cat '{}' \; &> /dev/null
 
        # Second verifying readability.
-       $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
+       $LCTL get_param -R '*' &> /dev/null
 
        # Verifing writability with badarea_io.
        find $proc_dirs \
@@ -13586,6 +13607,20 @@ test_184e() {
 }
 run_test 184e "Recreate layout after stripeless layout swaps"
 
+test_184f() {
+       # Create a file with name longer than sizeof(struct stat) ==
+       # 144 to see if we can get chars from the file name to appear
+       # in the returned striping. Note that 'f' == 0x66.
+       local file=$(for ((i = 0; i < 200; i++)); do echo -n f; done)
+
+       mkdir -p $DIR/$tdir
+       mcreate $DIR/$tdir/$file
+       if lfs find --stripe-count 0x6666 $DIR/$tdir | grep $file; then
+               error "IOC_MDC_GETFILEINFO returned garbage striping"
+       fi
+}
+run_test 184f "IOC_MDC_GETFILEINFO for files with long names but no striping"
+
 test_185() { # LU-2441
        # LU-3553 - no volatile file support in old servers
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
@@ -13894,8 +13929,8 @@ verify_jobstats() {
 jobstats_set() {
        local new_jobenv=$1
 
-       do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$new_jobenv
-       wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $new_jobenv
+       set_persistent_param_and_check client "jobid_var" \
+               "$FSNAME.sys.jobid_var" $new_jobenv
 }
 
 test_205() { # Job stats
@@ -13911,9 +13946,13 @@ test_205() { # Job stats
 
        local old_jobenv=$($LCTL get_param -n jobid_var)
        [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
-       stack_trap "do_facet mgs \
-               $LCTL conf_param $FSNAME.sys.jobid_var=$old_jobenv" EXIT
 
+       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               stack_trap "do_facet mgs $PERM_CMD jobid_var=$old_jobenv" EXIT
+       else
+               stack_trap "do_facet mgs $PERM_CMD \
+                       $FSNAME.sys.jobid_var=$old_jobenv" EXIT
+       fi
        changelog_register
 
        local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
@@ -14545,17 +14584,15 @@ test_224c() { # LU-6441
                                osc.*.max_pages_per_rpc)
        local at_max=$($LCTL get_param -n at_max)
        local timeout=$($LCTL get_param -n timeout)
-       local test_at="$LCTL get_param -n at_max"
+       local test_at="at_max"
        local param_at="$FSNAME.sys.at_max"
-       local test_timeout="$LCTL get_param -n timeout"
+       local test_timeout="timeout"
        local param_timeout="$FSNAME.sys.timeout"
 
        $LCTL set_param -n osc.*.max_pages_per_rpc=1024
 
-       set_conf_param_and_check client "$test_at" "$param_at" 0 ||
-               error "conf_param at_max=0 failed"
-       set_conf_param_and_check client "$test_timeout" "$param_timeout" 5 ||
-               error "conf_param timeout=5 failed"
+       set_persistent_param_and_check client "$test_at" "$param_at" 0
+       set_persistent_param_and_check client "$test_timeout" "$param_timeout" 5
 
        #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3   0x520
        do_facet ost1 $LCTL set_param fail_loc=0x520
@@ -14564,10 +14601,9 @@ test_224c() { # LU-6441
        sync
        do_facet ost1 $LCTL set_param fail_loc=0
 
-       set_conf_param_and_check client "$test_at" "$param_at" $at_max ||
-               error "conf_param at_max=$at_max failed"
-       set_conf_param_and_check client "$test_timeout" "$param_timeout" \
-               $timeout || error "conf_param timeout=$timeout failed"
+       set_persistent_param_and_check client "$test_at" "$param_at" $at_max
+       set_persistent_param_and_check client "$test_timeout" "$param_timeout" \
+               $timeout
 
        $LCTL set_param -n $pages_per_rpc
        restore_lustre_params < $p
@@ -15566,18 +15602,6 @@ test_236() {
 }
 run_test 236 "Layout swap on open unlinked file"
 
-# test to verify file handle related system calls
-# (name_to_handle_at/open_by_handle_at)
-# The new system calls are supported in glibc >= 2.14.
-
-test_237() {
-       echo "Test file_handle syscalls" > $DIR/$tfile ||
-               error "write failed"
-       check_fhandle_syscalls $DIR/$tfile ||
-               error "check_fhandle_syscalls failed"
-}
-run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
-
 # LU-4659 linkea consistency
 test_238() {
        local server_version=$(lustre_version_code $SINGLEMDS)
@@ -17286,6 +17310,140 @@ test_271f() {
 }
 run_test 271f "DoM: read on open (200K file and read tail)"
 
+test_272a() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
+               skip "Need MDS version at least 2.11.50"
+
+       local dom=$DIR/$tdir/dom
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 256K -L mdt -E -1 -c1 $dom
+       dd if=/dev/urandom of=$dom bs=512K count=1 ||
+               error "failed to write data into $dom"
+       local old_md5=$(md5sum $dom)
+
+       $LFS migrate -E 256K -L mdt -E -1 -c2 $dom ||
+               error "failed to migrate to the same DoM component"
+
+       [ $($LFS getstripe -c $dom) -eq 2 ] ||
+               error "layout was not changed silently"
+
+       local new_md5=$(md5sum $dom)
+
+       [ "$old_md5" != "$new_md5" ] &&
+               error "md5sum differ: $old_md5, $new_md5"
+       return 0
+}
+run_test 272a "DoM migration: new layout with the same DOM component"
+
+test_272b() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
+               skip "Need MDS version at least 2.11.50"
+
+       local dom=$DIR/$tdir/dom
+       mkdir -p $DIR/$tdir
+       $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
+
+       local mdtidx=$($LFS getstripe -m $dom)
+       local mdtname=MDT$(printf %04x $mdtidx)
+       local facet=mds$((mdtidx + 1))
+
+       local mdtfree1=$(do_facet $facet \
+               lctl get_param -n osd*.*$mdtname.kbytesfree)
+       dd if=/dev/urandom of=$dom bs=2M count=1 ||
+               error "failed to write data into $dom"
+       local old_md5=$(md5sum $dom)
+       cancel_lru_locks mdc
+       local mdtfree1=$(do_facet $facet \
+               lctl get_param -n osd*.*$mdtname.kbytesfree)
+
+       $LFS migrate -c2 $dom ||
+               error "failed to migrate to the new composite layout"
+       [ $($LFS getstripe -L $dom) == 'mdt' ] &&
+               error "MDT stripe was not removed"
+
+       cancel_lru_locks mdc
+       local new_md5=$(md5sum $dom)
+       [ "$old_md5" != "$new_md5" ] &&
+               error "$old_md5 != $new_md5"
+
+       # Skip free space checks with ZFS
+       if [ "$(facet_fstype $facet)" != "zfs" ]; then
+               local mdtfree2=$(do_facet $facet \
+                               lctl get_param -n osd*.*$mdtname.kbytesfree)
+               [ $mdtfree2 -gt $mdtfree1 ] ||
+                       error "MDT space is not freed after migration"
+       fi
+       return 0
+}
+run_test 272b "DoM migration: DOM file to the OST-striped file (plain)"
+
+test_272c() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
+               skip "Need MDS version at least 2.11.50"
+
+       local dom=$DIR/$tdir/$tfile
+       mkdir -p $DIR/$tdir
+       $LFS setstripe -E 1M -L mdt -E -1 -c1 $dom
+
+       local mdtidx=$($LFS getstripe -m $dom)
+       local mdtname=MDT$(printf %04x $mdtidx)
+       local facet=mds$((mdtidx + 1))
+
+       dd if=/dev/urandom of=$dom bs=2M count=1 oflag=direct ||
+               error "failed to write data into $dom"
+       local old_md5=$(md5sum $dom)
+       cancel_lru_locks mdc
+       local mdtfree1=$(do_facet $facet \
+               lctl get_param -n osd*.*$mdtname.kbytesfree)
+
+       $LFS migrate -E 2M -c1 -E -1 -c2 $dom ||
+               error "failed to migrate to the new composite layout"
+       [ $($LFS getstripe -L $dom) == 'mdt' ] &&
+               error "MDT stripe was not removed"
+
+       cancel_lru_locks mdc
+       local new_md5=$(md5sum $dom)
+       [ "$old_md5" != "$new_md5" ] &&
+               error "$old_md5 != $new_md5"
+
+       # Skip free space checks with ZFS
+       if [ "$(facet_fstype $facet)" != "zfs" ]; then
+               local mdtfree2=$(do_facet $facet \
+                               lctl get_param -n osd*.*$mdtname.kbytesfree)
+               [ $mdtfree2 -gt $mdtfree1 ] ||
+                       error "MDS space is not freed after migration"
+       fi
+       return 0
+}
+run_test 272c "DoM migration: DOM file to the OST-striped file (composite)"
+
+test_273a() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.50) ] &&
+               skip "Need MDS version at least 2.11.50"
+
+       # Layout swap cannot be done if either file has DOM component,
+       # this will never be supported, migration should be used instead
+
+       local dom=$DIR/$tdir/$tfile
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -c2 ${dom}_plain
+       $LFS setstripe -E 1M -L mdt -E -1 -c2 ${dom}_dom
+       $LFS swap_layouts ${dom}_plain ${dom}_dom &&
+               error "can swap layout with DoM component"
+       $LFS swap_layouts ${dom}_dom ${dom}_plain &&
+               error "can swap layout with DoM component"
+
+       $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_comp
+       $LFS swap_layouts ${dom}_comp ${dom}_dom &&
+               error "can swap layout with DoM component"
+       $LFS swap_layouts ${dom}_dom ${dom}_comp &&
+               error "can swap layout with DoM component"
+       return 0
+}
+run_test 273a "DoM: layout swapping should fail with DOM"
+
 test_275() {
        remote_ost_nodsh && skip "remote OST with nodsh"
        [ $(lustre_version_code ost1) -lt $(version_code 2.10.57) ] &&
@@ -18890,9 +19048,9 @@ test_411() {
        echo 1M > $cgdir/memory.limit_in_bytes
 
        # Should not LBUG, just be killed by oom-killer
-       sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null" &&
-               error "fail to trigger a memory allocation error"
-
+       # dd will return 0 even allocation failure in some environment.
+       # So don't check return value
+       sh -c "echo \$$ > $cgdir/tasks && dd if=$DIR/$tfile of=/dev/null"
        cleanup_test411_cgroup $cgdir
 
        return 0
@@ -19004,6 +19162,20 @@ test_415() {
 }
 run_test 415 "lock revoke is not missing"
 
+
+test_416() {
+       [ $(lustre_version_code mds1) -lt $(version_code 2.11.55) ] &&
+               skip "Need server version at least 2.11.55"
+
+       # define OBD_FAIL_OSD_TXN_START    0x19a
+       do_facet mds1 lctl set_param fail_loc=0x19a
+
+       lfs mkdir -c $MDSCOUNT $DIR/$tdir
+
+       true
+}
+run_test 416 "transaction start failure won't cause system hung"
+
 prep_801() {
        [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
        [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
@@ -19628,6 +19800,38 @@ test_807() {
 }
 run_test 807 "verify LSOM syncing tool"
 
+check_som_nologged()
+{
+       local lines=$($LFS changelog $FSNAME-MDT0000 |
+               grep 'x=trusted.som' | wc -l)
+       [ $lines -ne 0 ] && error "trusted.som xattr is logged in Changelogs"
+}
+
+test_808() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.55) ] &&
+               skip "Need MDS version at least 2.11.55" && return
+
+       # Registration step
+       changelog_register || error "changelog_register failed"
+
+       touch $DIR/$tfile || error "touch $tfile failed"
+       check_som_nologged
+
+       dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=1 ||
+               error "write $tfile failed"
+       check_som_nologged
+
+       $TRUNCATE $DIR/$tfile 1234
+       check_som_nologged
+
+       $TRUNCATE $DIR/$tfile 1048576
+       check_som_nologged
+
+       # Deregistration step
+       changelog_deregister || error "changelog_deregister failed"
+}
+run_test 808 "Check trusted.som xattr not logged in Changelogs"
+
 #
 # tests that do cleanup/setup should be run at the end
 #