+test_65() { # LU-2237
+ # Currently, the test is only valid for ldiskfs backend
+ [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
+ skip "non-ldiskfs backend" && return
+
+ local devname=$(mdsdevname ${SINGLEMDS//mds/})
+ local brpt=$(facet_mntpt brpt)
+ local opts=""
+
+ if ! do_facet $SINGLEMDS "test -b $devname"; then
+ opts="-o loop"
+ fi
+
+ stop_mds || error "Unable to stop MDS"
+ local obj=$(do_facet $SINGLEMDS \
+ "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" |
+ grep Inode)
+ if [ -z "$obj" ]; then
+ # The MDT may be just re-formatted, mount the MDT for the
+ # first time to guarantee the "last_rcvd" file is there.
+ start_mds || error "fail to mount the MDS for the first time"
+ stop_mds || error "Unable to stop MDS"
+ fi
+
+ # remove the "last_rcvd" file
+ do_facet $SINGLEMDS "mkdir -p $brpt"
+ do_facet $SINGLEMDS \
+ "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
+ do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
+ do_facet $SINGLEMDS "umount -d $brpt"
+
+ # restart MDS, the "last_rcvd" file should be recreated.
+ start_mds || error "fail to restart the MDS"
+ stop_mds || error "Unable to stop MDS"
+ obj=$(do_facet $SINGLEMDS \
+ "$DEBUGFS -c -R \\\"stat last_rcvd\\\" $devname" | grep Inode)
+ [ -n "$obj" ] || error "fail to re-create the last_rcvd"
+}
+run_test 65 "re-create the lost last_rcvd file when server mount"
+
+test_66() {
+ [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
+ { skip "Need MGS version at least 2.3.59"; return 0; }
+
+ setup
+ local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
+ local MDS_NID=$(do_facet $SINGLEMDS $LCTL list_nids | head -1)
+
+ echo "replace_nids should fail if MDS, OSTs and clients are UP"
+ do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
+ error "replace_nids fail"
+
+ umount_client $MOUNT || error "unmounting client failed"
+ echo "replace_nids should fail if MDS and OSTs are UP"
+ do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
+ error "replace_nids fail"
+
+ stop_ost || error "Unable to stop OST1"
+ echo "replace_nids should fail if MDS is UP"
+ do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID &&
+ error "replace_nids fail"
+
+ stop_mds || error "stopping mds failed"
+
+ if combined_mgs_mds; then
+ start_mdt 1 "-o nosvc" ||
+ error "starting mds with nosvc option failed"
+ fi
+
+ echo "command should accept two parameters"
+ do_facet mgs $LCTL replace_nids $FSNAME-OST0000 &&
+ error "command should accept two params"
+
+ echo "correct device name should be passed"
+ do_facet mgs $LCTL replace_nids $FSNAME-WRONG0000 $OST1_NID &&
+ error "wrong devname"
+
+ echo "wrong nids list should not destroy the system"
+ do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
+ error "wrong parse"
+
+ echo "replace OST nid"
+ do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
+ error "replace nids failed"
+
+ echo "command should accept two parameters"
+ do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 &&
+ error "command should accept two params"
+
+ echo "wrong nids list should not destroy the system"
+ do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
+ error "wrong parse"
+
+ echo "replace MDS nid"
+ do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
+ error "replace nids failed"
+
+ if ! combined_mgs_mds ; then
+ stop_mgs
+ else
+ stop_mds || error "Unable to stop MDS"
+ fi
+
+ setup_noconfig
+ check_mount || error "error after nid replace"
+ cleanup || error "cleanup failed"
+ reformat
+}
+run_test 66 "replace nids"
+
+test_67() { #LU-2950
+ local legacy="$TMP/legacy_lnet_config"
+ local new="$TMP/new_routes_test"
+ local out="$TMP/config_out_file"
+ local verify="$TMP/conv_verify"
+ local verify_conf="$TMP/conf_verify"
+
+ # Create the legacy file that will be run through the
+ # lustre_routes_conversion script
+ cat <<- LEGACY_LNET_CONFIG > $legacy
+ tcp1 23 192.168.213.1@tcp:1; tcp5 34 193.30.4.3@tcp:4;
+ tcp2 54 10.1.3.2@tcp;
+ tcp3 10.3.4.3@tcp:3;
+ tcp4 10.3.3.4@tcp;
+ LEGACY_LNET_CONFIG
+
+ # Create the verification file to verify the output of
+ # lustre_routes_conversion script against.
+ cat <<- VERIFY_LNET_CONFIG > $verify
+ tcp1: { gateway: 192.168.213.1@tcp, hop: 23, priority: 1 }
+ tcp5: { gateway: 193.30.4.3@tcp, hop: 34, priority: 4 }
+ tcp2: { gateway: 10.1.3.2@tcp, hop: 54 }
+ tcp3: { gateway: 10.3.4.3@tcp, priority: 3 }
+ tcp4: { gateway: 10.3.3.4@tcp }
+ VERIFY_LNET_CONFIG
+
+ # Create the verification file to verify the output of
+ # lustre_routes_config script against
+ cat <<- VERIFY_LNET_CONFIG > $verify_conf
+ lctl --net tcp1 add_route 192.168.213.1@tcp 23 1
+ lctl --net tcp5 add_route 193.30.4.3@tcp 34 4
+ lctl --net tcp2 add_route 10.1.3.2@tcp 54 4
+ lctl --net tcp3 add_route 10.3.4.3@tcp 1 3
+ lctl --net tcp4 add_route 10.3.3.4@tcp 1 3
+ VERIFY_LNET_CONFIG
+
+ lustre_routes_conversion $legacy $new > /dev/null
+ if [ -f $new ]; then
+ # verify the conversion output
+ cmp -s $new $verify > /dev/null
+ if [ $? -eq 1 ]; then
+ error "routes conversion failed"
+ fi
+
+ lustre_routes_config --dry-run --verbose $new > $out
+ # check that the script succeeded
+ cmp -s $out $verify_conf > /dev/null
+ if [ $? -eq 1 ]; then
+ error "routes config failed"
+ fi
+ else
+ error "routes conversion test failed"
+ fi
+ # remove generated files
+ rm -f $new $legacy $verify $verify_conf $out
+}
+run_test 67 "test routes conversion and configuration"
+
+test_68() {
+ local fid
+ local seq
+ local START
+ local END
+
+ [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
+ { skip "Need MDS version at least 2.4.53"; return 0; }
+
+ umount_client $MOUNT || error "umount client failed"
+
+ start_mdt 1 || error "MDT start failed"
+ start_ost || error "Unable to start OST1"
+
+ # START-END - the sequences we'll be reserving
+ START=$(do_facet $SINGLEMDS \
+ $LCTL get_param -n seq.ctl*.space | awk -F'[[ ]' '{print $2}')
+ END=$((START + (1 << 30)))
+ do_facet $SINGLEMDS \
+ $LCTL set_param seq.ctl*.fldb="[$START-$END\):0:mdt"
+
+ # reset the sequences MDT0000 has already assigned
+ do_facet $SINGLEMDS \
+ $LCTL set_param seq.srv*MDT0000.space=clear
+
+ # remount to let the client allocate new sequence
+ mount_client $MOUNT || error "mount client failed"
+
+ touch $DIR/$tfile || error "touch $DIR/$tfile failed"
+ do_facet $SINGLEMDS \
+ $LCTL get_param seq.srv*MDT0000.space
+ $LFS path2fid $DIR/$tfile
+
+ local old_ifs="$IFS"
+ IFS='[:]'
+ fid=($($LFS path2fid $DIR/$tfile))
+ IFS="$old_ifs"
+ let seq=${fid[1]}
+
+ if [[ $seq < $END ]]; then
+ error "used reserved sequence $seq?"
+ fi
+ cleanup || error "cleanup failed with $?"
+}
+run_test 68 "be able to reserve specific sequences in FLDB"
+
+test_69() {
+ local server_version=$(lustre_version_code $SINGLEMDS)
+
+ [[ $server_version -lt $(version_code 2.4.2) ]] &&
+ skip "Need MDS version at least 2.4.2" && return
+
+ [[ $server_version -ge $(version_code 2.4.50) ]] &&
+ [[ $server_version -lt $(version_code 2.5.0) ]] &&
+ skip "Need MDS version at least 2.5.0" && return
+
+ setup
+
+ # use OST0000 since it probably has the most creations
+ local OSTNAME=$(ostname_from_index 0)
+ local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
+ local last_id=$(do_facet mds1 $LCTL get_param -n \
+ osc.$mdtosc_proc1.prealloc_last_id)
+
+ # Want to have OST LAST_ID over 1.5 * OST_MAX_PRECREATE to
+ # verify that the LAST_ID recovery is working properly. If
+ # not, then the OST will refuse to allow the MDS connect
+ # because the LAST_ID value is too different from the MDS
+ #define OST_MAX_PRECREATE=20000
+ local num_create=$((20000 * 5))
+
+ mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+ $SETSTRIPE -i 0 $DIR/$tdir || error "$SETSTRIPE -i 0 $DIR/$tdir failed"
+ createmany -o $DIR/$tdir/$tfile- $num_create ||
+ error "createmany: failed to create $num_create files: $?"
+ # delete all of the files with objects on OST0 so the
+ # filesystem is not inconsistent later on
+ $LFS find $MOUNT --ost 0 | xargs rm
+
+ stop_ost || error "OST0 stop failure"
+ add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat --replace \
+ $(ostdevname 1) $(ostvdevname 1) ||
+ error "reformat and replace $ostdev failed"
+ start_ost || error "OST0 restart failure"
+ wait_osc_import_state mds ost FULL
+
+ touch $DIR/$tdir/$tfile-last || error "create file after reformat"
+ local idx=$($GETSTRIPE -i $DIR/$tdir/$tfile-last)
+ [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
+
+ cleanup || error "cleanup failed with $?"
+}
+run_test 69 "replace an OST with the same index"
+
+test_70a() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local MDTIDX=1
+
+ cleanup || error "cleanup failed with $?"
+
+ start_mdt 1 || error "MDT0 start fail"
+
+ start_ost || error "OST0 start fail"
+
+ start_mdt 2 || error "MDT1 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+
+ mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
+
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
+ error "create remote dir fail"
+
+ rm -rf $DIR/$tdir || error "delete dir fail"
+ cleanup || error "cleanup failed with $?"
+}
+run_test 70a "start MDT0, then OST, then MDT1"
+
+test_70b() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local MDTIDX=1
+
+ start_ost || error "OST0 start fail"
+
+ start_mdt 1 || error "MDT0 start fail"
+ start_mdt 2 || error "MDT1 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+
+ mkdir $DIR/$tdir || error "create $DIR/$tdir failed"
+
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
+ error "create remote dir fail"
+
+ rm -rf $DIR/$tdir || error "delete dir fail"
+
+ cleanup || error "cleanup failed with $?"
+}
+run_test 70b "start OST, MDT1, MDT0"
+
+test_70c() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local MDTIDX=1
+
+ start_mdt 1 || error "MDT0 start fail"
+ start_mdt 2 || error "MDT1 start fail"
+ start_ost || error "OST0 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+ stop_mdt 1 || error "MDT1 start fail"
+
+ local mdc_for_mdt1=$($LCTL dl | grep MDT0000-mdc | awk '{print $4}')
+ echo "deactivate $mdc_for_mdt1"
+ $LCTL --device $mdc_for_mdt1 deactivate ||
+ error "set $mdc_for_mdt1 deactivate failed"
+
+ mkdir $DIR/$tdir && error "mkdir succeed"
+
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
+ error "create remote dir succeed"
+
+ cleanup || error "cleanup failed with $?"
+}
+run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
+
+test_70d() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ local MDTIDX=1
+
+ start_mdt 1 || error "MDT0 start fail"
+ start_mdt 2 || error "MDT1 start fail"
+ start_ost || error "OST0 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+
+ stop_mdt 2 || error "MDT1 start fail"
+
+ local mdc_for_mdt2=$($LCTL dl | grep MDT0001-mdc |
+ awk '{print $4}')
+ echo "deactivate $mdc_for_mdt2"
+ $LCTL --device $mdc_for_mdt2 deactivate ||
+ error "set $mdc_for_mdt2 deactivate failed"
+
+ mkdir $DIR/$tdir || error "mkdir fail"
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir &&
+ error "create remote dir succeed"
+
+ rm -rf $DIR/$tdir || error "delete dir fail"
+
+ cleanup || error "cleanup failed with $?"
+}
+run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
+
+test_71a() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ if combined_mgs_mds; then
+ skip "needs separate MGS/MDT" && return
+ fi
+ local MDTIDX=1
+
+ start_mdt 1 || error "MDT0 start fail"
+ start_ost || error "OST0 start fail"
+ start_mdt 2 || error "MDT1 start fail"
+ start_ost2 || error "OST1 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+
+ mkdir $DIR/$tdir || error "mkdir fail"
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
+ error "create remote dir succeed"
+
+ mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
+ rm -rf $DIR/$tdir || error "delete dir fail"
+
+ umount_client $MOUNT || error "umount_client failed"
+ stop_mdt 1 || error "MDT0 stop fail"
+ stop_mdt 2 || error "MDT1 stop fail"
+ stop_ost || error "OST0 stop fail"
+ stop_ost2 || error "OST1 stop fail"
+}
+run_test 71a "start MDT0 OST0, MDT1, OST1"
+
+test_71b() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ if combined_mgs_mds; then
+ skip "needs separate MGS/MDT" && return
+ fi
+ local MDTIDX=1
+
+ start_mdt 2 || error "MDT1 start fail"
+ start_ost || error "OST0 start fail"
+ start_mdt 1 || error "MDT0 start fail"
+ start_ost2 || error "OST1 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+
+ mkdir $DIR/$tdir || error "mkdir fail"
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
+ error "create remote dir succeed"
+
+ mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
+ rm -rf $DIR/$tdir || error "delete dir fail"
+
+ umount_client $MOUNT || error "umount_client failed"
+ stop_mdt 1 || error "MDT0 stop fail"
+ stop_mdt 2 || error "MDT1 stop fail"
+ stop_ost || error "OST0 stop fail"
+ stop_ost2 || error "OST1 stop fail"
+}
+run_test 71b "start MDT1, OST0, MDT0, OST1"
+
+test_71c() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ if combined_mgs_mds; then
+ skip "needs separate MGS/MDT" && return
+ fi
+ local MDTIDX=1
+
+ start_ost || error "OST0 start fail"
+ start_ost2 || error "OST1 start fail"
+ start_mdt 2 || error "MDT1 start fail"
+ start_mdt 1 || error "MDT0 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+
+ mkdir $DIR/$tdir || error "mkdir fail"
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
+ error "create remote dir succeed"
+
+ mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
+ rm -rf $DIR/$tdir || error "delete dir fail"
+
+ umount_client $MOUNT || error "umount_client failed"
+ stop_mdt 1 || error "MDT0 stop fail"
+ stop_mdt 2 || error "MDT1 stop fail"
+ stop_ost || error "OST0 stop fail"
+ stop_ost2 || error "OST1 stop fail"
+
+}
+run_test 71c "start OST0, OST1, MDT1, MDT0"
+
+test_71d() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ if combined_mgs_mds; then
+ skip "needs separate MGS/MDT" && return
+ fi
+ local MDTIDX=1
+
+ start_ost || error "OST0 start fail"
+ start_mdt 2 || error "MDT0 start fail"
+ start_mdt 1 || error "MDT0 start fail"
+ start_ost2 || error "OST1 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+
+ mkdir $DIR/$tdir || error "mkdir fail"
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
+ error "create remote dir succeed"
+
+ mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
+ rm -rf $DIR/$tdir || error "delete dir fail"
+
+ umount_client $MOUNT || error "umount_client failed"
+ stop_mdt 1 || error "MDT0 stop fail"
+ stop_mdt 2 || error "MDT1 stop fail"
+ stop_ost || error "OST0 stop fail"
+ stop_ost2 || error "OST1 stop fail"
+
+}
+run_test 71d "start OST0, MDT1, MDT0, OST1"
+
+test_71e() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+ if combined_mgs_mds; then
+ skip "needs separate MGS/MDT" && return
+ fi
+ local MDTIDX=1
+
+ start_ost || error "OST0 start fail"
+ start_mdt 2 || error "MDT1 start fail"
+ start_ost2 || error "OST1 start fail"
+ start_mdt 1 || error "MDT0 start fail"
+
+ mount_client $MOUNT || error "mount client fails"
+
+ mkdir $DIR/$tdir || error "mkdir fail"
+ $LFS mkdir -i $MDTIDX $DIR/$tdir/remote_dir ||
+ error "create remote dir succeed"
+
+ mcreate $DIR/$tdir/remote_dir/$tfile || error "create file failed"
+ rm -rf $DIR/$tdir || error "delete dir fail"
+
+ umount_client $MOUNT || error "umount_client failed"
+ stop_mdt 1 || error "MDT0 stop fail"
+ stop_mdt 2 || error "MDT1 stop fail"
+ stop_ost || error "OST0 stop fail"
+ stop_ost2 || error "OST1 stop fail"
+
+}
+run_test 71e "start OST0, MDT1, OST1, MDT0"
+
+test_72() { #LU-2634
+ local mdsdev=$(mdsdevname 1)
+ local ostdev=$(ostdevname 1)
+ local cmd="$E2FSCK -fnvd $mdsdev"
+ local fn=3
+
+ [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
+ skip "ldiskfs only test" && return
+
+ #tune MDT with "-O extents"
+
+ for num in $(seq $MDSCOUNT); do
+ add mds${num} $(mkfs_opts mds$num $(mdsdevname $num)) \
+ --reformat $(mdsdevname $num) $(mdsvdevname $num) ||
+ error "add mds $num failed"
+ $TUNE2FS -O extents $(mdsdevname $num)
+ done
+
+ add ost1 $(mkfs_opts ost1 $ostdev) --reformat $ostdev ||
+ error "add $ostdev failed"
+ start_mgsmds || error "start mds failed"
+ start_ost || error "start ost failed"
+ mount_client $MOUNT || error "mount client failed"
+
+ #create some short symlinks
+ mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+ createmany -o $DIR/$tdir/$tfile-%d $fn
+ echo "create $fn short symlinks"
+ for i in $(seq -w 1 $fn); do
+ ln -s $DIR/$tdir/$tfile-$i $MOUNT/$tfile-$i
+ done
+ ls -al $MOUNT
+
+ #umount
+ umount_client $MOUNT || error "umount client failed"
+ stop_mds || error "stop mds failed"
+ stop_ost || error "stop ost failed"
+
+ #run e2fsck
+ run_e2fsck $(facet_active_host $SINGLEMDS) $mdsdev "-n"
+}
+run_test 72 "test fast symlink with extents flag enabled"
+
+test_73() { #LU-3006
+ load_modules
+ [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
+ do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
+ error "1st tunefs failed"
+ start_mgsmds || error "start mds failed"
+ start_ost || error "start ost failed"
+ mount_client $MOUNT || error "mount client failed"
+ $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
+ grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
+ umount_client $MOUNT || error "umount client failed"
+ stopall
+ reformat
+}
+run_test 73 "failnode to update from mountdata properly"
+
+test_75() { # LU-2374
+ [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
+ skip "Need MDS version at least 2.4.1" && return
+
+ local index=0
+ local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
+ --reformat $(mdsdevname 1) $(mdsvdevname 1)"
+ local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
+ --reformat $(ostdevname 1) $(ostvdevname 1)"
+
+ #check with default parameters
+ add mds1 $opts_mds || error "add mds1 failed for default params"
+ add ost1 $opts_ost || error "add ost1 failed for default params"
+
+ opts_mds=$(echo $opts_mds | sed -e "s/--mdt//")
+ opts_mds=$(echo $opts_mds |
+ sed -e "s/--index=$index/--index=$index --mdt/")
+ opts_ost=$(echo $opts_ost | sed -e "s/--ost//")
+ opts_ost=$(echo $opts_ost |
+ sed -e "s/--index=$index/--index=$index --ost/")
+
+ add mds1 $opts_mds || error "add mds1 failed for new params"
+ add ost1 $opts_ost || error "add ost1 failed for new params"
+ return 0
+}
+run_test 75 "The order of --index should be irrelevant"
+
+test_76a() {
+ [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
+ { skip "Need MDS version at least 2.4.52" && return 0; }
+ setup
+ local MDMB_PARAM="osc.*.max_dirty_mb"
+ echo "Change MGS params"
+ local MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM |
+ head -1)
+ echo "max_dirty_mb: $MAX_DIRTY_MB"
+ local NEW_MAX_DIRTY_MB=$((MAX_DIRTY_MB + MAX_DIRTY_MB))
+ echo "new_max_dirty_mb: $NEW_MAX_DIRTY_MB"
+ do_facet mgs $LCTL set_param -P $MDMB_PARAM=$NEW_MAX_DIRTY_MB
+ wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
+ head -1" $NEW_MAX_DIRTY_MB
+ MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
+ echo "$MAX_DIRTY_MB"
+ [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
+ error "error while apply max_dirty_mb"
+
+ echo "Check the value is stored after remount"
+ stopall
+ setupall
+ wait_update $HOSTNAME "$LCTL get_param -n $MDMB_PARAM |
+ head -1" $NEW_MAX_DIRTY_MB
+ MAX_DIRTY_MB=$($LCTL get_param -n $MDMB_PARAM | head -1)
+ [ $MAX_DIRTY_MB = $NEW_MAX_DIRTY_MB ] ||
+ error "max_dirty_mb is not saved after remount"
+
+ echo "Change OST params"
+ CLIENT_PARAM="obdfilter.*.client_cache_count"
+ local CLIENT_CACHE_COUNT
+ CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
+ head -1)
+ echo "client_cache_count: $CLIENT_CACHE_COUNT"
+ NEW_CLIENT_CACHE_COUNT=$((CLIENT_CACHE_COUNT+CLIENT_CACHE_COUNT))
+ echo "new_client_cache_count: $NEW_CLIENT_CACHE_COUNT"
+ do_facet mgs $LCTL set_param -P $CLIENT_PARAM=$NEW_CLIENT_CACHE_COUNT
+ wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
+ head -1" $NEW_CLIENT_CACHE_COUNT
+ CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
+ head -1)
+ echo "$CLIENT_CACHE_COUNT"
+ [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
+ error "error while apply client_cache_count"
+
+ echo "Check the value is stored after remount"
+ stopall
+ setupall
+ wait_update $(facet_host ost1) "$LCTL get_param -n $CLIENT_PARAM |
+ head -1" $NEW_CLIENT_CACHE_COUNT
+ CLIENT_CACHE_COUNT=$(do_facet ost1 $LCTL get_param -n $CLIENT_PARAM |
+ head -1)
+ echo "$CLIENT_CACHE_COUNT"
+ [ $CLIENT_CACHE_COUNT = $NEW_CLIENT_CACHE_COUNT ] ||
+ error "client_cache_count is not saved after remount"
+ stopall
+}
+run_test 76a "set permanent params set_param -P"
+
+test_76b() { # LU-4783
+ [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
+ { skip "Need MGS version at least 2.5.57" && return 0; }
+ stopall
+ setupall
+ do_facet mgs $LCTL get_param mgs.MGS.live.params ||
+ error "start params log failed"
+ stopall
+}
+run_test 76b "verify params log setup correctly"
+
+test_77() { # LU-3445
+ local server_version=$(lustre_version_code $SINGLEMDS)
+
+ [[ $server_version -ge $(version_code 2.2.60) ]] &&
+ [[ $server_version -le $(version_code 2.4.0) ]] &&
+ skip "Need MDS version < 2.2.60 or > 2.4.0" && return
+
+ if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
+ is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
+ skip_env "mixed loopback and real device not working" && return
+ fi
+
+ local fs2mdsdev=$(mdsdevname 1_2)
+ local fs2ostdev=$(ostdevname 1_2)
+ local fs2mdsvdev=$(mdsvdevname 1_2)
+ local fs2ostvdev=$(ostvdevname 1_2)
+ local fsname=test1234
+ local mgsnid
+ local failnid="$(h2$NETTYPE 1.2.3.4),$(h2$NETTYPE 4.3.2.1)"
+
+ add fs2mds $(mkfs_opts mds1 $fs2mdsdev) --mgs --fsname=$fsname \
+ --reformat $fs2mdsdev $fs2mdsvdev || error "add fs2mds failed"
+ start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT ||
+ error "start fs2mds failed"
+
+ mgsnid=$(do_facet fs2mds $LCTL list_nids | xargs | tr ' ' ,)
+ [[ $mgsnid = *,* ]] || mgsnid+=",$mgsnid"
+
+ add fs2ost $(mkfs_opts ost1 $fs2ostdev) --mgsnode=$mgsnid \
+ --failnode=$failnid --fsname=$fsname \
+ --reformat $fs2ostdev $fs2ostvdev ||
+ error "add fs2ost failed"
+ start fs2ost $fs2ostdev $OST_MOUNT_OPTS || error "start fs2ost failed"
+
+ mkdir -p $MOUNT2 || error "mkdir $MOUNT2 failed"
+ $MOUNT_CMD $mgsnid:/$fsname $MOUNT2 || error "mount $MOUNT2 failed"
+ DIR=$MOUNT2 MOUNT=$MOUNT2 check_mount || error "check $MOUNT2 failed"
+ cleanup_fs2
+}
+run_test 77 "comma-separated MGS NIDs and failover node NIDs"
+
+test_78() {
+ [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
+ $(facet_fstype ost1) != ldiskfs ]] &&
+ skip "only applicable to ldiskfs-based MDTs and OSTs" && return
+
+ # reformat the Lustre filesystem with a smaller size
+ local saved_MDSSIZE=$MDSSIZE
+ local saved_OSTSIZE=$OSTSIZE
+ MDSSIZE=$((MDSSIZE - 20000))
+ OSTSIZE=$((OSTSIZE - 20000))
+ reformat || error "(1) reformat Lustre filesystem failed"
+ MDSSIZE=$saved_MDSSIZE
+ OSTSIZE=$saved_OSTSIZE
+
+ # mount the Lustre filesystem
+ setup_noconfig || error "(2) setup Lustre filesystem failed"
+
+ # create some files
+ log "create test files"
+ local i
+ local file
+ local num_files=100
+ mkdir $MOUNT/$tdir || error "(3) mkdir $MOUNT/$tdir failed"
+ for i in $(seq $num_files); do
+ file=$MOUNT/$tdir/$tfile-$i
+ dd if=/dev/urandom of=$file count=1 bs=1M ||
+ error "(4) create $file failed"
+ done
+
+ # unmount the Lustre filesystem
+ cleanup || error "(5) cleanup Lustre filesystem failed"
+
+ # run e2fsck on the MDT and OST devices
+ local mds_host=$(facet_active_host $SINGLEMDS)
+ local ost_host=$(facet_active_host ost1)
+ local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
+ local ost_dev=$(ostdevname 1)
+
+ run_e2fsck $mds_host $mds_dev "-y"
+ run_e2fsck $ost_host $ost_dev "-y"
+
+ # get the original block count of the MDT and OST filesystems
+ local mds_orig_blks=$(get_block_count $SINGLEMDS $mds_dev)
+ local ost_orig_blks=$(get_block_count ost1 $ost_dev)
+
+ # expand the MDT and OST filesystems to the device size
+ run_resize2fs $SINGLEMDS $mds_dev "" || error "expand $SINGLEMDS failed"
+ run_resize2fs ost1 $ost_dev "" || error "expand ost1 failed"
+
+ # run e2fsck on the MDT and OST devices again
+ run_e2fsck $mds_host $mds_dev "-y"
+ run_e2fsck $ost_host $ost_dev "-y"
+
+ # mount the Lustre filesystem
+ setup
+
+ # check the files
+ log "check files after expanding the MDT and OST filesystems"
+ for i in $(seq $num_files); do
+ file=$MOUNT/$tdir/$tfile-$i
+ $CHECKSTAT -t file -s 1048576 $file ||
+ error "(6) checkstat $file failed"
+ done
+
+ # create more files
+ log "create more files after expanding the MDT and OST filesystems"
+ for i in $(seq $((num_files + 1)) $((num_files + 10))); do
+ file=$MOUNT/$tdir/$tfile-$i
+ dd if=/dev/urandom of=$file count=1 bs=1M ||
+ error "(7) create $file failed"
+ done
+
+ # unmount the Lustre filesystem
+ cleanup || error "(8) cleanup Lustre filesystem failed"
+
+ # run e2fsck on the MDT and OST devices
+ run_e2fsck $mds_host $mds_dev "-y"
+ run_e2fsck $ost_host $ost_dev "-y"
+
+ # get the maximum block count of the MDT and OST filesystems
+ local mds_max_blks=$(get_block_count $SINGLEMDS $mds_dev)
+ local ost_max_blks=$(get_block_count ost1 $ost_dev)
+
+ # get the minimum block count of the MDT and OST filesystems
+ local mds_min_blks=$(run_resize2fs $SINGLEMDS $mds_dev "" "-P" 2>&1 |
+ grep minimum | sed -e 's/^.*filesystem: //g')
+ local ost_min_blks=$(run_resize2fs ost1 $ost_dev "" "-P" 2>&1 |
+ grep minimum | sed -e 's/^.*filesystem: //g')
+
+ # shrink the MDT and OST filesystems to a smaller size
+ local shrunk=false
+ local new_blks
+ local base_blks
+ if [[ $mds_max_blks -gt $mds_min_blks &&
+ $mds_max_blks -gt $mds_orig_blks ]]; then
+ [[ $mds_orig_blks -gt $mds_min_blks ]] &&
+ base_blks=$mds_orig_blks || base_blks=$mds_min_blks
+ new_blks=$(( (mds_max_blks - base_blks) / 2 + base_blks ))
+ run_resize2fs $SINGLEMDS $mds_dev $new_blks ||
+ error "shrink $SINGLEMDS to $new_blks failed"
+ shrunk=true
+ fi
+
+ if [[ $ost_max_blks -gt $ost_min_blks &&
+ $ost_max_blks -gt $ost_orig_blks ]]; then
+ [[ $ost_orig_blks -gt $ost_min_blks ]] &&
+ base_blks=$ost_orig_blks || base_blks=$ost_min_blks
+ new_blks=$(( (ost_max_blks - base_blks) / 2 + base_blks ))
+ run_resize2fs ost1 $ost_dev $new_blks ||
+ error "shrink ost1 to $new_blks failed"
+ shrunk=true
+ fi
+
+ # check whether the MDT or OST filesystem was shrunk or not
+ if ! $shrunk; then
+ combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
+ reformat || error "(10) reformat Lustre filesystem failed"
+ return 0
+ fi
+
+ # run e2fsck on the MDT and OST devices again
+ run_e2fsck $mds_host $mds_dev "-y"
+ run_e2fsck $ost_host $ost_dev "-y"
+
+ # mount the Lustre filesystem again
+ setup
+
+ # check the files
+ log "check files after shrinking the MDT and OST filesystems"
+ for i in $(seq $((num_files + 10))); do
+ file=$MOUNT/$tdir/$tfile-$i
+ $CHECKSTAT -t file -s 1048576 $file ||
+ error "(11) checkstat $file failed"
+ done
+
+ # unmount and reformat the Lustre filesystem
+ cleanup || error "(12) cleanup Lustre filesystem failed"
+ combined_mgs_mds || stop_mgs || error "(13) stop mgs failed"
+ reformat || error "(14) reformat Lustre filesystem failed"
+}
+run_test 78 "run resize2fs on MDT and OST filesystems"
+
+test_79() { # LU-4227
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
+ { skip "Need MDS version at least 2.5.59"; return 0; }
+
+ local mdsdev1=$(mdsdevname 1)
+ local mdsvdev1=$(mdsvdevname 1)
+ local mdsdev2=$(mdsdevname 2)
+ local mdsvdev2=$(mdsvdevname 2)
+ local ostdev1=$(ostdevname 1)
+ local ostvdev1=$(ostvdevname 1)
+ local opts_mds1="$(mkfs_opts mds1 $mdsdev1) --reformat"
+ local opts_mds2="$(mkfs_opts mds2 $mdsdev2) --reformat"
+ local opts_ost1="$(mkfs_opts ost1 $ostdev1) --reformat"
+ local mgsnode_opt
+
+ # remove --mgs/--mgsnode from mkfs.lustre options
+ opts_mds1=$(echo $opts_mds1 | sed -e "s/--mgs//")
+
+ mgsnode_opt=$(echo $opts_mds2 |
+ awk '{ for ( i = 1; i < NF; i++ )
+ if ( $i ~ "--mgsnode" ) { print $i; break } }')
+ [ -n $mgsnode_opt ] &&
+ opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
+
+ mgsnode_opt=$(echo $opts_ost1 |
+ awk '{ for ( i = 1; i < NF; i++ )
+ if ( $i ~ "--mgsnode" ) { print $i; break } }')
+ [ -n $mgsnode_opt ] &&
+ opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
+
+ # -MGS, format a mdt without --mgs option
+ add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
+ error "Must specify --mgs when formatting mdt combined with mgs"
+
+ # +MGS, format a mdt/ost without --mgsnode option
+ add mds1 $(mkfs_opts mds1 $mdsdev1) --reformat $mdsdev1 $mdsvdev1 \
+ > /dev/null || error "start mds1 failed"
+ add mds2 $opts_mds2 $mdsdev2 $mdsvdev2 &&
+ error "Must specify --mgsnode when formatting a mdt"
+ add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
+ error "Must specify --mgsnode when formatting an ost"
+
+ reformat
+}
+run_test 79 "format MDT/OST without mgs option (should return errors)"
+
+test_80() {
+ start_mds || error "Failed to start MDT"
+ start_ost || error "Failed to start OST1"
+ uuid=$(do_facet ost1 $LCTL get_param -n mgc.*.uuid)
+#define OBD_FAIL_MGS_PAUSE_TARGET_CON 0x906
+ do_facet ost1 "$LCTL set_param fail_val=10 fail_loc=0x906"
+ do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x906"
+ do_facet mgs "$LCTL set_param -n mgs/MGS/evict_client $uuid"
+ sleep 30
+ start_ost2 || error "Failed to start OST2"
+
+ do_facet ost1 "$LCTL set_param fail_loc=0"
+ stopall
+}
+run_test 80 "mgc import reconnect race"
+
+# Save the original values of $OSTCOUNT and $OSTINDEX$i.
+save_ostindex() {
+ local new_ostcount=$1
+ saved_ostcount=$OSTCOUNT
+ OSTCOUNT=$new_ostcount
+
+ local i
+ local index
+ for i in $(seq $OSTCOUNT); do
+ index=OSTINDEX$i
+ eval saved_ostindex$i=${!index}
+ eval OSTINDEX$i=""
+ done
+}
+
+# Restore the original values of $OSTCOUNT and $OSTINDEX$i.
+restore_ostindex() {
+ trap 0
+
+ local i
+ local index
+ for i in $(seq $OSTCOUNT); do
+ index=saved_ostindex$i
+ eval OSTINDEX$i=${!index}
+ done
+ OSTCOUNT=$saved_ostcount
+
+ formatall
+}
+
+# The main purpose of this test is to ensure the OST_INDEX_LIST functions as
+# expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
+# assigned index and ensures we can mount such a formatted file system
+test_81() { # LU-4665
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
+ { skip "Need MDS version at least 2.6.54" && return; }
+ [[ $OSTCOUNT -ge 3 ]] || { skip_env "Need at least 3 OSTs" && return; }
+
+ stopall
+
+ # Each time RANDOM is referenced, a random integer between 0 and 32767
+ # is generated.
+ local i
+ local saved_ostindex1=$OSTINDEX1
+ for i in 65535 $((RANDOM + 65536)); do
+ echo -e "\nFormat ost1 with --index=$i, should fail"
+ OSTINDEX1=$i
+ if add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --reformat \
+ $(ostdevname 1) $(ostvdevname 1); then
+ OSTINDEX1=$saved_ostindex1
+ error "format ost1 with --index=$i should fail"
+ fi
+ done
+ OSTINDEX1=$saved_ostindex1
+
+ save_ostindex 3
+
+ # Format OSTs with random sparse indices.
+ trap "restore_ostindex" EXIT
+ echo -e "\nFormat $OSTCOUNT OSTs with sparse indices"
+ OST_INDEX_LIST=[0,$((RANDOM * 2 % 65533 + 1)),65534] formatall
+
+ # Setup and check Lustre filesystem.
+ start_mgsmds || error "start_mgsmds failed"
+ for i in $(seq $OSTCOUNT); do
+ start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
+ error "start ost$i failed"
+ done
+
+ mount_client $MOUNT || error "mount client $MOUNT failed"
+ check_mount || error "check client $MOUNT failed"
+
+ # Check max_easize.
+ local max_easize=$($LCTL get_param -n llite.*.max_easize)
+ [[ $max_easize -eq 128 ]] ||
+ error "max_easize is $max_easize, should be 128 bytes"
+
+ restore_ostindex
+}
+run_test 81 "sparse OST indexing"
+
+# Wait OSTs to be active on both client and MDT side.
+wait_osts_up() {
+ local cmd="$LCTL get_param -n lov.$FSNAME-clilov-*.target_obd |
+ awk 'BEGIN {c = 0} /ACTIVE/{c += 1} END {printf \\\"%d\\\", c}'"
+ wait_update $HOSTNAME "eval $cmd" $OSTCOUNT ||
+ error "wait_update OSTs up on client failed"
+
+ cmd="$LCTL get_param -n lod.$FSNAME-MDT*-*.target_obd | sort -u |
+ awk 'BEGIN {c = 0} /ACTIVE/{c += 1} END {printf \\\"%d\\\", c}'"
+ wait_update_facet $SINGLEMDS "eval $cmd" $OSTCOUNT ||
+ error "wait_update OSTs up on MDT failed"
+}
+
+# Here we exercise the stripe placement functionality on a file system that
+# has formatted the OST with a random index. With the file system the following
+# functionality is tested:
+#
+# 1. Creating a new file with a specific stripe layout.
+#
+# 2. Modifiy a existing empty file with a specific stripe layout.
+#
+# 3. Ensure we fail to set the stripe layout of a file that already has one.
+#
+# 4. If ost-index is defined we need to ensure it is the first entry in the
+# ost index list returned by lfs getstripe.
+#
+# 5. Lastly ensure this functionality fails with directories.
+test_82a() { # LU-4665
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
+ { skip "Need MDS version at least 2.6.54" && return; }
+ [[ $OSTCOUNT -ge 3 ]] || { skip_env "Need at least 3 OSTs" && return; }
+
+ stopall
+
+ save_ostindex 3
+
+ # Format OSTs with random sparse indices.
+ local i
+ local index
+ local ost_indices
+ for i in $(seq $OSTCOUNT); do
+ index=$((RANDOM * 2))
+ ost_indices+=" $index"
+ done
+ ost_indices=$(comma_list $ost_indices)
+
+ trap "restore_ostindex" EXIT
+ echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
+ OST_INDEX_LIST=[$ost_indices] formatall
+
+ # Setup Lustre filesystem.
+ start_mgsmds || error "start_mgsmds failed"
+ for i in $(seq $OSTCOUNT); do
+ start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
+ error "start ost$i failed"
+ done
+
+ mount_client $MOUNT || error "mount client $MOUNT failed"
+ wait_osts_up
+
+ $LFS df $MOUNT || error "$LFS df $MOUNT failed"
+ mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+
+ # 1. If the file does not exist, new file will be created
+ # with specified OSTs.
+ local file=$DIR/$tdir/$tfile-1
+ local cmd="$SETSTRIPE -o $ost_indices $file"
+ echo -e "\n$cmd"
+ eval $cmd || error "$cmd failed"
+ check_stripe_count $file $OSTCOUNT
+ check_obdidx $file $ost_indices
+ dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
+ error "write $file failed"
+
+ # 2. If the file already exists and is an empty file, the file
+ # will be attached with specified layout.
+ file=$DIR/$tdir/$tfile-2
+ mcreate $file || error "mcreate $file failed"
+ cmd="$SETSTRIPE -o $ost_indices $file"
+ echo -e "\n$cmd"
+ eval $cmd || error "$cmd failed"
+ dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
+ error "write $file failed"
+ check_stripe_count $file $OSTCOUNT
+ check_obdidx $file $ost_indices
+
+ # 3. If the file already has a valid layout attached, the command
+ # should fail with EBUSY.
+ echo -e "\n$cmd"
+ eval $cmd && error "stripe is already set on $file, $cmd should fail"
+
+ # 4. If [--stripe-index|-i <start_ost_idx>] is used, the index must
+ # be in the OST indices list.
+ local start_ost_idx=${ost_indices##*,}
+ file=$DIR/$tdir/$tfile-3
+ cmd="$SETSTRIPE -o $ost_indices -i $start_ost_idx $file"
+ echo -e "\n$cmd"
+ eval $cmd || error "$cmd failed"
+ check_stripe_count $file $OSTCOUNT
+ check_obdidx $file $ost_indices
+ check_start_ost_idx $file $start_ost_idx
+
+ file=$DIR/$tdir/$tfile-4
+ cmd="$SETSTRIPE"
+ cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
+ cmd+=" -i $start_ost_idx $file"
+ echo -e "\n$cmd"
+ eval $cmd && error "index $start_ost_idx should be in $ost_indices"
+
+ # 5. Specifying OST indices for directory should fail with ENOSUPP.
+ local dir=$DIR/$tdir/$tdir
+ mkdir $dir || error "mkdir $dir failed"
+ cmd="$SETSTRIPE -o $ost_indices $dir"
+ echo -e "\n$cmd"
+ eval $cmd && error "$cmd should fail, specifying OST indices" \
+ "for directory is not supported"
+
+ restore_ostindex
+}
+run_test 82a "specify OSTs for file (succeed) or directory (fail)"
+
+cleanup_82b() {
+ trap 0
+
+ # Remove OSTs from a pool and destroy the pool.
+ destroy_pool $ost_pool || true
+
+ restore_ostindex
+}
+
+# Test 82b is run to ensure that if the user supplies a pool with a specific
+# stripe layout that it behaves proprerly. It should fail in the case that
+# the supplied OST index list points to OSTs not contained in the user
+# supplied pool.
+test_82b() { # LU-4665
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
+ { skip "Need MDS version at least 2.6.54" && return; }
+ [[ $OSTCOUNT -ge 4 ]] || { skip_env "Need at least 4 OSTs" && return; }
+
+ stopall
+
+ save_ostindex 4
+
+ # Format OSTs with random sparse indices.
+ local i
+ local index
+ local ost_indices
+ for i in $(seq $OSTCOUNT); do
+ index=$((RANDOM * 2))
+ ost_indices+=" $index"
+ done
+ ost_indices=$(comma_list $ost_indices)
+
+ trap "restore_ostindex" EXIT
+ echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
+ OST_INDEX_LIST=[$ost_indices] formatall
+
+ # Setup Lustre filesystem.
+ start_mgsmds || error "start_mgsmds failed"
+ for i in $(seq $OSTCOUNT); do
+ start ost$i $(ostdevname $i) $OST_MOUNT_OPTS ||
+ error "start ost$i failed"
+ done
+
+ mount_client $MOUNT || error "mount client $MOUNT failed"
+ wait_osts_up
+ $LFS df $MOUNT || error "$LFS df $MOUNT failed"
+ mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+
+ # Create a new pool and add OSTs into it.
+ local ost_pool=$FSNAME.$TESTNAME
+ create_pool $ost_pool || error "create OST pool $ost_pool failed"
+
+ trap - EXIT
+ trap "cleanup_82b" EXIT
+
+ local ost_idx_in_list=${ost_indices##*,}
+ local ost_idx_in_pool=$(exclude_items_from_list $ost_indices \
+ $ost_idx_in_list)
+
+ local ost_targets="$FSNAME-OST["
+ for i in ${ost_idx_in_pool//,/ }; do
+ ost_targets=$ost_targets$(printf "%04x," $i)
+ done
+ ost_targets="${ost_targets%,}]"
+
+ local ost_targets_uuid=$(for i in ${ost_idx_in_pool//,/ }; \
+ do printf "$FSNAME-OST%04x_UUID\n" $i; done |
+ sort -u | tr '\n' ' ')
+
+ local cmd="$LCTL pool_add $ost_pool $ost_targets"
+ do_facet mgs $cmd || error "$cmd failed"
+ wait_update $HOSTNAME "$LCTL get_param -n lov.$FSNAME-*.pools.$TESTNAME|
+ sort -u | tr '\n' ' ' " "$ost_targets_uuid" ||
+ error "wait_update $ost_pool failed"
+ pool_list $ost_pool || error "list OST pool $ost_pool failed"
+
+ # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
+ # then the OSTs must be the members of the pool.
+ local file=$DIR/$tdir/$tfile
+ cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
+ echo -e "\n$cmd"
+ eval $cmd && error "OST with index $ost_idx_in_list should be" \
+ "in OST pool $ost_pool"
+
+ # Only select OST $ost_idx_in_list from $ost_pool for file.
+ ost_idx_in_list=${ost_idx_in_pool#*,}
+ cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
+ echo -e "\n$cmd"
+ eval $cmd || error "$cmd failed"
+ cmd="$GETSTRIPE $file"
+ echo -e "\n$cmd"
+ eval $cmd || error "$cmd failed"
+ check_stripe_count $file 2
+ check_obdidx $file $ost_idx_in_list
+ dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
+ error "write $file failed"
+
+ cleanup_82b
+}
+run_test 82b "specify OSTs for file with --pool and --ost-list options"
+
+test_83() {
+ local dev
+ local ostmnt
+ local fstype
+ local mnt_opts
+
+ if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+ skip "Only applicable to ldiskfs-based MDTs"
+ return
+ fi
+
+ dev=$(ostdevname 1)
+ ostmnt=$(facet_mntpt ost1)
+ fstype=$(facet_fstype ost1)
+
+ # Mount the OST as an ldiskfs filesystem.
+ log "mount the OST $dev as a $fstype filesystem"
+ add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
+ --reformat $dev $dev > /dev/null ||
+ error "format ost1 error"
+
+ if ! test -b $dev; then
+ mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
+ fi
+ echo "mnt_opts $mnt_opts"
+ do_facet ost1 mount -t $fstype $dev \
+ $ostmnt $mnt_opts
+ # Run llverfs on the mounted ldiskfs filesystem.
+ # It is needed to get ENOSPACE.
+ log "run llverfs in partial mode on the OST $fstype $ostmnt"
+ do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
+ "no" || error "run_llverfs error on $fstype"
+
+ # Unmount the OST.
+ log "unmount the OST $dev"
+ stop ost1
+
+ # Delete file IO_scrub. Later osd_scrub_setup will try to
+ # create "IO_scrub" but will get ENOSPACE.
+ writeconf_all
+ echo "start ost1 service on `facet_active_host ost1`"
+ start ost1 `ostdevname 1` $OST_MOUNT_OPTS
+
+ local err
+ err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
+ echo "string err $err"
+ [ -z "$err" ] || error $err
+ reformat
+}
+run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
+Busy inodes after unmount ..."
+
+recovery_time_min() {
+ local CONNECTION_SWITCH_MIN=5
+ local CONNECTION_SWITCH_INC=5
+ local CONNECTION_SWITCH_MAX
+ local RECONNECT_DELAY_MAX
+ local INITIAL_CONNECT_TIMEOUT
+ local max
+ local TO_20
+
+ #CONNECTION_SWITCH_MAX=min(50, max($CONNECTION_SWITCH_MIN,$TIMEOUT)
+ (($CONNECTION_SWITCH_MIN>$TIMEOUT)) && \
+ max=$CONNECTION_SWITCH_MIN || max=$TIMEOUT
+ (($max<50)) && CONNECTION_SWITCH_MAX=$max || CONNECTION_SWITCH_MAX=50
+
+ #INITIAL_CONNECT_TIMEOUT = max(CONNECTION_SWITCH_MIN, \
+ #obd_timeout/20)
+ TO_20=$(($TIMEOUT/20))
+ (($CONNECTION_SWITCH_MIN>$TO_20)) && \
+ INITIAL_CONNECT_TIMEOUT=$CONNECTION_SWITCH_MIN || \
+ INITIAL_CONNECT_TIMEOUT=$TO_20
+
+ RECONNECT_DELAY_MAX=$(($CONNECTION_SWITCH_MAX+$CONNECTION_SWITCH_INC+ \
+ $INITIAL_CONNECT_TIMEOUT))
+ echo $((2*$RECONNECT_DELAY_MAX))
+}
+
+test_84() {
+ local facet=$SINGLEMDS
+ local num=$(echo $facet | tr -d "mds")
+ local dev=$(mdsdevname $num)
+ local time_min=$(recovery_time_min)
+ local recovery_duration
+ local completed_clients
+ local wrap_up=5
+
+ echo "start mds service on $(facet_active_host $facet)"
+ start $facet ${dev} $MDS_MOUNT_OPTS \
+ "-o recovery_time_hard=$time_min,recovery_time_soft=$time_min" $@ ||
+ error "start MDS failed"
+
+ start_ost
+ start_ost2
+
+ echo "recovery_time=$time_min, timeout=$TIMEOUT, wrap_up=$wrap_up"
+
+ mount_client $MOUNT1 || error "mount failed"
+ mount_client $MOUNT2 || error "mount failed"
+
+ replay_barrier $SINGLEMDS
+ createmany -o $DIR1/$tfile-%d 1000
+
+ # We need to catch the end of recovery window to extend it.
+ # Skip 5 requests and add delay to request handling.
+ #define OBD_FAIL_TGT_REPLAY_DELAY 0x709 | FAIL_SKIP
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x20000709 fail_val=5"
+
+ facet_failover $SINGLEMDS || error "failover: $?"
+ client_up
+
+ echo "recovery status"
+ do_facet $SINGLEMDS \
+ "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status"
+
+ recovery_duration=$(do_facet $SINGLEMDS \
+ "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
+ awk '/recovery_duration/ { print $2 }')
+ (( $recovery_duration > $time_min + $wrap_up )) &&
+ error "recovery_duration > recovery_time_hard + wrap up"
+ completed_clients=$(do_facet $SINGLEMDS \
+ "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_status" |
+ awk '/completed_clients/ { print $2 }')
+ [ "$completed_clients" = "1/2" ] ||
+ error "completed_clients != 1/2: $completed_clients"
+
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+ umount_client $MOUNT1
+ umount_client $MOUNT2
+
+ stop_ost
+ stop_ost2
+ stop_mds
+}
+run_test 84 "check recovery_hard_time"
+