+
+test_44() { # 16317
+ setup
+ check_mount || return 2
+ UUID=$($LCTL get_param llite.${FSNAME}*.uuid | cut -d= -f2)
+ STATS_FOUND=no
+ UUIDS=$(do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.*.uuid")
+ for VAL in $UUIDS; do
+ NID=$(echo $VAL | cut -d= -f1)
+ CLUUID=$(echo $VAL | cut -d= -f2)
+ [ "$UUID" = "$CLUUID" ] && STATS_FOUND=yes && break
+ done
+ [ "$STATS_FOUND" = "no" ] && error "stats not found for client"
+ cleanup
+ return 0
+}
+run_test 44 "mounted client proc entry exists"
+
+test_45() { #17310
+ setup
+ check_mount || return 2
+ stop_mds
+ df -h $MOUNT &
+ log "sleep 60 sec"
+ sleep 60
+#define OBD_FAIL_PTLRPC_LONG_UNLINK 0x50f
+ do_facet client "lctl set_param fail_loc=0x50f"
+ log "sleep 10 sec"
+ sleep 10
+ manual_umount_client --force || return 3
+ do_facet client "lctl set_param fail_loc=0x0"
+ start_mds
+ mount_client $MOUNT || return 4
+ cleanup
+ return 0
+}
+run_test 45 "long unlink handling in ptlrpcd"
+
+cleanup_46a() {
+ trap 0
+ local rc=0
+ local count=$1
+
+ umount_client $MOUNT2 || rc=$?
+ umount_client $MOUNT || rc=$?
+ while [ $count -gt 0 ]; do
+ stop ost${count} -f || rc=$?
+ let count=count-1
+ done
+ stop_mds || rc=$?
+ cleanup_nocli || rc=$?
+ #writeconf to remove all ost2 traces for subsequent tests
+ writeconf
+ return $rc
+}
+
+test_46a() {
+ echo "Testing with $OSTCOUNT OSTs"
+ reformat_and_config
+ start_mds || return 1
+ #first client should see only one ost
+ start_ost || return 2
+ wait_osc_import_state mds ost FULL
+ #start_client
+ mount_client $MOUNT || return 3
+ trap "cleanup_46a $OSTCOUNT" EXIT ERR
+
+ local i
+ for (( i=2; i<=$OSTCOUNT; i++ )); do
+ start ost$i `ostdevname $i` $OST_MOUNT_OPTS || return $((i+2))
+ done
+
+ # wait until osts in sync
+ for (( i=2; i<=$OSTCOUNT; i++ )); do
+ wait_osc_import_state mds ost$i FULL
+ done
+
+
+ #second client see all ost's
+
+ mount_client $MOUNT2 || return 8
+ $LFS setstripe $MOUNT2 -c -1 || return 9
+ $LFS getstripe $MOUNT2 || return 10
+
+ echo "ok" > $MOUNT2/widestripe
+ $LFS getstripe $MOUNT2/widestripe || return 11
+ # fill acl buffer for avoid expand lsm to them
+ awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd | while read acl; do
+ setfacl -m $acl $MOUNT2/widestripe
+ done
+
+ # will be deadlock
+ stat $MOUNT/widestripe || return 12
+
+ cleanup_46a $OSTCOUNT || { echo "cleanup_46a failed!" && return 13; }
+ return 0
+}
+run_test 46a "handle ost additional - wide striped file"
+
+test_47() { #17674
+ reformat
+ setup_noconfig
+ check_mount || return 2
+ $LCTL set_param ldlm.namespaces.$FSNAME-*-*-*.lru_size=100
+
+ local lru_size=[]
+ local count=0
+ for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
+ if echo $ns | grep "MDT[[:digit:]]*"; then
+ continue
+ fi
+ lrs=$(echo $ns | sed 's/.*lru_size=//')
+ lru_size[count]=$lrs
+ let count=count+1
+ done
+
+ facet_failover ost1
+ facet_failover $SINGLEMDS
+ client_up || return 3
+
+ count=0
+ for ns in $($LCTL get_param ldlm.namespaces.$FSNAME-*-*-*.lru_size); do
+ if echo $ns | grep "MDT[[:digit:]]*"; then
+ continue
+ fi
+ lrs=$(echo $ns | sed 's/.*lru_size=//')
+ if ! test "$lrs" -eq "${lru_size[count]}"; then
+ n=$(echo $ns | sed -e 's/ldlm.namespaces.//' -e 's/.lru_size=.*//')
+ error "$n has lost lru_size: $lrs vs. ${lru_size[count]}"
+ fi
+ let count=count+1
+ done
+
+ cleanup
+ return 0
+}
+run_test 47 "server restart does not make client loss lru_resize settings"
+
+cleanup_48() {
+ trap 0
+
+ # reformat after this test is needed - if test will failed
+ # we will have unkillable file at FS
+ reformat_and_config
+}
+
+test_48() { # bug 17636
+ reformat
+ setup_noconfig
+ check_mount || return 2
+
+ $LFS setstripe $MOUNT -c -1 || return 9
+ $LFS getstripe $MOUNT || return 10
+
+ echo "ok" > $MOUNT/widestripe
+ $LFS getstripe $MOUNT/widestripe || return 11
+
+ trap cleanup_48 EXIT ERR
+
+ # fill acl buffer for avoid expand lsm to them
+ getent passwd | awk -F : '{ print "u:"$1":rwx" }' | while read acl; do
+ setfacl -m $acl $MOUNT/widestripe
+ done
+
+ stat $MOUNT/widestripe || return 12
+
+ cleanup_48
+ return 0
+}
+run_test 48 "too many acls on file"
+
+# check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE
+test_49() { # bug 17710
+ local OLD_MDS_MKFS_OPTS=$MDS_MKFS_OPTS
+ local OLD_OST_MKFS_OPTS=$OST_MKFS_OPTS
+ local LOCAL_TIMEOUT=20
+
+
+ OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$LOCAL_TIMEOUT $MKFSOPT $OSTOPT"
+
+ reformat
+ setup_noconfig
+ check_mount || return 1
+
+ echo "check ldlm_timout..."
+ LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
+ LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
+ LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
+
+ if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
+ error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
+ fi
+
+ if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT / 3)) ]; then
+ error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
+ fi
+
+ umount_client $MOUNT
+ stop_ost || return 2
+ stop_mds || return 3
+
+ OST_MKFS_OPTS="--ost --fsname=$FSNAME --device-size=$OSTSIZE --mgsnode=$MGSNID --param sys.timeout=$LOCAL_TIMEOUT --param sys.ldlm_timeout=$((LOCAL_TIMEOUT - 1)) $MKFSOPT $OSTOPT"
+
+ reformat
+ setup_noconfig
+ check_mount || return 7
+
+ LDLM_MDS="`do_facet $SINGLEMDS lctl get_param -n ldlm_timeout`"
+ LDLM_OST1="`do_facet ost1 lctl get_param -n ldlm_timeout`"
+ LDLM_CLIENT="`do_facet client lctl get_param -n ldlm_timeout`"
+
+ if [ $LDLM_MDS -ne $LDLM_OST1 ] || [ $LDLM_MDS -ne $LDLM_CLIENT ]; then
+ error "Different LDLM_TIMEOUT:$LDLM_MDS $LDLM_OST1 $LDLM_CLIENT"
+ fi
+
+ if [ $LDLM_MDS -ne $((LOCAL_TIMEOUT - 1)) ]; then
+ error "LDLM_TIMEOUT($LDLM_MDS) is not correct"
+ fi
+
+ cleanup || return $?
+
+ MDS_MKFS_OPTS=$OLD_MDS_MKFS_OPTS
+ OST_MKFS_OPTS=$OLD_OST_MKFS_OPTS
+}
+run_test 49 "check PARAM_SYS_LDLM_TIMEOUT option of MKFS.LUSTRE"
+
+lazystatfs() {
+ # Test both statfs and lfs df and fail if either one fails
+ multiop_bg_pause $1 f_
+ RC1=$?
+ PID=$!
+ killall -USR1 multiop
+ [ $RC1 -ne 0 ] && log "lazystatfs multiop failed"
+ wait $PID || { RC1=$?; log "multiop return error "; }
+
+ $LFS df &
+ PID=$!
+ sleep 5
+ kill -s 0 $PID
+ RC2=$?
+ if [ $RC2 -eq 0 ]; then
+ kill -s 9 $PID
+ log "lazystatfs df failed"
+ fi
+
+ RC=0
+ [[ $RC1 -ne 0 || $RC2 -eq 0 ]] && RC=1
+ return $RC
+}
+
+test_50a() {
+ setup
+ lctl set_param llite.$FSNAME-*.lazystatfs=1
+ touch $DIR/$tfile
+
+ lazystatfs $MOUNT || error "lazystatfs failed but no down servers"
+
+ cleanup || return $?
+}
+run_test 50a "lazystatfs all servers available =========================="
+
+test_50b() {
+ setup
+ lctl set_param llite.$FSNAME-*.lazystatfs=1
+ touch $DIR/$tfile
+
+ # Wait for client to detect down OST
+ stop_ost || error "Unable to stop OST1"
+ wait_osc_import_state mds ost DISCONN
+
+ lazystatfs $MOUNT || error "lazystatfs should don't have returned EIO"
+
+ umount_client $MOUNT || error "Unable to unmount client"
+ stop_mds || error "Unable to stop MDS"
+}
+run_test 50b "lazystatfs all servers down =========================="
+
+test_50c() {
+ start_mds || error "Unable to start MDS"
+ start_ost || error "Unable to start OST1"
+ start_ost2 || error "Unable to start OST2"
+ mount_client $MOUNT || error "Unable to mount client"
+ lctl set_param llite.$FSNAME-*.lazystatfs=1
+ touch $DIR/$tfile
+
+ # Wait for client to detect down OST
+ stop_ost || error "Unable to stop OST1"
+ wait_osc_import_state mds ost DISCONN
+ lazystatfs $MOUNT || error "lazystatfs failed with one down server"
+
+ umount_client $MOUNT || error "Unable to unmount client"
+ stop_ost2 || error "Unable to stop OST2"
+ stop_mds || error "Unable to stop MDS"
+}
+run_test 50c "lazystatfs one server down =========================="
+
+test_50d() {
+ start_mds || error "Unable to start MDS"
+ start_ost || error "Unable to start OST1"
+ start_ost2 || error "Unable to start OST2"
+ mount_client $MOUNT || error "Unable to mount client"
+ lctl set_param llite.$FSNAME-*.lazystatfs=1
+ touch $DIR/$tfile
+
+ # Issue the statfs during the window where the client still
+ # belives the OST to be available but it is in fact down.
+ # No failure just a statfs which hangs for a timeout interval.
+ stop_ost || error "Unable to stop OST1"
+ lazystatfs $MOUNT || error "lazystatfs failed with one down server"
+
+ umount_client $MOUNT || error "Unable to unmount client"
+ stop_ost2 || error "Unable to stop OST2"
+ stop_mds || error "Unable to stop MDS"
+}
+run_test 50d "lazystatfs client/server conn race =========================="
+
+test_50e() {
+ local RC1
+ local pid
+
+ reformat_and_config
+ start_mds || return 1
+ #first client should see only one ost
+ start_ost || return 2
+ wait_osc_import_state mds ost FULL
+
+ # Wait for client to detect down OST
+ stop_ost || error "Unable to stop OST1"
+ wait_osc_import_state mds ost DISCONN
+
+ mount_client $MOUNT || error "Unable to mount client"
+ lctl set_param llite.$FSNAME-*.lazystatfs=0
+
+ multiop_bg_pause $MOUNT _f
+ RC1=$?
+ pid=$!
+
+ if [ $RC1 -ne 0 ]; then
+ log "multiop failed $RC1"
+ else
+ kill -USR1 $pid
+ sleep $(( $TIMEOUT+1 ))
+ kill -0 $pid
+ [ $? -ne 0 ] && error "process isn't sleep"
+ start_ost || error "Unable to start OST1"
+ wait $pid || error "statfs failed"
+ fi
+
+ umount_client $MOUNT || error "Unable to unmount client"
+ stop_ost || error "Unable to stop OST1"
+ stop_mds || error "Unable to stop MDS"
+}
+run_test 50e "normal statfs all servers down =========================="
+
+test_50f() {
+ local RC1
+ local pid
+ CONN_PROC="osc.$FSNAME-OST0001-osc-[M]*.ost_server_uuid"
+
+ start_mds || error "Unable to start mds"
+ #first client should see only one ost
+ start_ost || error "Unable to start OST1"
+ wait_osc_import_state mds ost FULL
+
+ start_ost2 || error "Unable to start OST2"
+ wait_osc_import_state mds ost2 FULL
+
+ # Wait for client to detect down OST
+ stop_ost2 || error "Unable to stop OST2"
+
+ wait_osc_import_state mds ost2 DISCONN
+ mount_client $MOUNT || error "Unable to mount client"
+ lctl set_param llite.$FSNAME-*.lazystatfs=0
+
+ multiop_bg_pause $MOUNT _f
+ RC1=$?
+ pid=$!
+
+ if [ $RC1 -ne 0 ]; then
+ log "lazystatfs multiop failed $RC1"
+ else
+ kill -USR1 $pid
+ sleep $(( $TIMEOUT+1 ))
+ kill -0 $pid
+ [ $? -ne 0 ] && error "process isn't sleep"
+ start_ost2 || error "Unable to start OST2"
+ wait $pid || error "statfs failed"
+ stop_ost2 || error "Unable to stop OST2"
+ fi
+
+ umount_client $MOUNT || error "Unable to unmount client"
+ stop_ost || error "Unable to stop OST1"
+ stop_mds || error "Unable to stop MDS"
+ #writeconf to remove all ost2 traces for subsequent tests
+ writeconf
+}
+run_test 50f "normal statfs one server in down =========================="
+
+test_50g() {
+ [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2, skipping" && return
+ setup
+ start_ost2 || error "Unable to start OST2"
+ wait_osc_import_state mds ost2 FULL
+ wait_osc_import_state client ost2 FULL
+
+ local PARAM="${FSNAME}-OST0001.osc.active"
+
+ $LFS setstripe -c -1 $DIR/$tfile || error "Unable to lfs setstripe"
+ do_facet mgs $LCTL conf_param $PARAM=0 || error "Unable to deactivate OST"
+
+ umount_client $MOUNT || error "Unable to unmount client"
+ mount_client $MOUNT || error "Unable to mount client"
+ # This df should not cause a panic
+ df -k $MOUNT
+
+ do_facet mgs $LCTL conf_param $PARAM=1 || error "Unable to activate OST"
+ rm -f $DIR/$tfile
+ umount_client $MOUNT || error "Unable to unmount client"
+ stop_ost2 || error "Unable to stop OST2"
+ stop_ost || error "Unable to stop OST1"
+ stop_mds || error "Unable to stop MDS"
+ #writeconf to remove all ost2 traces for subsequent tests
+ writeconf
+}
+run_test 50g "deactivated OST should not cause panic====================="
+
+test_51() {
+ local LOCAL_TIMEOUT=20
+
+ reformat
+ setup_noconfig
+ check_mount || return 1
+
+ mkdir $MOUNT/d1
+ $LFS setstripe -c -1 $MOUNT/d1
+ #define OBD_FAIL_MDS_REINT_DELAY 0x142
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x142"
+ touch $MOUNT/d1/f1 &
+ local pid=$!
+ sleep 2
+ start_ost2 || return 2
+ wait $pid
+ stop_ost2 || return 3
+ cleanup
+}
+run_test 51 "Verify that mdt_reint handles RMF_MDT_MD correctly when an OST is added"
+
+copy_files_xattrs()
+{
+ local node=$1
+ local dest=$2
+ local xattrs=$3
+ shift 3
+
+ do_node $node mkdir -p $dest
+ [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
+
+ do_node $node 'tar cf - '$@' | tar xf - -C '$dest';
+ [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
+ [ $? -eq 0 ] || { error "Unable to tar files"; return 2; }
+
+ do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs
+ [ $? -eq 0 ] || { error "Unable to read xattrs"; return 3; }
+}
+
+diff_files_xattrs()
+{
+ local node=$1
+ local backup=$2
+ local xattrs=$3
+ shift 3
+
+ local backup2=${TMP}/backup2
+
+ do_node $node mkdir -p $backup2
+ [ $? -eq 0 ] || { error "Unable to create directory"; return 1; }
+
+ do_node $node 'tar cf - '$@' | tar xf - -C '$backup2';
+ [ \"\${PIPESTATUS[*]}\" = \"0 0\" ] || exit 1'
+ [ $? -eq 0 ] || { error "Unable to tar files to diff"; return 2; }
+
+ do_node $node "diff -rq $backup $backup2"
+ [ $? -eq 0 ] || { error "contents differ"; return 3; }
+
+ local xattrs2=${TMP}/xattrs2
+ do_node $node 'getfattr -d -m "[a-z]*\\." '$@' > '$xattrs2
+ [ $? -eq 0 ] || { error "Unable to read xattrs to diff"; return 4; }
+
+ do_node $node "diff $xattrs $xattrs2"
+ [ $? -eq 0 ] || { error "xattrs differ"; return 5; }
+
+ do_node $node "rm -rf $backup2 $xattrs2"
+ [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 6; }
+}
+
+test_52() {
+ start_mds
+ [ $? -eq 0 ] || { error "Unable to start MDS"; return 1; }
+ start_ost
+ [ $? -eq 0 ] || { error "Unable to start OST1"; return 2; }
+ mount_client $MOUNT
+ [ $? -eq 0 ] || { error "Unable to mount client"; return 3; }
+
+ local nrfiles=8
+ local ost1mnt=${MOUNT%/*}/ost1
+ local ost1node=$(facet_active_host ost1)
+ local ost1tmp=$TMP/conf52
+
+ mkdir -p $DIR/$tdir
+ [ $? -eq 0 ] || { error "Unable to create tdir"; return 4; }
+ touch $TMP/modified_first
+ [ $? -eq 0 ] || { error "Unable to create temporary file"; return 5; }
+ local mtime=$(stat -c %Y $TMP/modified_first)
+ do_node $ost1node "mkdir -p $ost1tmp && touch -m -d @$mtime $ost1tmp/modified_first"
+
+ [ $? -eq 0 ] || { error "Unable to create temporary file"; return 6; }
+ sleep 1
+
+ $LFS setstripe $DIR/$tdir -c -1 -s 1M
+ [ $? -eq 0 ] || { error "lfs setstripe failed"; return 7; }
+
+ for (( i=0; i < nrfiles; i++ )); do
+ multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c
+ [ $? -eq 0 ] || { error "multiop failed"; return 8; }
+ echo -n .
+ done
+ echo
+
+ # backup files
+ echo backup files to $TMP/files
+ local files=$(find $DIR/$tdir -type f -newer $TMP/modified_first)
+ copy_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
+ [ $? -eq 0 ] || { error "Unable to copy files"; return 9; }
+
+ umount_client $MOUNT
+ [ $? -eq 0 ] || { error "Unable to umount client"; return 10; }
+ stop_ost
+ [ $? -eq 0 ] || { error "Unable to stop ost1"; return 11; }
+
+ echo mount ost1 as ldiskfs
+ do_node $ost1node mount -t $FSTYPE $ost1_dev $ost1mnt $OST_MOUNT_OPTS
+ [ $? -eq 0 ] || { error "Unable to mount ost1 as ldiskfs"; return 12; }
+
+ # backup objects
+ echo backup objects to $ost1tmp/objects
+ local objects=$(do_node $ost1node 'find '$ost1mnt'/O/0 -type f -size +0'\
+ '-newer '$ost1tmp'/modified_first -regex ".*\/[0-9]+"')
+ copy_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
+ [ $? -eq 0 ] || { error "Unable to copy objects"; return 13; }
+
+ # move objects to lost+found
+ do_node $ost1node 'mv '$objects' '${ost1mnt}'/lost+found'
+ [ $? -eq 0 ] || { error "Unable to move objects"; return 14; }
+
+ # recover objects
+ do_node $ost1node "ll_recover_lost_found_objs -d $ost1mnt/lost+found"
+ [ $? -eq 0 ] || { error "ll_recover_lost_found_objs failed"; return 15; }
+
+ # compare restored objects against saved ones
+ diff_files_xattrs $ost1node $ost1tmp/objects $ost1tmp/object_xattrs $objects
+ [ $? -eq 0 ] || { error "Unable to diff objects"; return 16; }
+
+ do_node $ost1node "umount $ost1_dev"
+ [ $? -eq 0 ] || { error "Unable to umount ost1 as ldiskfs"; return 17; }
+
+ start_ost
+ [ $? -eq 0 ] || { error "Unable to start ost1"; return 18; }
+ mount_client $MOUNT
+ [ $? -eq 0 ] || { error "Unable to mount client"; return 19; }
+
+ # compare files
+ diff_files_xattrs `hostname` $TMP/files $TMP/file_xattrs $files
+ [ $? -eq 0 ] || { error "Unable to diff files"; return 20; }
+
+ rm -rf $TMP/files $TMP/file_xattrs
+ [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 21; }
+ do_node $ost1node "rm -rf $ost1tmp"
+ [ $? -eq 0 ] || { error "Unable to delete temporary files"; return 22; }
+ cleanup
+}
+run_test 52 "check recovering objects from lost+found"
+
+# Checks threads_min/max/started for some service
+#
+# Arguments: service name (OST or MDT), facet (e.g., ost1, $SINGLEMDS), and a
+# parameter pattern prefix like 'ost.*.ost'.
+thread_sanity() {
+ local modname=$1
+ local facet=$2
+ local parampat=$3
+ local opts=$4
+ local tmin
+ local tmin2
+ local tmax
+ local tmax2
+ local tstarted
+ local paramp
+ local msg="Insane $modname thread counts"
+ shift 4
+
+ setup
+ check_mount || return 41
+
+ # We need to expand $parampat, but it may match multiple parameters, so
+ # we'll pick the first one
+ if ! paramp=$(do_facet $facet "lctl get_param -N ${parampat}.threads_min"|head -1); then
+ error "Couldn't expand ${parampat}.threads_min parameter name"
+ return 22
+ fi
+
+ # Remove the .threads_min part
+ paramp=${paramp%.threads_min}
+
+ # Check for sanity in defaults
+ tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
+ tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
+ tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started" || echo 0)
+ lassert 23 "$msg (PDSH problems?)" '(($tstarted && $tmin && $tmax))' || return $?
+ lassert 24 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' || return $?
+
+ # Check that we can lower min/max
+ do_facet $facet "lctl set_param ${paramp}.threads_min=$((tmin - 1))"
+ do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmax - 1))"
+ tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
+ tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
+ lassert 25 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmax -1)))' || return $?
+
+ # Check that we can set min/max to the same value
+ do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 1))"
+ tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
+ tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
+ lassert 26 "$msg" '(($tmin2 == ($tmin - 1) && $tmax2 == ($tmin - 1)))' || return $?
+
+ # Check that we can't set max < min
+ do_facet $facet "lctl set_param ${paramp}.threads_max=$((tmin - 2))"
+ tmin2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min" || echo 0)
+ tmax2=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max" || echo 0)
+ lassert 27 "$msg" '(($tmin2 <= $tmax2))' || return $?
+
+ # We need to ensure that we get the module options desired; to do this
+ # we set LOAD_MODULES_REMOTE=true and we call setmodopts below.
+ LOAD_MODULES_REMOTE=true
+ cleanup
+ local oldvalue
+ setmodopts -a $modname "$opts" oldvalue
+
+ load_modules
+ setup
+ check_mount || return 41
+
+ # Restore previous setting of MODOPTS_*
+ setmodopts $modname "$oldvalue"
+
+ # Check that $opts took
+ tmin=$(do_facet $facet "lctl get_param -n ${paramp}.threads_min")
+ tmax=$(do_facet $facet "lctl get_param -n ${paramp}.threads_max")
+ tstarted=$(do_facet $facet "lctl get_param -n ${paramp}.threads_started")
+ lassert 28 "$msg" '(($tstarted == $tmin && $tstarted == $tmax ))' || return $?
+ cleanup
+
+ # Workaround a YALA bug where YALA expects that modules will remain
+ # loaded on the servers
+ LOAD_MODULES_REMOTE=false
+ load_modules
+ setup
+ cleanup
+}
+
+test_53a() {
+ thread_sanity OST ost1 'ost.*.ost' 'oss_num_threads=64'
+}
+run_test 53a "check OSS thread count params"
+
+test_53b() {
+ thread_sanity MDT $SINGLEMDS 'mdt.*.*.' 'mdt_num_threads=64'
+}
+run_test 53b "check MDT thread count params"
+
+run_llverfs()
+{
+ local dir=$1
+ local partial_arg=""
+ local size=$(df -B G $dir | tail -1 | awk '{print $2}' | sed 's/G//') # Gb
+
+ # Run in partial (fast) mode if the size
+ # of a partition > 10 GB
+ [ $size -gt 10 ] && partial_arg="-p"
+
+ llverfs $partial_arg $dir
+}
+
+test_54a() {
+ do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1)
+ [ $? -eq 0 ] || error "llverdev failed!"
+ reformat_and_config
+}
+run_test 54a "llverdev"
+
+test_54b() {
+ setup
+ run_llverfs $MOUNT
+ [ $? -eq 0 ] || error "llverfs failed!"
+ cleanup
+}
+run_test 54b "llverfs"
+
+lov_objid_size()
+{
+ local max_ost_index=$1
+ echo -n $(((max_ost_index + 1) * 8))
+}
+
+test_55() {
+ local mdsdev=$(mdsdevname 1)
+ local ostdev=$(ostdevname 1)
+ local saved_opts=$OST_MKFS_OPTS
+
+ for i in 0 1023 2048
+ do
+ OST_MKFS_OPTS="$saved_opts --index $i"
+ reformat
+
+ setup_noconfig
+ stopall
+
+ setup
+ sync
+ echo checking size of lov_objid for ost index $i
+ LOV_OBJID_SIZE=$(do_facet mds1 "$DEBUGFS -R 'stat lov_objid' $mdsdev 2>/dev/null" | grep ^User | awk '{print $6}')
+ if [ "$LOV_OBJID_SIZE" != $(lov_objid_size $i) ]; then
+ error "lov_objid size has to be $(lov_objid_size $i), not $LOV_OBJID_SIZE"
+ else
+ echo ok, lov_objid size is correct: $LOV_OBJID_SIZE
+ fi
+ stopall
+ done
+
+ OST_MKFS_OPTS=$saved_opts
+ reformat
+}
+run_test 55 "check lov_objid size"
+
+test_56() {
+ add mds1 $MDS_MKFS_OPTS --mkfsoptions='\"-J size=16\"' --reformat $(mdsdevname 1)
+ add ost1 $OST_MKFS_OPTS --index=1000 --reformat $(ostdevname 1)
+ add ost2 $OST_MKFS_OPTS --index=10000 --reformat $(ostdevname 2)
+
+ start_mds
+ start_ost
+ start_ost2 || error "Unable to start second ost"
+ mount_client $MOUNT || error "Unable to mount client"
+ echo ok
+ $LFS osts
+ [ -n "$ENABLE_QUOTA" ] && { $LFS quotacheck -ug $MOUNT || error "quotacheck has failed" ; }
+ stopall
+ reformat
+}
+run_test 56 "check big indexes"
+
+test_57() { # bug 22656
+ local NID=$(do_facet ost1 "$LCTL get_param nis" | tail -1 | awk '{print $1}')
+ writeconf
+ do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" || error "tunefs failed"
+ start_mgsmds
+ start_ost && error "OST registration from failnode should fail"
+ stop_mds
+ reformat
+}
+run_test 57 "initial registration from failnode should fail (should return errs)"
+
+count_osts() {
+ do_facet mgs $LCTL get_param mgs.MGS.live.$FSNAME | grep OST | wc -l
+}
+
+test_59() {
+ start_mgsmds >> /dev/null
+ local C1=$(count_osts)
+ if [ $C1 -eq 0 ]; then
+ start_ost >> /dev/null
+ C1=$(count_osts)
+ fi
+ stopall
+ echo "original ost count: $C1 (expect > 0)"
+ [ $C1 -gt 0 ] || error "No OSTs in $FSNAME log"
+ start_mgsmds -o writeconf >> /dev/null || error "MDT start failed"
+ local C2=$(count_osts)
+ echo "after mdt writeconf count: $C2 (expect 0)"
+ [ $C2 -gt 0 ] && error "MDT writeconf should erase OST logs"
+ echo "OST start without writeconf should fail:"
+ start_ost >> /dev/null && error "OST start without writeconf didn't fail"
+ echo "OST start with writeconf should succeed:"
+ start_ost -o writeconf >> /dev/null || error "OST1 start failed"
+ local C3=$(count_osts)
+ echo "after ost writeconf count: $C3 (expect 1)"
+ [ $C3 -eq 1 ] || error "new OST writeconf should add:"
+ start_ost2 -o writeconf >> /dev/null || error "OST2 start failed"
+ local C4=$(count_osts)
+ echo "after ost2 writeconf count: $C4 (expect 2)"
+ [ $C4 -eq 2 ] || error "OST2 writeconf should add log"
+ stop_ost2 >> /dev/null
+ cleanup_nocli >> /dev/null
+}
+run_test 59 "writeconf mount option"
+
+
+test_58() { # bug 22658
+ [ "$FSTYPE" != "ldiskfs" ] && skip "not supported for $FSTYPE" && return
+ setup
+ mkdir -p $DIR/$tdir
+ createmany -o $DIR/$tdir/$tfile-%d 100
+ # make sure that OSTs do not cancel llog cookies before we unmount the MDS
+#define OBD_FAIL_OBD_LOG_CANCEL_NET 0x601
+ do_facet mds "lctl set_param fail_loc=0x601"
+ unlinkmany $DIR/$tdir/$tfile-%d 100
+ stop mds
+ local MNTDIR=$(facet_mntpt mds)
+ # remove all files from the OBJECTS dir
+ do_facet mds "mount -t ldiskfs $MDSDEV $MNTDIR"
+ do_facet mds "find $MNTDIR/OBJECTS -type f -delete"
+ do_facet mds "umount $MNTDIR"
+ # restart MDS with missing llog files
+ start_mds
+ do_facet mds "lctl set_param fail_loc=0"
+ reformat
+}
+run_test 58 "missing llog files must not prevent MDT from mounting"
+
+if ! combined_mgs_mds ; then
+ stop mgs
+fi
+