+test_401a() { #LU-7437
+ local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
+ [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
+ return
+ #count the number of parameters by "list_param -R"
+ local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
+ #count the number of parameters by listing proc files
+ local procs=$(find -L $proc_dirs -mindepth 1 -printf '%P\n' 2>/dev/null|
+ sort -u | wc -l)
+
+ [ $params -eq $procs ] ||
+ error "found $params parameters vs. $procs proc files"
+
+ # test the list_param -D option only returns directories
+ params=$($LCTL list_param -R -D '*' 2>/dev/null | wc -l)
+ #count the number of parameters by listing proc directories
+ procs=$(find -L $proc_dirs -mindepth 1 -type d -printf '%P\n' 2>/dev/null |
+ sort -u | wc -l)
+
+ [ $params -eq $procs ] ||
+ error "found $params parameters vs. $procs proc files"
+}
+run_test 401a "Verify if 'lctl list_param -R' can list parameters recursively"
+
+test_401b() {
+ local save=$($LCTL get_param -n jobid_var)
+ local tmp=testing
+
+ $LCTL set_param foo=bar jobid_var=$tmp bar=baz &&
+ error "no error returned when setting bad parameters"
+
+ local jobid_new=$($LCTL get_param -n foe jobid_var baz)
+ [[ "$jobid_new" == "$tmp" ]] || error "jobid tmp $jobid_new != $tmp"
+
+ $LCTL set_param -n fog=bam jobid_var=$save bat=fog
+ local jobid_old=$($LCTL get_param -n foe jobid_var bag)
+ [[ "$jobid_old" == "$save" ]] || error "jobid new $jobid_old != $save"
+}
+run_test 401b "Verify 'lctl {get,set}_param' continue after error"
+
+test_401c() {
+ local jobid_var_old=$($LCTL get_param -n jobid_var)
+ local jobid_var_new
+
+ $LCTL set_param jobid_var= &&
+ error "no error returned for 'set_param a='"
+
+ jobid_var_new=$($LCTL get_param -n jobid_var)
+ [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
+ error "jobid_var was changed by setting without value"
+
+ $LCTL set_param jobid_var &&
+ error "no error returned for 'set_param a'"
+
+ jobid_var_new=$($LCTL get_param -n jobid_var)
+ [[ "$jobid_var_old" == "$jobid_var_new" ]] ||
+ error "jobid_var was changed by setting without value"
+}
+run_test 401c "Verify 'lctl set_param' without value fails in either format."
+
+test_401d() {
+ local jobid_var_old=$($LCTL get_param -n jobid_var)
+ local jobid_var_new
+ local new_value="foo=bar"
+
+ $LCTL set_param jobid_var=$new_value ||
+ error "'set_param a=b' did not accept a value containing '='"
+
+ jobid_var_new=$($LCTL get_param -n jobid_var)
+ [[ "$jobid_var_new" == "$new_value" ]] ||
+ error "'set_param a=b' failed on a value containing '='"
+
+ # Reset the jobid_var to test the other format
+ $LCTL set_param jobid_var=$jobid_var_old
+ jobid_var_new=$($LCTL get_param -n jobid_var)
+ [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
+ error "failed to reset jobid_var"
+
+ $LCTL set_param jobid_var $new_value ||
+ error "'set_param a b' did not accept a value containing '='"
+
+ jobid_var_new=$($LCTL get_param -n jobid_var)
+ [[ "$jobid_var_new" == "$new_value" ]] ||
+ error "'set_param a b' failed on a value containing '='"
+
+ $LCTL set_param jobid_var $jobid_var_old
+ jobid_var_new=$($LCTL get_param -n jobid_var)
+ [[ "$jobid_var_new" == "$jobid_var_old" ]] ||
+ error "failed to reset jobid_var"
+}
+run_test 401d "Verify 'lctl set_param' accepts values containing '='"
+
+test_402() {
+ remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
+#define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
+ do_facet mds1 "lctl set_param fail_loc=0x8000015c"
+ touch $DIR/$tdir/$tfile && error "touch should fail with ENOENT" ||
+ echo "Touch failed - OK"
+}
+run_test 402 "Return ENOENT to lod_generate_and_set_lovea"
+
+test_403() {
+ local file1=$DIR/$tfile.1
+ local file2=$DIR/$tfile.2
+ local tfile=$TMP/$tfile
+
+ rm -f $file1 $file2 $tfile
+
+ touch $file1
+ ln $file1 $file2
+
+ # 30 sec OBD_TIMEOUT in ll_getattr()
+ # right before populating st_nlink
+ $LCTL set_param fail_loc=0x80001409
+ stat -c %h $file1 > $tfile &
+
+ # create an alias, drop all locks and reclaim the dentry
+ < $file2
+ cancel_lru_locks mdc
+ cancel_lru_locks osc
+ sysctl -w vm.drop_caches=2
+
+ wait
+
+ [ `cat $tfile` -gt 0 ] || error "wrong nlink count: `cat $tfile`"
+
+ rm -f $tfile $file1 $file2
+}
+run_test 403 "i_nlink should not drop to zero due to aliasing"
+
+test_404() { # LU-6601
+ remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ local mosps=$(do_facet $SINGLEMDS $LCTL dl |
+ awk '/osp .*-osc-MDT/ { print $4}')
+
+ local osp
+ for osp in $mosps; do
+ echo "Deactivate: " $osp
+ do_facet $SINGLEMDS $LCTL --device %$osp deactivate
+ local stat=$(do_facet $SINGLEMDS $LCTL dl |
+ awk -vp=$osp '$4 == p { print $2 }')
+ [ $stat = IN ] || {
+ do_facet $SINGLEMDS $LCTL dl | grep -w $osp
+ error "deactivate error"
+ }
+ echo "Activate: " $osp
+ do_facet $SINGLEMDS $LCTL --device %$osp activate
+ local stat=$(do_facet $SINGLEMDS $LCTL dl |
+ awk -vp=$osp '$4 == p { print $2 }')
+ [ $stat = UP ] || {
+ do_facet $SINGLEMDS $LCTL dl | grep -w $osp
+ error "activate error"
+ }
+ done
+}
+run_test 404 "validate manual {de}activated works properly for OSPs"
+
+test_405() {
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
+ skip "Layout swap lock is not supported" && return
+
+ check_swap_layouts_support && return 0
+
+ test_mkdir -p $DIR/$tdir
+ swap_lock_test -d $DIR/$tdir ||
+ error "One layout swap locked test failed"
+}
+run_test 405 "Various layout swap lock tests"
+
+test_406() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+ [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+ [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+ [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
+ skip "Need MDS version at least 2.8.50" && return
+
+ local def_stripenr=$($GETSTRIPE -c $MOUNT)
+ local def_stripe_size=$($GETSTRIPE -S $MOUNT)
+ local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
+ local def_pool=$($GETSTRIPE -p $MOUNT)
+
+ local test_pool=$TESTNAME
+ pool_add $test_pool || error "pool_add failed"
+ pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
+ error "pool_add_targets failed"
+
+ # parent set default stripe count only, child will stripe from both
+ # parent and fs default
+ $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
+ error "setstripe $MOUNT failed"
+ $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
+ $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
+ for i in $(seq 10); do
+ local f=$DIR/$tdir/$tfile.$i
+ touch $f || error "touch failed"
+ local count=$($GETSTRIPE -c $f)
+ [ $count -eq $OSTCOUNT ] ||
+ error "$f stripe count $count != $OSTCOUNT"
+ local offset=$($GETSTRIPE -i $f)
+ [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
+ local size=$($GETSTRIPE -S $f)
+ [ $size -eq $((def_stripe_size * 2)) ] ||
+ error "$f stripe size $size != $((def_stripe_size * 2))"
+ local pool=$($GETSTRIPE -p $f)
+ [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
+ done
+
+ # change fs default striping, delete parent default striping, now child
+ # will stripe from new fs default striping only
+ $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
+ error "change $MOUNT default stripe failed"
+ $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
+ for i in $(seq 11 20); do
+ local f=$DIR/$tdir/$tfile.$i
+ touch $f || error "touch $f failed"
+ local count=$($GETSTRIPE -c $f)
+ [ $count -eq 1 ] || error "$f stripe count $count != 1"
+ local offset=$($GETSTRIPE -i $f)
+ [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
+ local size=$($GETSTRIPE -S $f)
+ [ $size -eq $def_stripe_size ] ||
+ error "$f stripe size $size != $def_stripe_size"
+ local pool=$($GETSTRIPE -p $f)
+ [ "#$pool" == "#" ] || error "$f pool $pool is set"
+
+ done
+
+ unlinkmany $DIR/$tdir/$tfile. 1 20
+
+ # restore FS default striping
+ if [ -z $def_pool ]; then
+ $SETSTRIPE -c $def_stripenr -S $def_stripe_size \
+ -i $def_stripe_offset $MOUNT ||
+ error "restore default striping failed"
+ else
+ $SETSTRIPE -c $def_stripenr -S $def_stripe_size -p $def_pool \
+ -i $def_stripe_offset $MOUNT ||
+ error "restore default striping with $def_pool failed"
+ fi
+
+ local f=$DIR/$tdir/$tfile
+ pool_remove_all_targets $test_pool $f
+ pool_remove $test_pool $f
+}
+run_test 406 "DNE support fs default striping"
+