4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2016, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/utils/mkfs_lustre.c
34 * Author: Nathan Rutman <nathan@clusterfs.com>
37 /* This source file is compiled into both mkfs.lustre and tunefs.lustre */
41 #endif /* HAVE_CONFIG_H */
54 #include <sys/types.h>
56 #include <sys/mount.h>
57 #include <sys/utsname.h>
63 #include <lnet/nidstr.h>
64 #include <lustre_disk.h>
65 #include <lustre_param.h>
66 #include <lnet/lnetctl.h>
67 #include <lustre_ver.h>
69 #include "mount_utils.h"
74 static int print_only = 0;
76 #ifdef HAVE_LDISKFS_OSD
77 #define FSLIST_LDISKFS "ldiskfs"
80 #define FSLIST_LDISKFS ""
81 #endif /* HAVE_LDISKFS_OSD */
84 #define FSLIST_ZFS "|zfs"
86 #define FSLIST_ZFS "zfs"
91 #endif /* HAVE_ZFS_OSD */
94 #error "no backing OSD types (ldiskfs or ZFS) are configured"
97 #define FSLIST FSLIST_LDISKFS FSLIST_ZFS
101 fprintf(out, "usage: %s <target type> [--backfstype="FSLIST"] "
102 "--fsname=<filesystem name>\n"
103 "\t--index=<target index> [options] <device>\n", progname);
105 fprintf(out, "usage: %s <target type> --backfstype=zfs "
106 "--fsname=<filesystem name> [options]\n"
107 "\t<pool name>/<dataset name>\n"
108 "\t[[<vdev type>] <device> [<device> ...] [vdev type>] ...]\n",
112 "\t<device>:block device or file (e.g /dev/sda or /tmp/ost1)\n"
114 "\t<pool name>: name of ZFS pool where target is created "
116 "\t<dataset name>: name of new dataset, must be unique within "
118 "\t<vdev type>: type of vdev (mirror, raidz, raidz2, spare, "
123 "\t\t--mgs: configuration management service\n"
124 "\t\t--nomgs: turn off MGS service on this MDT\n"
126 "\t\t--mdt: metadata storage, mutually exclusive with ost\n"
127 "\t\t--ost: object storage, mutually exclusive with mdt, mgs\n"
129 "\toptions (in order of popularity):\n"
130 "\t\t--index=#N: numerical target index (0..N)\n"
131 "\t\t\trequired for all targets other than the MGS,\n"
132 "\t\t\ttarget index may either be a decimal number or\n"
133 "\t\t\thexadecimal number starting with '0x'\n"
134 "\t\t--fsname=<8_char_filesystem_name>: fs targets belong to\n"
135 "\t\t\trequired for all targets other than MGS\n"
136 "\t\t--mgsnode=<nid>[,<...>]: NID(s) of remote MGS\n"
137 "\t\t\trequired for all targets other than MGS\n"
138 "\t\t--mountfsoptions=<opts>: permanent Lustre mount options\n"
139 "\t\t--backfs-mount-opts=<opts>: backing fs mount options\n"
140 "\t\t--failnode=<nid>[,<...>]: NID(s) of backup failover node\n"
141 "\t\t\tmutually exclusive with --servicenode\n"
142 "\t\t--servicenode=<nid>[,<...>]: NID(s) of service partners\n"
143 "\t\t\ttreat nodes as equal service node, mutually exclusive "
145 "\t\t--param <key>=<value>: set a permanent parameter\n"
146 "\t\t\te.g. --param sys.timeout=40\n"
147 "\t\t\t --param lov.stripesize=2M\n"
148 "\t\t--network=<net>[,<...>]: restrict OST/MDT to network(s)\n"
150 "\t\t--backfstype=<fstype>: backing fs type (ldiskfs, zfs)\n"
151 "\t\t--device-size=#N(KB): device size for loop devices\n"
152 "\t\t--mkfsoptions=<opts>: format options\n"
153 "\t\t--reformat: overwrite an existing disk\n"
154 "\t\t--replace: replace an old target with the same index\n"
155 "\t\t--stripe-count-hint=#N: for optimizing MDT inode size\n"
157 "\t\t--erase-params: erase all old parameter settings\n"
158 "\t\t--writeconf: erase all config logs for this fs.\n"
159 "\t\t--quota: enable space accounting on old 2.x device.\n"
160 "\t\t--rename: rename the filesystem name\n"
162 "\t\t--comment=<user comment>: arbitrary string (%d bytes)\n"
163 "\t\t--dryrun: report what we would do; don't write to disk\n"
164 "\t\t--verbose: e.g. show mkfs progress\n"
165 "\t\t--force-nohostid: Ignore hostid requirement for ZFS "
167 "\t\t-V|--version: output build version of the utility and\n"
170 (int)sizeof(((struct lustre_disk_data *)0)->ldd_userdata));
174 /* ==================== Lustre config functions =============*/
176 void print_ldd(char *str, struct lustre_disk_data *ldd)
178 printf("\n %s:\n", str);
179 printf("Target: %s\n", ldd->ldd_svname);
180 if (ldd->ldd_svindex == INDEX_UNASSIGNED)
181 printf("Index: unassigned\n");
183 printf("Index: %d\n", ldd->ldd_svindex);
184 if (ldd->ldd_uuid[0])
185 printf("UUID: %s\n", (char *)ldd->ldd_uuid);
186 printf("Lustre FS: %s\n", ldd->ldd_fsname);
187 printf("Mount type: %s\n", MT_STR(ldd));
188 printf("Flags: %#x\n", ldd->ldd_flags);
189 printf(" (%s%s%s%s%s%s%s%s%s)\n",
190 IS_MDT(ldd) ? "MDT ":"",
191 IS_OST(ldd) ? "OST ":"",
192 IS_MGS(ldd) ? "MGS ":"",
193 ldd->ldd_flags & LDD_F_NEED_INDEX ? "needs_index ":"",
194 ldd->ldd_flags & LDD_F_VIRGIN ? "first_time ":"",
195 ldd->ldd_flags & LDD_F_UPDATE ? "update ":"",
196 ldd->ldd_flags & LDD_F_WRITECONF ? "writeconf ":"",
197 ldd->ldd_flags & LDD_F_NO_PRIMNODE? "no_primnode ":"",
198 ldd->ldd_flags & LDD_F_UPGRADE14 ? "upgrade1.4 ":"");
199 printf("Persistent mount opts: %s\n", ldd->ldd_mount_opts);
200 printf("Parameters:%s\n", ldd->ldd_params);
201 if (ldd->ldd_userdata[0])
202 printf("Comment: %s\n", ldd->ldd_userdata);
206 void set_defaults(struct mkfs_opts *mop)
208 mop->mo_ldd.ldd_magic = LDD_MAGIC;
209 mop->mo_ldd.ldd_config_ver = 1;
210 mop->mo_ldd.ldd_flags = LDD_F_NEED_INDEX | LDD_F_UPDATE | LDD_F_VIRGIN;
211 #ifdef HAVE_LDISKFS_OSD
212 mop->mo_ldd.ldd_mount_type = LDD_MT_LDISKFS;
214 mop->mo_ldd.ldd_mount_type = LDD_MT_ZFS;
216 mop->mo_ldd.ldd_svindex = INDEX_UNASSIGNED;
217 mop->mo_mgs_failnodes = 0;
218 mop->mo_stripe_count = 1;
219 mop->mo_pool_vdevs = NULL;
222 static inline void badopt(const char *opt, char *type)
224 fprintf(stderr, "%s: '--%s' only valid for %s\n",
225 progname, opt, type);
229 /* from mount_lustre */
230 /* Get rid of symbolic hostnames for tcp, since kernel can't do lookups */
231 #define MAXNIDSTR 1024
232 static char *convert_hostnames(char *s1)
234 char *converted, *s2 = 0, *c, *end, sep;
235 int left = MAXNIDSTR;
238 converted = malloc(left);
239 if (converted == NULL) {
243 end = s1 + strlen(s1);
245 while ((left > 0) && (s1 < end)) {
246 s2 = strpbrk(s1, ",:");
251 nid = libcfs_str2nid(s1);
254 if (nid == LNET_NID_ANY) {
255 fprintf(stderr, "%s: Cannot resolve hostname '%s'.\n",
260 if (strncmp(libcfs_nid2str(nid), "127.0.0.1",
261 strlen("127.0.0.1")) == 0) {
262 fprintf(stderr, "%s: The NID '%s' resolves to the "
263 "loopback address '%s'. Lustre requires a "
264 "non-loopback address.\n",
265 progname, s1, libcfs_nid2str(nid));
270 c += snprintf(c, left, "%s%c", libcfs_nid2str(nid), sep);
271 left = converted + MAXNIDSTR - c;
277 int parse_opts(int argc, char *const argv[], struct mkfs_opts *mop,
278 char **mountopts, char *old_fsname)
280 static struct option long_opt[] = {
281 { "backfs-mount-opts", required_argument, NULL, 'B' },
282 { "failnode", required_argument, NULL, 'f' },
283 { "failover", required_argument, NULL, 'f' },
284 { "mgs", no_argument, NULL, 'G' },
285 { "help", no_argument, NULL, 'h' },
286 { "index", required_argument, NULL, 'i' },
287 { "fsname", required_argument, NULL, 'L' },
288 { "mgsnode", required_argument, NULL, 'm' },
289 { "mgsnid", required_argument, NULL, 'm' },
290 { "dryrun", no_argument, NULL, 'n' },
291 { "nomgs", no_argument, NULL, 'N' },
292 { "mountfsoptions", required_argument, NULL, 'o' },
293 { "param", required_argument, NULL, 'p' },
294 { "quiet", no_argument, NULL, 'q' },
295 { "servicenode", required_argument, NULL, 's' },
296 { "network", required_argument, NULL, 't' },
297 { "comment", required_argument, NULL, 'u' },
298 { "force-nohostid", no_argument, NULL, 'U' },
299 { "verbose", no_argument, NULL, 'v' },
300 { "version", no_argument, NULL, 'V' },
302 { "backfstype", required_argument, NULL, 'b' },
303 { "stripe-count-hint", required_argument, NULL, 'c' },
304 { "device-size", required_argument, NULL, 'd' },
305 { "mkfsoptions", required_argument, NULL, 'k' },
306 { "mdt", no_argument, NULL, 'M' },
307 { "ost", no_argument, NULL, 'O' },
308 { "reformat", no_argument, NULL, 'r' },
309 { "replace", no_argument, NULL, 'R' },
311 { "erase-params", no_argument, NULL, 'e' },
312 { "quota", no_argument, NULL, 'Q' },
313 { "rename", optional_argument, NULL, 'R' },
314 { "writeconf", no_argument, NULL, 'w' },
318 char *optstring = "B:f:Ghi:L:m:nNo:p:qs:t:u:vV"
324 struct lustre_disk_data *ldd = &mop->mo_ldd;
325 char new_fsname[16] = { 0 };
328 int failnode_set = 0, servicenode_set = 0;
330 bool index_option = false;
332 while ((opt = getopt_long(argc, argv, optstring, long_opt, &longidx)) !=
336 mop->mo_mountopts = optarg;
342 if ((opt == 'f' && servicenode_set) ||
343 (opt == 's' && failnode_set)) {
344 fprintf(stderr, "%s: %s cannot use with --%s\n",
345 progname, long_opt[longidx].name,
346 opt == 'f' ? "servicenode" :
351 nids = convert_hostnames(optarg);
355 rc = append_param(ldd->ldd_params, PARAM_FAILNODE,
361 /* Must update the mgs logs */
362 ldd->ldd_flags |= LDD_F_UPDATE;
364 ldd->ldd_flags &= ~LDD_F_NO_PRIMNODE;
367 ldd->ldd_flags |= LDD_F_NO_PRIMNODE;
370 mop->mo_flags |= MO_FAILOVER;
374 ldd->ldd_flags |= LDD_F_SV_TYPE_MGS;
383 /* LU-2374: check whether it is OST/MDT later */
384 base = (strlen(optarg) > 1 &&
385 !strncmp(optarg, "0x", 2)) ? 16 : 10;
386 /* Allowed input are base 16 and base 10 numbers only */
387 mop->mo_ldd.ldd_svindex = strtoul(optarg,
389 if (*endptr != '\0') {
390 fprintf(stderr, "%s: wrong index %s. "
391 "Target index must be decimal or "
396 if (ldd->ldd_svindex >= INDEX_UNASSIGNED) {
397 fprintf(stderr, "%s: wrong index %u. "
398 "Target index must be less than %u.\n",
399 progname, ldd->ldd_svindex,
404 ldd->ldd_flags &= ~LDD_F_NEED_INDEX;
408 rc = lustre_is_fsname_valid(optarg, 1,
411 fprintf(stderr, "%s: filesystem name must be "
412 "1-%d chars\n", progname,
416 fprintf(stderr, "%s: char '%c' not allowed in "
417 "filesystem name\n", progname, rc);
421 strscpy(new_fsname, optarg, sizeof(new_fsname));
425 char *nids = convert_hostnames(optarg);
430 rc = append_param(ldd->ldd_params, PARAM_MGSNODE,
436 mop->mo_mgs_failnodes++;
443 ldd->ldd_flags &= ~LDD_F_SV_TYPE_MGS;
449 rc = add_param(ldd->ldd_params, NULL, optarg);
453 /* Must update the mgs logs */
454 ldd->ldd_flags |= LDD_F_UPDATE;
460 if (!IS_MDT(ldd) && !IS_OST(ldd)) {
461 badopt(long_opt[longidx].name, "MDT,OST");
468 rc = add_param(ldd->ldd_params, PARAM_NETWORK, optarg);
472 /* Must update the mgs logs */
473 ldd->ldd_flags |= LDD_F_UPDATE;
476 strscpy(ldd->ldd_userdata, optarg,
477 sizeof(ldd->ldd_userdata));
480 mop->mo_flags |= MO_NOHOSTID_CHECK;
487 fprintf(stdout, "%s %s\n", progname,
488 LUSTRE_VERSION_STRING);
495 if (strcmp(optarg, mt_str(i)) == 0) {
496 ldd->ldd_mount_type = i;
499 } while (++i < LDD_MT_LAST);
501 if (i == LDD_MT_LAST) {
502 fprintf(stderr, "%s: invalid backend filesystem"
503 " type %s\n", progname, optarg);
510 int stripe_count = atol(optarg);
512 if (stripe_count <= 0) {
513 fprintf(stderr, "%s: bad stripe count "
514 "%d\n", progname, stripe_count);
517 mop->mo_stripe_count = stripe_count;
519 badopt(long_opt[longidx].name, "MDT");
524 mop->mo_device_kb = atol(optarg);
527 strscpy(mop->mo_mkfsopts, optarg,
528 sizeof(mop->mo_mkfsopts));
531 ldd->ldd_flags |= LDD_F_SV_TYPE_MDT;
534 ldd->ldd_flags |= LDD_F_SV_TYPE_OST;
537 mop->mo_flags |= MO_FORCEFORMAT;
544 ldd->ldd_params[0] = '\0';
545 /* Must update the mgs logs */
546 ldd->ldd_flags |= LDD_F_UPDATE;
549 mop->mo_flags |= MO_QUOTA;
554 mop->mo_flags |= MO_RENAME;
556 if (IS_SEPARATED_MGS(ldd)) {
557 fprintf(stderr, "%s: must specify the "
558 "old fsname to be renamed for "
559 "separated MGS\n", progname);
565 if ((strlen(optarg) < 1) || (strlen(optarg) > 8)) {
566 fprintf(stderr, "%s: filesystem name must be "
567 "1-8 chars\n", progname);
571 tmp = strpbrk(optarg, "/:");
573 fprintf(stderr, "%s: char '%c' not allowed in "
574 "filesystem name\n", progname, *tmp);
578 if (IS_SEPARATED_MGS(ldd)) {
579 strscpy(old_fsname, optarg,
580 sizeof(ldd->ldd_fsname));
581 } else if (strlen(old_fsname) != strlen(optarg) ||
582 strcmp(old_fsname, optarg) != 0) {
583 fprintf(stderr, "%s: the given fsname '%s' "
584 "to be renamed does not exist\n",
591 ldd->ldd_flags |= LDD_F_WRITECONF;
597 fprintf(stderr, "Unknown option '%c'\n", opt);
603 if (strlen(new_fsname) > 0) {
604 if (!(mop->mo_flags & (MO_FORCEFORMAT | MO_RENAME)) &&
606 (LDD_F_UPGRADE14 | LDD_F_VIRGIN | LDD_F_WRITECONF)))) {
607 fprintf(stderr, "%s: cannot change the name "
608 "of a registered target\n", progname);
612 strscpy(ldd->ldd_fsname, new_fsname, sizeof(ldd->ldd_fsname));
615 if (index_option && !(mop->mo_ldd.ldd_flags &
616 (LDD_F_UPGRADE14 | LDD_F_VIRGIN |
618 fprintf(stderr, "%s: cannot change the index of"
619 " a registered target\n", progname);
624 if (mop->mo_flags & MO_RENAME) {
625 if (new_fsname[0] == '\0') {
626 fprintf(stderr, "%s: need to specify new fsname for "
627 "renaming case\n", progname);
631 if (strcmp(old_fsname, new_fsname) == 0) {
632 fprintf(stderr, "%s: cannot rename fsname '%s' to "
633 "the same name\n", progname, old_fsname);
639 /* Need to clear this flag after parsing 'L' and 'i' options. */
641 ldd->ldd_flags &= ~LDD_F_VIRGIN;
643 if (optind == argc) {
644 /* The user didn't specify device name */
646 fprintf(stderr, "Not enough arguments - device name or "
647 "pool/dataset name not specified.\n");
650 /* The device or pool/filesystem name */
651 strscpy(mop->mo_device, argv[optind], sizeof(mop->mo_device));
653 /* Followed by optional vdevs */
654 if (optind < argc - 1)
655 mop->mo_pool_vdevs = (char **) &argv[optind + 1];
661 int main(int argc, char *const argv[])
663 struct mkfs_opts mop;
664 struct lustre_disk_data *ldd = &mop.mo_ldd;
665 char *mountopts = NULL;
666 char wanted_mountopts[512] = "";
667 char old_fsname[16] = "";
672 progname = strrchr(argv[0], '/');
673 if (progname != NULL)
678 if ((argc < 2) || (argv[argc - 1][0] == '-')) {
683 memset(&mop, 0, sizeof(mop));
686 /* device is last arg */
687 strscpy(mop.mo_device, argv[argc - 1], sizeof(mop.mo_device));
694 /* For tunefs, we must read in the old values before parsing any
697 /* Check whether the disk has already been formatted by mkfs.lustre */
698 ret = osd_is_lustre(mop.mo_device, &mount_type);
701 fprintf(stderr, "Device %s has not been formatted with "
702 "mkfs.lustre\n", mop.mo_device);
706 ldd->ldd_mount_type = mount_type;
708 ret = osd_read_ldd(mop.mo_device, ldd);
711 fprintf(stderr, "Failed to read previous Lustre data from %s "
712 "(%d)\n", mop.mo_device, ret);
716 strscpy(old_fsname, ldd->ldd_fsname, sizeof(ldd->ldd_fsname));
717 ldd->ldd_flags &= ~(LDD_F_WRITECONF | LDD_F_VIRGIN);
719 /* svname of the form lustre:OST1234 means never registered */
720 ret = strlen(ldd->ldd_svname);
721 if (ldd->ldd_svname[ret - 8] == ':') {
722 ldd->ldd_svname[ret - 8] = '-';
723 ldd->ldd_flags |= LDD_F_VIRGIN;
724 } else if (ldd->ldd_svname[ret - 8] == '=') {
725 ldd->ldd_svname[ret - 8] = '-';
726 ldd->ldd_flags |= LDD_F_WRITECONF;
729 if (strstr(ldd->ldd_params, PARAM_MGSNODE))
730 mop.mo_mgs_failnodes++;
733 print_ldd("Read previous values", ldd);
736 ret = parse_opts(argc, argv, &mop, &mountopts, old_fsname);
737 if (ret != 0 || version)
740 if (!IS_MDT(ldd) && !IS_OST(ldd) && !IS_MGS(ldd)) {
742 fprintf(stderr, "must set target type: MDT,OST,MGS\n");
747 if (((IS_MDT(ldd) || IS_MGS(ldd))) && IS_OST(ldd)) {
749 fprintf(stderr, "OST type is exclusive with MDT,MGS\n");
754 /* Stand alone MGS doesn't need an index */
755 if (!IS_MDT(ldd) && IS_MGS(ldd)) {
757 /* But if --index was specified flag an error */
758 if (!(ldd->ldd_flags & LDD_F_NEED_INDEX)) {
759 badopt("index", "MDT,OST");
763 ldd->ldd_flags &= ~LDD_F_NEED_INDEX;
766 if ((ldd->ldd_flags & (LDD_F_NEED_INDEX | LDD_F_UPGRADE14)) ==
767 (LDD_F_NEED_INDEX | LDD_F_UPGRADE14)) {
769 fprintf(stderr, "Can't find the target index, "
770 "specify with --index\n");
775 if (ldd->ldd_flags & LDD_F_NEED_INDEX)
776 fprintf(stderr, "warning: %s: for Lustre 2.4 and later, the "
777 "target index must be specified with --index\n",
780 /* If no index is supplied for MDT by default set index to zero */
781 if (IS_MDT(ldd) && (ldd->ldd_svindex == INDEX_UNASSIGNED)) {
782 ldd->ldd_flags &= ~LDD_F_NEED_INDEX;
783 ldd->ldd_svindex = 0;
785 if (!IS_MGS(ldd) && (mop.mo_mgs_failnodes == 0)) {
788 fprintf(stderr, "Must specify --mgs or --mgsnode\n");
790 fprintf(stderr, "Must specify --mgsnode\n");
794 if ((IS_MDT(ldd) || IS_OST(ldd)) && ldd->ldd_fsname[0] == '\0') {
796 fprintf(stderr, "Must specify --fsname for MDT/OST device\n");
801 /* These are the permanent mount options (always included) */
802 ret = osd_prepare_lustre(&mop,
803 wanted_mountopts, sizeof(wanted_mountopts));
806 fprintf(stderr, "unable to prepare backend (%d)\n", ret);
811 trim_mountfsoptions(mountopts);
812 if (check_mountfsoptions(mountopts, wanted_mountopts)) {
816 snprintf(ldd->ldd_mount_opts, sizeof(ldd->ldd_mount_opts),
820 if (ldd->ldd_mount_opts[0] == 0)
821 /* use the defaults unless old opts exist */
824 snprintf(ldd->ldd_mount_opts,
825 sizeof(ldd->ldd_mount_opts),
826 "%s", wanted_mountopts);
827 trim_mountfsoptions(ldd->ldd_mount_opts);
831 ret = osd_fix_mountopts(&mop, ldd->ldd_mount_opts,
832 sizeof(ldd->ldd_mount_opts));
835 fprintf(stderr, "unable to fix mountfsoptions (%d)\n", ret);
839 if (server_make_name(ldd->ldd_flags, ldd->ldd_svindex,
840 ldd->ldd_fsname, ldd->ldd_svname)) {
841 printf("unknown server type %#x\n", ldd->ldd_flags);
846 print_ldd("Permanent disk data", ldd);
849 printf("exiting before disk write.\n");
853 if (check_mtab_entry(mop.mo_device, mop.mo_device, NULL, NULL))
856 /* Create the loopback file */
857 if (mop.mo_flags & MO_IS_LOOP) {
858 ret = access(mop.mo_device, F_OK);
863 /* Reformat the loopback file */
864 if (ret != 0 || (mop.mo_flags & MO_FORCEFORMAT)) {
865 ret = loop_format(&mop);
871 ret = loop_setup(&mop);
874 fprintf(stderr, "Loop device setup for %s failed: %s\n",
875 mop.mo_device, strerror(ret));
881 /* Check whether the disk has already been formatted by mkfs.lustre */
882 if (!(mop.mo_flags & MO_FORCEFORMAT)) {
883 ret = osd_is_lustre(mop.mo_device, &mount_type);
886 fprintf(stderr, "Device %s was previously formatted "
887 "for lustre. Use --reformat to reformat it, "
888 "or tunefs.lustre to modify.\n",
894 /* Format the backing filesystem */
895 ret = osd_make_lustre(&mop);
898 fprintf(stderr, "mkfs failed %d\n", ret);
902 /* update svname with '=' to refresh config */
903 if (ldd->ldd_flags & LDD_F_WRITECONF) {
904 struct mount_opts opts;
906 opts.mo_source = mop.mo_device;
907 (void) osd_label_lustre(&opts);
910 /* Rename filesystem fsname */
911 if (mop.mo_flags & MO_RENAME) {
912 ret = osd_rename_fsname(&mop, old_fsname);
917 /* Enable quota accounting */
918 if (mop.mo_flags & MO_QUOTA) {
919 ret = osd_enable_quota(&mop);
924 /* Write our config files */
925 ret = osd_write_ldd(&mop);
928 fprintf(stderr, "failed to write local files\n");
934 ret2 = loop_cleanup(&mop);
938 /* Fix any crazy return values from system() */
939 if (ret != 0 && ((ret & 255) == 0))
943 verrprint("%s: exiting with %d (%s)\n",
944 progname, ret, strerror(ret));