"\t\t--ost: object storage, mutually exclusive with mdt\n"
"\t\t--mdt: metadata storage, mutually exclusive with ost\n"
"\t\t--mgmt: configuration management service - one per site\n"
- "\t\t--mgmtnode=<mgtnode>[,<failover-mgtnode>]:nid of a remote\n"
- "\t\t\tmgmt node [and the failover mgmt node]\n"
+ "\t\t--mgmtnid=<nid>[,<...>]:nid(s) of a remote mgmt node\n"
"\t\t--fsname=<filesystem_name>\n"
"\t\t--configdev=<altdevice|file>: store configuration info\n"
"\t\t\tfor this device on an alternate device\n"
"\t\t--startupwait=<secs>: time to wait for other servers to join\n"
"\t\t--reformat: overwrite an existing disk\n"
"\t\t--verbose\n");
- exit(out != stdout);
+ return;
}
#define vprint if (verbose) printf
vprint("Loading modules...");
/* portals, ksocknal, fsfilt, etc. in modules.conf */
- rc = load_module("_lustre");
+ rc = load_module("lustre");
if (rc) return rc;
/* FIXME currently use the MDT to write llogs, should be a MGS */
}
}
+static int lnet_setup = 0;
+static void lnet_start()
+{
+ ptl_initialize(0, NULL);
+ if (access("/proc/sys/lnet", X_OK) != 0)
+ load_module("lnet");
+ if (jt_ptl_get_nids(NULL) == -ENETDOWN) {
+ char *cmd[]={"network", "up"};
+ jt_ptl_network(2, cmd);
+ lnet_setup++;
+ }
+}
+
+static void lnet_stop()
+{
+ char *cmd[]={"network", "down"};
+ if (--lnet_setup == 0)
+ jt_ptl_network(2, cmd);
+}
+
+
/*============ disk dev functions ===================*/
/* Setup a file in the first unused loop_device */
return EINVAL;
}
+ ret = creat(mop->mo_device, S_IRUSR|S_IWUSR);
ret = truncate(mop->mo_device, mop->mo_device_sz * 1024);
if (ret != 0) {
+ ret = errno;
fprintf(stderr, "Unable to create backing store: %d\n", ret);
}
void print_ldd(struct lustre_disk_data *ldd)
{
int count = 0;
- printf("Permanent disk data:\n");
+ printf("\nPermanent disk data:\n");
printf("Server: %s\n", ldd->ldd_svname);
printf("Lustre FS: %s\n", ldd->ldd_fsname);
printf("Mount type: %s\n", MT_STR(ldd));
+ printf("Flags: %s%s%s%s\n",
+ ldd->ldd_flags & LDD_F_SV_TYPE_MDT ? "MDT ":"",
+ ldd->ldd_flags & LDD_F_SV_TYPE_OST ? "OST ":"",
+ ldd->ldd_flags & LDD_F_SV_TYPE_MGMT ? "MGT ":"",
+ ldd->ldd_flags & LDD_F_NEED_INDEX ? "needs_index ":"");
printf("Persistent mount opts: %s\n", ldd->ldd_mount_opts);
- printf("MGS nids:");
+ printf("MGS nids: ");
while (count < MAX_FAILOVER_NIDS) {
if (ldd->ldd_mgsnid[count] == LNET_NID_ANY)
break;
libcfs_nid2str(ldd->ldd_mgsnid[count]));
count++;
}
- printf("\n");
+ printf("\n\n");
}
/* Write the server config files */
return ret;
}
+#if 0
static int jt_setup()
{
int ret;
mop->mo_timeout, 0);
do_jt(jt_cfg_endrecord, "endrecord", 0);
-#if 0
/* Write client startup logs */
numnids = jt_getnids(nidarray,
sizeof(nidarray) / sizeof(nidarray[0]));
do_jt(jt_lcfg_set_timeout, "set_timeout",
mop->mo_timeout, 0);
}
-#endif
}
out_jt:
obd_finalize(1, (char **)&name /*dummy*/);
return ret;
}
+#endif
/* Make the mdt/ost server obd name based on the filesystem name */
static void make_sv_name(struct mkfs_opts *mop)
int ret = 0;
progname = argv[0];
- if (argc < 3)
+ if (argc < 3) {
usage(stderr);
-
+ goto out;
+ }
+
memset(&mop, 0, sizeof(mop));
set_defaults(&mop);
break;
case 'h':
usage(stdout);
- break;
+ goto out;
case 'i':
if (IS_MDT(&mop.mo_ldd) || IS_OST(&mop.mo_ldd)) {
mop.mo_index = atol(optarg);
char *s1 = optarg, *s2;
if (IS_MGMT(&mop.mo_ldd))
badopt(opt, "non-MGMT MDT,OST");
- while ((s2 = strsep(&s1, ","))){
+ while ((s2 = strsep(&s1, ","))) {
mop.mo_ldd.ldd_mgsnid[count++] =
libcfs_str2nid(s2);
if (count >= MAX_FAILOVER_NIDS) {
fprintf(stderr, "too many MGS nids, "
"ignoring %s\n", s1);
break;
- } else {
- mop.mo_ldd.ldd_mgsnid[count] =
- LNET_NID_ANY;
}
}
+ if (count < MAX_FAILOVER_NIDS)
+ mop.mo_ldd.ldd_mgsnid[count] =
+ LNET_NID_ANY;
break;
}
case 'M':
fprintf(stderr, "Unknown option '%c'\n", opt);
}
usage(stderr);
- break;
+ goto out;
}
}//while
if (optind >= argc) {
fatal();
fprintf(stderr, "Bad arguments\n");
usage(stderr);
+ goto out;
}
if (!(IS_MDT(&mop.mo_ldd) || IS_OST(&mop.mo_ldd) ||
fatal();
fprintf(stderr, "must set server type :{mdt,ost,mgmt}\n");
usage(stderr);
+ goto out;
}
if (IS_MDT(&mop.mo_ldd) && !IS_MGMT(&mop.mo_ldd) &&
mop.mo_ldd.ldd_mgsnid[0] == LNET_NID_ANY) {
int count;
__u64 *nids;
- vprint("No MGS specified, adding to this MDT\n");
+ vprint("No MGS specified, adding MGS to this MDT\n");
mop.mo_ldd.ldd_flags |= LDD_F_SV_TYPE_MGMT;
+ lnet_start();
count = jt_ptl_get_nids(&nids);
- if (count > 0) {
- vprint("Adding %d local nids for MGS\n", count);
- memcpy(mop.mo_ldd.ldd_mgsnid, nids,
- sizeof(mop.mo_ldd.ldd_mgsnid));
- free(nids);
- }
- if (count < MAX_FAILOVER_NIDS) {
- mop.mo_ldd.ldd_mgsnid[count] = LNET_NID_ANY;
+ if (count < 0) {
+ fprintf(stderr, "Can't find local nids "
+ "(is the lnet module loaded?)\n");
+ } else {
+ if (count > 0) {
+ vprint("Adding %d local nids for MGS\n", count);
+ memcpy(mop.mo_ldd.ldd_mgsnid, nids,
+ sizeof(mop.mo_ldd.ldd_mgsnid));
+ free(nids);
+ }
+ if (count < MAX_FAILOVER_NIDS) {
+ mop.mo_ldd.ldd_mgsnid[count] = LNET_NID_ANY;
+ }
}
}
fatal();
fprintf(stderr, "Must specify either --mgmt or --mgmtnode\n");
usage(stderr);
+ goto out;
}
if (IS_MDT(&mop.mo_ldd) && (mop.mo_stripe_sz == 0))
fprintf(stderr, "%s: unknown fs type %d '%s'\n",
progname, mop.mo_ldd.ldd_mount_type,
MT_STR(&mop.mo_ldd));
- return EINVAL;
+ ret = EINVAL;
+ goto out;
}
}
ret = loop_setup(&mop);
if (ret) {
fatal();
- fprintf(stderr, "Loop device setup failed %d\n", ret);
- return ret;
+ fprintf(stderr, "Loop device setup failed: %s\n",
+ strerror(ret));
+ goto out;
}
}
if (ret != 0) {
fatal();
fprintf(stderr, "mkfs failed %d\n", ret);
- return ret;
+ goto out;
}
ret = write_local_files(&mop);
if (ret != 0) {
fatal();
fprintf(stderr, "failed to write local files\n");
- return ret;
+ goto out;
}
+ /* We will not write startup logs here. That is the domain of the
+ mgc/mgs, and should probably be done at first mount.
+ mgc might have to pass info from the mount_data_file to mgs. */
+#if 0
ret = write_llog_files(&mop);
if (ret != 0) {
fatal();
fprintf(stderr, "failed to write setup logs\n");
- return ret;
+ goto out:
}
-
+#endif
+
+out:
loop_cleanup(&mop);
-
+ lnet_stop();
+
return ret;
}