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/mount_lustre.c
34 * Author: Robert Read <rread@clusterfs.com>
35 * Author: Nathan Rutman <nathan@clusterfs.com>
50 #include <sys/mount.h>
51 #include <sys/param.h>
52 #include <lustre_ver.h>
55 #include <lnet/nidstr.h>
56 #include <libcfs/util/string.h>
59 #include "mount_utils.h"
61 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 10, 53, 0)
64 * We only #include a kernel level include file here because
65 * important MS_ flag #defines are missing from the SLES version
67 * In the future if SLES updates sys/mount.h to have a more complete
68 * set of flag #defines we should stop including linux/fs.h
70 #if !defined(MS_RDONLY)
76 # define WITH_LIBMOUNT "(libmount)"
78 # define WITH_LIBMOUNT ""
81 #define MAX_RETRIES 99
89 fprintf(out, "\nThis mount helper should only be invoked via the "
90 "mount (8) command,\ne.g. mount -t lustre dev dir\n\n");
91 fprintf(out, "usage: %s [-fhnvV] [-o <mntopt>] <device> <mountpt>\n",
94 "\t<device>: the disk device, or for a client:\n"
95 "\t\t<mgsnid>[:<altmgsnid>...]:/<filesystem>[/<subdir>]\n"
96 "\t<filesystem>: name of the Lustre filesystem (e.g. lustre1)\n"
97 "\t<mountpt>: filesystem mountpoint (e.g. /mnt/lustre)\n"
98 "\t-f|--fake: fake mount (updates /etc/mtab)\n"
99 "\t-o force|--force: force mount even if already in /etc/mtab\n"
100 "\t-h|--help: print this usage message\n"
101 "\t-n|--nomtab: do not update /etc/mtab after mount\n"
102 "\t-v|--verbose: print verbose config settings\n"
103 "\t-V|--version: output build version of the utility and exit\n"
104 "\t<mntopt>: one or more comma separated of:\n"
105 "\t\t(no)flock,(no)user_xattr,(no)acl\n"
106 "\t\tabort_recov: abort server recovery handling\n"
107 "\t\tnosvc: only start MGC/MGS obds\n"
108 "\t\tnomgs: only start target obds, using existing MGS\n"
109 "\t\tnoscrub: NOT auto start OI scrub unless start explicitly\n"
110 "\t\tskip_lfsck: NOT auto resume the paused/crashed LFSCK\n"
111 "\t\texclude=<ostname>[:<ostname>] : colon-separated list of "
112 "inactive OSTs (e.g. lustre-OST0001)\n"
114 "\t\tskpath=<file|directory>: Path to a file or directory of"
115 "key configuration files to load into the kernel keyring\n"
117 "\t\tretry=<num>: number of times mount is retried by client\n"
118 "\t\tmd_stripe_cache_size=<num>: set the raid stripe cache "
119 "size for the underlying raid if present\n");
120 exit((out != stdout) ? EINVAL : 0);
123 /* Get rid of symbolic hostnames for tcp, since kernel can't do lookups */
124 #define MAXNIDSTR 1024
125 static char *convert_hostnames(char *s1)
127 char *converted, *s2 = 0, *c;
129 int left = MAXNIDSTR;
132 converted = malloc(left);
133 if (converted == NULL) {
134 fprintf(stderr, "out of memory: needed %d bytes\n",
139 while ((left > 0) && (*s1 != '/')) {
140 s2 = strpbrk(s1, ",:");
145 nid = libcfs_str2nid(s1);
146 *s2 = sep; /* back to original string */
147 if (nid == LNET_NID_ANY)
149 c += snprintf(c, left, "%s%c", libcfs_nid2str(nid), sep);
150 left = converted + MAXNIDSTR - c;
153 snprintf(c, left, "%s", s1);
156 fprintf(stderr, "%s: Can't parse NID '%s'\n", progname, s1);
161 /*****************************************************************************
163 * This part was cribbed from util-linux/mount/mount.c. There was no clear
164 * license information, but many other files in the package are identified as
165 * GNU GPL, so it's a pretty safe bet that was their intent.
167 ****************************************************************************/
169 const char *opt; /* option name */
170 int inv; /* true if flag value should be inverted */
171 int mask; /* flag mask value */
174 static const struct opt_map opt_map[] = {
175 /* these flags are parsed by mount, not Lustre */
176 { .opt = "async", .mask = MS_SYNCHRONOUS, .inv = 1 }, /* asynchronous I/O */
177 { .opt = "atime", .mask = MS_NOATIME, .inv = 1 }, /* set access time */
178 { .opt = "auto" }, /* allow auto mount */
179 { .opt = "defaults" }, /* default options */
180 { .opt = "dev", .mask = MS_NODEV, .inv = 1 }, /* interpret devs */
181 { .opt = "exec", .mask = MS_NOEXEC, .inv = 1 }, /* allow execution */
183 { .opt = "noatime", .mask = MS_NOATIME }, /* do not set atime */
184 { .opt = "noauto" }, /* mount explicitly */
185 { .opt = "nodev", .mask = MS_NODEV }, /* no interpret devs */
186 { .opt = "noowner", .inv = 1 }, /* no special privs */
187 { .opt = "nosuid", .mask = MS_NOSUID }, /* do not honor suid */
188 { .opt = "nouser", .inv = 1 }, /* users cannot mount */
189 { .opt = "nousers", .inv = 1 }, /* users cannot mount */
190 { .opt = "_netdev" }, /* network only */
191 { .opt = "noexec", .mask = MS_NOEXEC }, /* no execute */
192 { .opt = "remount", .mask = MS_REMOUNT }, /* remount */
193 { .opt = "ro", .mask = MS_RDONLY }, /* read-only */
194 { .opt = "rw", .mask = MS_RDONLY, .inv = 1 }, /* read-write */
195 { .opt = "suid", .mask = MS_NOSUID, .inv = 1 }, /* honor suid */
196 { .opt = "sync", .mask = MS_SYNCHRONOUS }, /* synchronous I/O */
198 { .opt = "diratime", /* set access time */
199 .mask = MS_NODIRATIME, .inv = 1 }, /* on read */
200 { .opt = "nodiratime", /* do not set access */
201 .mask = MS_NODIRATIME }, /* time on read */
204 { .opt = "norelatime", /* do not set rel */
205 .mask = MS_RELATIME, .inv = 1 }, /* access time */
206 { .opt = "relatime", /* set relative */
207 .mask = MS_RELATIME }, /* access time */
209 #ifdef MS_STRICTATIME
210 { .opt = "strictatime",
211 .mask = MS_STRICTATIME }, /* strict access time */
214 /****************************************************************************/
216 /* 1 = don't pass on to lustre
217 0 = pass on to lustre */
218 static int parse_one_option(const char *check, int *flagp)
220 const struct opt_map *opt;
222 for (opt = &opt_map[0]; opt->opt != NULL; opt++) {
223 if (strncmp(check, opt->opt, strlen(opt->opt)) == 0) {
226 *flagp &= ~(opt->mask);
233 /* Assume any unknown options are valid and pass them on. The mount
234 will fail if lmd_parse, ll_options or ldiskfs doesn't recognize it.*/
238 static int append_option(char *options, size_t options_len,
239 const char *param, const char *value)
242 if (options[0] != '\0') {
243 rc = strlcat(options, ",", options_len);
244 if (rc >= options_len)
247 rc = strlcat(options, param, options_len);
248 if (rc >= options_len)
251 rc = strlcat(options, value, options_len);
252 if (rc >= options_len)
257 fprintf(stderr, "error: mount options %s%s too long\n", param, value);
261 /* Replace options with subset of Lustre-specific options, and
262 fill in mount flags */
263 int parse_options(struct mount_opts *mop, char *orig_options,
264 int *flagp, size_t options_len)
266 char *options, *opt, *nextopt, *arg, *val;
269 options = calloc(strlen(orig_options) + 1, 1);
271 nextopt = orig_options;
272 while ((opt = strsep(&nextopt, ","))) {
277 /* Handle retries in a slightly different
280 val = strchr(opt, '=');
281 /* please note that some ldiskfs mount options are also in
282 * the form of param=value. We should pay attention not to
283 * remove those mount options, see bug 22097. */
284 if (val && strncmp(arg, "max_sectors_kb", 14) == 0) {
285 mop->mo_max_sectors_kb = atoi(val + 1);
287 strncmp(arg, "md_stripe_cache_size", 20) == 0) {
288 mop->mo_md_stripe_cache_size = atoi(val + 1);
289 } else if (val && strncmp(arg, "retry", 5) == 0) {
290 mop->mo_retry = atoi(val + 1);
291 if (mop->mo_retry > MAX_RETRIES)
292 mop->mo_retry = MAX_RETRIES;
293 else if (mop->mo_retry < 0)
295 } else if (val && strncmp(arg, "mgssec", 6) == 0) {
296 rc = append_option(options, options_len, opt, NULL);
299 } else if (strncmp(arg, "nosvc", 5) == 0) {
301 rc = append_option(options, options_len, opt, NULL);
304 } else if (strcmp(opt, "force") == 0) {
305 /* XXX special check for 'force' option */
307 printf("force: %d\n", mop->mo_force);
309 } else if (val && strncmp(opt, "skpath=", 7) == 0) {
310 if (strlen(val) + 1 >= sizeof(mop->mo_skpath)) {
312 "%s: shared key path too long\n",
317 strncpy(mop->mo_skpath, val + 1, strlen(val + 1));
319 } else if (parse_one_option(opt, flagp) == 0) {
320 /* pass this on as an option */
321 rc = append_option(options, options_len, opt, NULL);
326 #ifdef MS_STRICTATIME
327 #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(3, 2, 53, 0)
330 * In the future when upstream fixes land in all supported kernels
331 * we should stop forcing MS_STRICTATIME in lustre mounts.
332 * We override the kernel level default of MS_RELATIME for now
333 * due to a kernel vfs level bug in atime updates that fails
334 * to reset timestamps from the future.
336 #warn "remove MS_STRICTATIME override if kernel updates atime from the future"
338 /* set strictatime to default if NOATIME or RELATIME
339 not given explicit */
340 if (!(*flagp & (MS_NOATIME | MS_RELATIME)))
341 *flagp |= MS_STRICTATIME;
343 strcpy(orig_options, options);
350 /* Add mgsnids from ldd params */
351 static int add_mgsnids(struct mount_opts *mop, char *options,
352 const char *params, size_t options_len)
354 char *ptr = (char *)params;
358 while ((ptr = strstr(ptr, PARAM_MGSNODE)) != NULL) {
359 sep = strchr(ptr, ' ');
364 rc = append_option(options, options_len, ptr, NULL);
367 mop->mo_have_mgsnid++;
380 static int clear_update_ondisk(char *source, struct lustre_disk_data *ldd)
382 char wanted_mountopts[512] = "";
383 struct mkfs_opts mkop;
387 memset(&mkop, 0, sizeof(mkop));
389 mkop.mo_ldd.ldd_flags &= ~LDD_F_UPDATE;
390 mkop.mo_flags = MO_NOHOSTID_CHECK; /* Ignore missing hostid */
391 if (strlen(source) > sizeof(mkop.mo_device)-1) {
393 fprintf(stderr, "Device name too long: %s\n", source);
396 strncpy(mkop.mo_device, source, sizeof(mkop.mo_device));
398 ret = osd_prepare_lustre(&mkop,
399 wanted_mountopts, sizeof(wanted_mountopts));
402 fprintf(stderr, "Can't prepare device %s: %s\n",
403 source, strerror(ret));
407 /* Create the loopback file */
408 if (mkop.mo_flags & MO_IS_LOOP) {
409 ret = access(mkop.mo_device, F_OK);
413 fprintf(stderr, "Can't access device %s: %s\n",
414 source, strerror(ret));
418 ret = loop_setup(&mkop);
421 fprintf(stderr, "Loop device setup for %s failed: %s\n",
422 mkop.mo_device, strerror(ret));
426 ret = osd_write_ldd(&mkop);
429 fprintf(stderr, "failed to write local files: %s\n",
433 ret2 = loop_cleanup(&mkop);
440 static int parse_ldd(char *source, struct mount_opts *mop,
441 char *options, size_t options_len)
443 struct lustre_disk_data *ldd = &mop->mo_ldd;
448 rc = osd_is_lustre(source, &ldd->ldd_mount_type);
450 fprintf(stderr, "%s: %s has not been formatted with mkfs.lustre"
451 " or the backend filesystem type is not supported by "
452 "this tool\n", progname, source);
456 rc = osd_read_ldd(source, ldd);
458 fprintf(stderr, "%s: %s failed to read permanent mount"
459 " data: %s\n", progname, source,
460 rc >= 0 ? strerror(rc) : "");
464 if ((IS_MDT(ldd) || IS_OST(ldd)) &&
465 (ldd->ldd_flags & LDD_F_NEED_INDEX)) {
466 fprintf(stderr, "%s: %s has no index assigned "
467 "(probably formatted with old mkfs)\n",
472 if (ldd->ldd_flags & LDD_F_UPGRADE14) {
473 fprintf(stderr, "%s: we cannot upgrade %s from this (very old) "
474 "Lustre version\n", progname, source);
478 if (ldd->ldd_flags & LDD_F_UPDATE)
479 clear_update_ondisk(source, ldd);
481 /* Since we never rewrite ldd, ignore temp flags */
482 ldd->ldd_flags &= ~(LDD_F_VIRGIN | LDD_F_WRITECONF);
484 /* This is to make sure default options go first */
485 temp_options = strdup(options);
486 if (temp_options == NULL) {
487 fprintf(stderr, "%s: can't allocate memory for temp_options\n",
491 strncpy(options, ldd->ldd_mount_opts, options_len);
492 rc = append_option(options, options_len, temp_options, NULL);
497 /* svname of the form lustre:OST1234 means never registered */
498 rc = strlen(ldd->ldd_svname);
499 if (strcmp(ldd->ldd_svname, "MGS") != 0) {
501 fprintf(stderr, "%s: invalid name '%s'\n",
502 progname, ldd->ldd_svname);
504 } else if (ldd->ldd_svname[rc - 8] == ':') {
505 ldd->ldd_svname[rc - 8] = '-';
506 ldd->ldd_flags |= LDD_F_VIRGIN;
507 } else if (ldd->ldd_svname[rc - 8] == '=') {
508 ldd->ldd_svname[rc - 8] = '-';
509 ldd->ldd_flags |= LDD_F_WRITECONF;
512 /* backend osd type */
513 rc = append_option(options, options_len, "osd=",
514 mt_type(ldd->ldd_mount_type));
518 if (!mop->mo_have_mgsnid) {
519 /* Only use disk data if mount -o mgsnode=nid wasn't
521 if (ldd->ldd_flags & LDD_F_SV_TYPE_MGS) {
522 rc = append_option(options, options_len, "mgs", NULL);
525 mop->mo_have_mgsnid++;
527 if (add_mgsnids(mop, options, ldd->ldd_params,
532 /* Better have an mgsnid by now */
533 if (!mop->mo_have_mgsnid) {
534 fprintf(stderr, "%s: missing option mgsnode=<nid>\n",
539 if (ldd->ldd_flags & LDD_F_VIRGIN) {
540 rc = append_option(options, options_len, "virgin", NULL);
544 if (ldd->ldd_flags & LDD_F_UPDATE) {
545 rc = append_option(options, options_len, "update", NULL);
549 if (ldd->ldd_flags & LDD_F_WRITECONF) {
550 rc = append_option(options, options_len, "writeconf", NULL);
554 if (ldd->ldd_flags & LDD_F_NO_PRIMNODE) {
555 rc = append_option(options, options_len, "noprimnode", NULL);
560 /* prefix every lustre parameter with param= so that in-kernel
561 * mount can recognize them properly and send to MGS at registration */
562 start = ldd->ldd_params;
563 while (start && *start != '\0') {
564 while (*start == ' ') start++;
568 start = strchr(cur, ' ');
573 rc = append_option(options, options_len, "param=", cur);
578 /* svname must be last option */
579 rc = append_option(options, options_len, "svname=", ldd->ldd_svname);
584 static void set_defaults(struct mount_opts *mop)
586 memset(mop, 0, sizeof(*mop));
587 mop->mo_usource = NULL;
588 mop->mo_source = NULL;
593 mop->mo_have_mgsnid = 0;
594 mop->mo_md_stripe_cache_size = 16384;
595 mop->mo_orig_options = "";
597 mop->mo_max_sectors_kb = -1;
600 static int parse_opts(int argc, char *const argv[], struct mount_opts *mop)
602 static struct option long_opts[] = {
603 { .val = 1, .name = "force", .has_arg = no_argument },
604 { .val = 'f', .name = "fake", .has_arg = no_argument },
605 { .val = 'h', .name = "help", .has_arg = no_argument },
606 { .val = 'n', .name = "nomtab", .has_arg = no_argument },
607 { .val = 'o', .name = "options", .has_arg = required_argument },
608 { .val = 'v', .name = "verbose", .has_arg = no_argument },
609 { .val = 'V', .name = "version", .has_arg = no_argument },
611 char real_path[PATH_MAX] = {'\0'};
613 char path[256], name[256];
618 while ((opt = getopt_long(argc, argv, "fhno:vV",
619 long_opts, NULL)) != EOF){
623 printf("force: %d\n", mop->mo_force);
627 printf("fake: %d\n", mop->mo_fake);
634 printf("nomtab: %d\n", mop->mo_nomtab);
637 mop->mo_orig_options = optarg;
644 fprintf(stdout, "%s %s %s\n", progname,
645 LUSTRE_VERSION_STRING, WITH_LIBMOUNT);
648 fprintf(stderr, "%s: unknown option '%c'\n",
655 if (optind + 2 > argc) {
656 fprintf(stderr, "%s: too few arguments\n", progname);
660 mop->mo_usource = argv[optind];
661 if (!mop->mo_usource) {
666 * Try to get the real path to the device, in case it is a
667 * symbolic link for instance
669 if (realpath(mop->mo_usource, real_path) != NULL) {
670 ptr = strrchr(real_path, '/');
671 if (ptr && strncmp(ptr, "/dm-", 4) == 0 && isdigit(*(ptr + 4))) {
672 snprintf(path, sizeof(path), "/sys/block/%s/dm/name", ptr+1);
673 if ((f = fopen(path, "r"))) {
674 /* read "<name>\n" from sysfs */
675 if (fgets(name, sizeof(name), f) && (sz = strlen(name)) > 1) {
677 snprintf(real_path, sizeof(real_path), "/dev/mapper/%s", name);
682 mop->mo_usource = strdup(real_path);
685 ptr = strstr(mop->mo_usource, ":/");
687 mop->mo_source = convert_hostnames(mop->mo_usource);
691 mop->mo_source = strdup(mop->mo_usource);
694 if (realpath(argv[optind + 1], mop->mo_target) == NULL) {
696 fprintf(stderr, "warning: %s: cannot resolve: %s\n",
697 argv[optind + 1], strerror(errno));
704 /* change label from <fsname>:<index> to
705 * <fsname>-<index> to indicate the device has
706 * been registered. only if the label is
707 * supposed to be changed and target service
708 * is supposed to start */
709 static void label_lustre(struct mount_opts *mop)
714 if (mop->mo_ldd.ldd_flags & (LDD_F_VIRGIN | LDD_F_WRITECONF)) {
715 (void)osd_label_lustre(mop);
717 struct lustre_disk_data ldd;
720 /* device label could be changed after journal recovery,
721 * it should also be relabeled for mount has succeeded. */
722 memset(&ldd, 0, sizeof(ldd));
723 rc = osd_read_ldd(mop->mo_source, &ldd);
725 rc = strlen(ldd.ldd_svname);
726 if (rc >= 8 && ldd.ldd_svname[rc - 8] != '-')
727 (void)osd_label_lustre(mop);
732 int main(int argc, char *const argv[])
734 struct mount_opts mop;
742 progname = strrchr(argv[0], '/');
743 progname = progname ? progname + 1 : argv[0];
747 g_pagesize = sysconf(_SC_PAGESIZE);
748 if (g_pagesize == -1) {
750 printf("error: %d failed to get page size.\n", rc);
753 maxopt_len = MIN(g_pagesize, 64 * 1024);
755 rc = parse_opts(argc, argv, &mop);
760 for (i = 0; i < argc; i++)
761 printf("arg[%d] = %s\n", i, argv[i]);
762 printf("source = %s (%s), target = %s\n", mop.mo_usource,
763 mop.mo_source, mop.mo_target);
764 printf("options = %s\n", mop.mo_orig_options);
767 options = malloc(maxopt_len);
768 if (options == NULL) {
769 fprintf(stderr, "can't allocate memory for options\n");
774 if (strlen(mop.mo_orig_options) >= maxopt_len) {
775 fprintf(stderr, "error: mount options too long\n");
780 strcpy(options, mop.mo_orig_options);
781 rc = parse_options(&mop, options, &flags, maxopt_len);
783 fprintf(stderr, "%s: can't parse options: %s\n",
790 rc = check_mtab_entry(mop.mo_usource, mop.mo_source,
791 mop.mo_target, "lustre");
792 if (rc && !(flags & MS_REMOUNT)) {
793 fprintf(stderr, "%s: according to %s %s is "
794 "already mounted on %s\n", progname, MOUNTED,
795 mop.mo_usource, mop.mo_target);
799 if (!rc && (flags & MS_REMOUNT)) {
800 fprintf(stderr, "%s: according to %s %s is "
801 "not already mounted on %s\n", progname, MOUNTED,
802 mop.mo_usource, mop.mo_target);
807 if (flags & MS_REMOUNT)
810 rc = access(mop.mo_target, F_OK);
813 fprintf(stderr, "%s: %s inaccessible: %s\n", progname,
814 mop.mo_target, strerror(errno));
818 client = (strstr(mop.mo_usource, ":/") != NULL);
824 rc = parse_ldd(mop.mo_source, &mop, options, maxopt_len);
829 /* In Linux 2.4, the target device doesn't get passed to any of our
830 functions. So we'll stick it on the end of the options. */
831 rc = append_option(options, maxopt_len, "device=", mop.mo_source);
836 printf("mounting device %s at %s, flags=%#x options=%s\n",
837 mop.mo_source, mop.mo_target, flags, options);
839 if (!client && osd_tune_lustre(mop.mo_source, &mop)) {
841 fprintf(stderr, "%s: unable to set tunables for %s"
842 " (may cause reduced IO performance)\n",
843 argv[0], mop.mo_source);
847 if (mop.mo_skpath[0] != '\0') {
848 /* Treat shared key failures as fatal */
849 rc = load_shared_keys(&mop);
852 "%s: Error loading shared keys: %s\n",
853 progname, strerror(rc));
857 #endif /* HAVE_GSS */
860 /* flags and target get to lustre_get_sb(), but not
861 * lustre_fill_super(). Lustre ignores the flags, but mount
863 for (i = 0, rc = -EAGAIN; i <= mop.mo_retry && rc != 0; i++) {
864 rc = mount(mop.mo_source, mop.mo_target, "lustre",
865 flags, (void *)options);
871 fprintf(stderr, "%s: mount %s at %s "
872 "failed: %s retries left: "
873 "%d\n", basename(progname),
874 mop.mo_usource, mop.mo_target,
880 int limit = i/2 > 5 ? i/2 : 5;
895 cli = strrchr(mop.mo_usource, ':');
896 if (cli && (strlen(cli) > 2))
901 fprintf(stderr, "%s: mount %s at %s failed: %s\n", progname,
902 mop.mo_usource, mop.mo_target, strerror(errno));
904 fprintf(stderr, "Is the backend filesystem mounted?\n"
905 "Check /etc/mtab and /proc/mounts\n");
907 fprintf(stderr, "Are the lustre modules loaded?\n"
908 "Check /etc/modprobe.conf and "
909 "/proc/filesystems\n");
910 if (errno == ENOTBLK)
911 fprintf(stderr, "Do you need -o loop?\n");
912 if (errno == ENOMEDIUM)
914 "This filesystem needs at least 1 OST\n");
915 if (errno == ENOENT) {
916 fprintf(stderr, "Is the MGS specification correct?\n");
917 fprintf(stderr, "Is the filesystem name correct?\n");
918 fprintf(stderr, "If upgrading, is the copied client log"
919 " valid? (see upgrade docs)\n");
921 if (errno == EALREADY)
922 fprintf(stderr, "The target service is already running."
923 " (%s)\n", mop.mo_usource);
925 fprintf(stderr, "The target service failed to start "
926 "(bad config log?) (%s). "
927 "See /var/log/messages.\n", mop.mo_usource);
929 fprintf(stderr, "Is the MGS running?\n");
930 if (errno == EADDRINUSE)
931 fprintf(stderr, "The target service's index is already "
932 "in use. (%s)\n", mop.mo_usource);
933 if (errno == EINVAL) {
934 fprintf(stderr, "This may have multiple causes.\n");
936 fprintf(stderr, "Is '%s' the correct filesystem"
938 fprintf(stderr, "Are the mount options correct?\n");
939 fprintf(stderr, "Check the syslog for more info.\n");
942 /* May as well try to clean up loop devs */
943 if (strncmp(mop.mo_usource, "/dev/loop", 9) == 0) {
946 sprintf(cmd, "/sbin/losetup -d %s", mop.mo_usource);
947 if ((ret = system(cmd)) < 0)
950 rc = WEXITSTATUS(ret);
954 /* Deal with utab just for client. Note that we ignore
955 * the return value here since it is not worth to fail
956 * mount by prevent some rare cases */
957 if (strstr(mop.mo_usource, ":/") != NULL)
958 update_utab_entry(&mop);
959 if (!mop.mo_nomtab) {
960 rc = update_mtab_entry(mop.mo_usource, mop.mo_target,
961 "lustre", mop.mo_orig_options,
974 /* mo_usource should be freed, but we can rely on the kernel */