+test_214() { # for bug 20133
+ mkdir -p $DIR/d214p/d214c
+ for (( i=0; i < 340; i++ )) ; do
+ touch $DIR/d214p/d214c/a$i
+ done
+
+ ls -l $DIR/d214p || error "ls -l $DIR/d214p failed"
+ mv $DIR/d214p/d214c $DIR/ || error "mv $DIR/d214p/d214c $DIR/ failed"
+ ls $DIR/d214c || error "ls $DIR/d214c failed"
+ rm -rf $DIR/d214* || error "rm -rf $DIR/d214* failed"
+}
+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() {
+ cat /proc/sys/lnet/$1 >$TMP/lnet_$1.out || error "cannot read /proc/sys/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"
+}
+
+# counterpart of create_lnet_proc_files
+remove_lnet_proc_files() {
+ rm -f $TMP/lnet_$1.out $TMP/lnet_$1.sys
+}
+
+# uses 1st arg as trailing part of filename, 2nd arg as description for reports,
+# 3rd arg as regexp for body
+check_lnet_proc_stats() {
+ local l=$(cat "$TMP/lnet_$1" |wc -l)
+ [ $l = 1 ] || (cat "$TMP/lnet_$1" && error "$2 is not of 1 line: $l")
+
+ grep -E "$3" "$TMP/lnet_$1" || (cat "$TMP/lnet_$1" && error "$2 misformatted")
+}
+
+# uses 1st arg as trailing part of filename, 2nd arg as description for reports,
+# 3rd arg as regexp for body, 4th arg as regexp for 1st line, 5th arg is
+# optional and can be regexp for 2nd line (lnet.routes case)
+check_lnet_proc_entry() {
+ local blp=2 # blp stands for 'position of 1st line of body'
+ [ "$5" = "" ] || blp=3 # lnet.routes case
+
+ local l=$(cat "$TMP/lnet_$1" |wc -l)
+ # subtracting one from $blp because the body can be empty
+ [ "$l" -ge "$(($blp - 1))" ] || (cat "$TMP/lnet_$1" && error "$2 is too short: $l")
+
+ sed -n '1 p' "$TMP/lnet_$1" |grep -E "$4" >/dev/null ||
+ (cat "$TMP/lnet_$1" && error "1st line of $2 misformatted")
+
+ [ "$5" = "" ] || sed -n '2 p' "$TMP/lnet_$1" |grep -E "$5" >/dev/null ||
+ (cat "$TMP/lnet_$1" && error "2nd line of $2 misformatted")
+
+ # bail out if any unexpected line happened
+ sed -n "$blp~1 p" "$TMP/lnet_$1" |grep -Ev "$3"
+ [ "$?" != 0 ] || error "$2 misformatted"
+}
+
+test_215() { # for bugs 18102, 21079, 21517
+ local N='(0|[1-9][0-9]*)' # non-negative numeric
+ local P='[1-9][0-9]*' # positive numeric
+ local I='(0|-?[1-9][0-9]*)' # any numeric (0 | >0 | <0)
+ local NET='[a-z][a-z0-9]*' # LNET net like o2ib2
+ local ADDR='[0-9.]+' # LNET addr like 10.0.0.1
+ local NID="$ADDR@$NET" # LNET nid like 10.0.0.1@o2ib2
+
+ local L1 # regexp for 1st line
+ local L2 # regexp for 2nd line (optional)
+ local BR # regexp for the rest (body)
+
+ # /proc/sys/lnet/stats should look as 11 space-separated non-negative numerics
+ BR="^$N $N $N $N $N $N $N $N $N $N $N$"
+ create_lnet_proc_files "stats"
+ check_lnet_proc_stats "stats.out" "/proc/sys/lnet/stats" "$BR"
+ check_lnet_proc_stats "stats.sys" "lnet.stats" "$BR"
+ remove_lnet_proc_files "stats"
+
+ # /proc/sys/lnet/routes should look like this:
+ # Routing disabled/enabled
+ # net hops state router
+ # where net is a string like tcp0, hops >= 0, state is up/down,
+ # router is a string like 192.168.1.1@tcp2
+ L1="^Routing (disabled|enabled)$"
+ L2="^net +hops +state +router$"
+ BR="^$NET +$N +(up|down) +$NID$"
+ create_lnet_proc_files "routes"
+ check_lnet_proc_entry "routes.out" "/proc/sys/lnet/routes" "$BR" "$L1" "$L2"
+ check_lnet_proc_entry "routes.sys" "lnet.routes" "$BR" "$L1" "$L2"
+ remove_lnet_proc_files "routes"
+
+ # /proc/sys/lnet/routers should look like this:
+ # ref rtr_ref alive_cnt state last_ping ping_sent deadline down_ni router
+ # where ref > 0, rtr_ref > 0, alive_cnt >= 0, state is up/down,
+ # last_ping >= 0, ping_sent is boolean (0/1), deadline and down_ni are
+ # numeric (0 or >0 or <0), router is a string like 192.168.1.1@tcp2
+ L1="^ref +rtr_ref +alive_cnt +state +last_ping +ping_sent +deadline +down_ni +router$"
+ BR="^$P +$P +$N +(up|down) +$N +(0|1) +$I +$I +$NID$"
+ create_lnet_proc_files "routers"
+ check_lnet_proc_entry "routers.out" "/proc/sys/lnet/routers" "$BR" "$L1"
+ check_lnet_proc_entry "routers.sys" "lnet.routers" "$BR" "$L1"
+ remove_lnet_proc_files "routers"
+
+ # /proc/sys/lnet/peers should look like this:
+ # nid refs state max rtr min tx min queue
+ # where nid is a string like 192.168.1.1@tcp2, refs > 0,
+ # state is up/down/NA, max >= 0. rtr, min, tx, min are
+ # numeric (0 or >0 or <0), queue >= 0.
+ L1="^nid +refs +state +max +rtr +min +tx +min +queue$"
+ BR="^$NID +$P +(up|down|NA) +$N +$I +$I +$I +$I +$N$"
+ create_lnet_proc_files "peers"
+ check_lnet_proc_entry "peers.out" "/proc/sys/lnet/peers" "$BR" "$L1"
+ check_lnet_proc_entry "peers.sys" "lnet.peers" "$BR" "$L1"
+ remove_lnet_proc_files "peers"
+
+ # /proc/sys/lnet/buffers should look like this:
+ # pages count credits min
+ # where pages >=0, count >=0, credits and min are numeric (0 or >0 or <0)
+ L1="^pages +count +credits +min$"
+ BR="^ +$N +$N +$I +$I$"
+ create_lnet_proc_files "buffers"
+ check_lnet_proc_entry "buffers.out" "/proc/sys/lnet/buffers" "$BR" "$L1"
+ check_lnet_proc_entry "buffers.sys" "lnet.buffers" "$BR" "$L1"
+ remove_lnet_proc_files "buffers"
+
+ # /proc/sys/lnet/nis should look like this:
+ # nid status alive refs peer rtr max tx min
+ # where nid is a string like 192.168.1.1@tcp2, status is up/down,
+ # alive is numeric (0 or >0 or <0), refs > 0, peer >= 0,
+ # rtr >= 0, max >=0, tx and min are numeric (0 or >0 or <0).
+ L1="^nid +status +alive +refs +peer +rtr +max +tx +min$"
+ BR="^$NID +(up|down) +$I +$P +$N +$N +$N +$I +$I$"
+ create_lnet_proc_files "nis"
+ check_lnet_proc_entry "nis.out" "/proc/sys/lnet/nis" "$BR" "$L1"
+ check_lnet_proc_entry "nis.sys" "lnet.nis" "$BR" "$L1"
+ remove_lnet_proc_files "nis"
+
+ # can we successfully write to /proc/sys/lnet/stats?
+ echo "0" >/proc/sys/lnet/stats || error "cannot write to /proc/sys/lnet/stats"
+ sysctl -w lnet.stats=0 || error "cannot write to lnet.stats"
+}
+run_test 215 "/proc/sys/lnet exists and has proper content - bugs 18102, 21079, 21517"
+
+test_216() { # bug 20317
+ local node
+ local p="$TMP/sanityN-$TESTNAME.parameters"
+ save_lustre_params $HOSTNAME "osc.*.contention_seconds" > $p
+ for node in $(osts_nodes); do
+ save_lustre_params $node "ldlm.namespaces.filter-*.max_nolock_bytes" >> $p
+ save_lustre_params $node "ldlm.namespaces.filter-*.contended_locks" >> $p
+ save_lustre_params $node "ldlm.namespaces.filter-*.contention_seconds" >> $p
+ done
+ clear_osc_stats
+
+ # agressive lockless i/o settings
+ for node in $(osts_nodes); do
+ do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 2000000; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 0; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 60'
+ done
+ lctl set_param -n osc.*.contention_seconds 60
+
+ $DIRECTIO write $DIR/$tfile 0 10 4096
+ $CHECKSTAT -s 40960 $DIR/$tfile
+
+ # disable lockless i/o
+ for node in $(osts_nodes); do
+ do_node $node 'lctl set_param -n ldlm.namespaces.filter-*.max_nolock_bytes 0; lctl set_param -n ldlm.namespaces.filter-*.contended_locks 32; lctl set_param -n ldlm.namespaces.filter-*.contention_seconds 0'
+ done
+ lctl set_param -n osc.*.contention_seconds 0
+ clear_osc_stats
+
+ dd if=/dev/zero of=$DIR/$tfile count=0
+ $CHECKSTAT -s 0 $DIR/$tfile
+
+ restore_lustre_params <$p
+ rm -f $p
+ rm $DIR/$tfile
+}
+run_test 216 "check lockless direct write works and updates file size and kms correctly"
+