require_dsh_mds || exit 0
require_dsh_ost || exit 0
#
-[ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="30a 31 45 69"
assert_DIR
}
run_test 67 "test routes conversion and configuration"
+test_69() {
+ 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 + 100))
+
+ mkdir -p $DIR/$tdir
+ $LFS setstripe -i 0 $DIR/$tdir
+ createmany -o $DIR/$tdir/$tfile- $num_create
+ # 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=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
+ [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
+
+ cleanup
+}
+run_test 69 "replace an OST with the same index"
+
test_70a() {
[ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
local MDTIDX=1
char *progname;
int verbose = 1;
static int print_only = 0;
-static int upgrade_to_18 = 0;
#ifdef HAVE_LDISKFS_OSD
#define FSLIST_LDISKFS "ldiskfs"
"\t\t--device-size=#N(KB): device size for loop devices\n"
"\t\t--mkfsoptions=<opts>: format options\n"
"\t\t--reformat: overwrite an existing disk\n"
+ "\t\t--replace: replace an old target with the same index\n"
"\t\t--stripe-count-hint=#N: for optimizing MDT inode size\n"
#else
"\t\t--erase-params: erase all old parameter settings\n"
int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
char **mountopts)
{
- static struct option long_opt[] = {
- {"backfstype", 1, 0, 'b'},
- {"stripe-count-hint", 1, 0, 'c'},
- {"comment", 1, 0, 'u'},
- {"configdev", 1, 0, 'C'},
- {"device-size", 1, 0, 'd'},
- {"dryrun", 0, 0, 'n'},
- {"erase-params", 0, 0, 'e'},
- {"failnode", 1, 0, 'f'},
- {"failover", 1, 0, 'f'},
- {"mgs", 0, 0, 'G'},
- {"help", 0, 0, 'h'},
- {"index", 1, 0, 'i'},
- {"mkfsoptions", 1, 0, 'k'},
- {"mgsnode", 1, 0, 'm'},
- {"mgsnid", 1, 0, 'm'},
- {"mdt", 0, 0, 'M'},
- {"fsname",1, 0, 'L'},
- {"noformat", 0, 0, 'n'},
- {"nomgs", 0, 0, 'N'},
- {"mountfsoptions", 1, 0, 'o'},
- {"ost", 0, 0, 'O'},
- {"param", 1, 0, 'p'},
- {"print", 0, 0, 'n'},
- {"quiet", 0, 0, 'q'},
- {"reformat", 0, 0, 'r'},
- {"servicenode", 1, 0, 's'},
- {"verbose", 0, 0, 'v'},
- {"writeconf", 0, 0, 'w'},
- {"upgrade_to_18", 0, 0, 'U'},
- {"network", 1, 0, 't'},
- {"quota", 0, 0, 'Q'},
- {0, 0, 0, 0}
- };
- char *optstring = "b:c:C:d:ef:Ghi:k:L:m:MnNo:Op:Pqrs:t:Uu:vw";
- int opt;
- int rc, longidx;
- int failnode_set = 0, servicenode_set = 0;
+ static struct option long_opt[] = {
+ { "backfstype", required_argument, NULL, 'b' },
+ { "stripe-count-hint", required_argument, NULL, 'c' },
+ { "comment", required_argument, NULL, 'u' },
+ { "configdev", required_argument, NULL, 'C' },
+ { "device-size", required_argument, NULL, 'd' },
+ { "dryrun", no_argument, NULL, 'n' },
+ { "erase-params", no_argument, NULL, 'e' },
+ { "failnode", required_argument, NULL, 'f' },
+ { "failover", required_argument, NULL, 'f' },
+ { "mgs", no_argument, NULL, 'G' },
+ { "help", no_argument, NULL, 'h' },
+ { "index", required_argument, NULL, 'i' },
+ { "mkfsoptions", required_argument, NULL, 'k' },
+ { "mgsnode", required_argument, NULL, 'm' },
+ { "mgsnid", required_argument, NULL, 'm' },
+ { "mdt", no_argument, NULL, 'M' },
+ { "fsname", required_argument, NULL, 'L' },
+ { "noformat", no_argument, NULL, 'n' },
+ { "nomgs", no_argument, NULL, 'N' },
+ { "mountfsoptions", required_argument, NULL, 'o' },
+ { "ost", no_argument, NULL, 'O' },
+ { "param", required_argument, NULL, 'p' },
+ { "print", no_argument, NULL, 'n' },
+ { "quiet", no_argument, NULL, 'q' },
+ { "quota", no_argument, NULL, 'Q' },
+ { "reformat", no_argument, NULL, 'r' },
+ { "replace", no_argument, NULL, 'R' },
+ { "servicenode", required_argument, NULL, 's' },
+ { "network", required_argument, NULL, 't' },
+ { "verbose", no_argument, NULL, 'v' },
+ { "writeconf", no_argument, NULL, 'w' },
+ { 0, 0, NULL, 0 }
+ };
+ char *optstring = "b:c:C:d:ef:Ghi:k:L:m:MnNo:Op:PqrRs:t:Uu:vw";
+ int opt;
+ int rc, longidx;
+ int failnode_set = 0, servicenode_set = 0;
+ int replace = 0;
while ((opt = getopt_long(argc, argv, optstring, long_opt, &longidx)) !=
EOF) {
case 'r':
mop->mo_flags |= MO_FORCEFORMAT;
break;
+ case 'R':
+ replace = 1;
+ break;
case 't':
if (!IS_MDT(&mop->mo_ldd) && !IS_OST(&mop->mo_ldd)) {
badopt(long_opt[longidx].name, "MDT,OST");
case 'w':
mop->mo_ldd.ldd_flags |= LDD_F_WRITECONF;
break;
- case 'U':
- upgrade_to_18 = 1;
- break;
case 'Q':
mop->mo_flags |= MO_QUOTA;
break;
}
}//while
+ /* Need to clear this flag after parsing 'L' and 'i' options. */
+ if (replace)
+ mop->mo_ldd.ldd_flags &= ~LDD_F_VIRGIN;
+
if (optind == argc) {
/* The user didn't specify device name */
fatal();