+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
+ 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
+ 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 $brpt"
+
+ # restart MDS, the "last_rcvd" file should be recreated.
+ start_mds || error "fail to restart the MDS"
+ 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
+ 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
+ fi
+
+ setup_noconfig
+ check_mount || error "error after nid replace"
+ cleanup || error "cleanup failed"
+ reformat
+}
+run_test 66 "replace nids"
+