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 /*"optname", inv,ms_mask */
176 /* These flags are parsed by mount, not lustre */
177 { "defaults", 0, 0 }, /* default options */
178 { "remount", 0, MS_REMOUNT}, /* remount with different options */
179 { "rw", 1, MS_RDONLY }, /* read-write */
180 { "ro", 0, MS_RDONLY }, /* read-only */
181 { "exec", 1, MS_NOEXEC }, /* permit execution of binaries */
182 { "noexec", 0, MS_NOEXEC }, /* don't execute binaries */
183 { "suid", 1, MS_NOSUID }, /* honor suid executables */
184 { "nosuid", 0, MS_NOSUID }, /* don't honor suid executables */
185 { "dev", 1, MS_NODEV }, /* interpret device files */
186 { "nodev", 0, MS_NODEV }, /* don't interpret devices */
187 { "sync", 0, MS_SYNCHRONOUS}, /* synchronous I/O */
188 { "async", 1, MS_SYNCHRONOUS}, /* asynchronous I/O */
189 { "atime", 1, MS_NOATIME }, /* set file access time on read */
190 { "noatime", 0, MS_NOATIME }, /* do not set file access time on read */
192 { "diratime", 1, MS_NODIRATIME }, /* set file access time on read */
193 { "nodiratime",0,MS_NODIRATIME }, /* do not set file access time on read */
196 { "relatime", 0, MS_RELATIME }, /* set file access time on read */
197 { "norelatime",1,MS_RELATIME }, /* do not set file access time on read */
199 #ifdef MS_STRICTATIME
200 { "strictatime",0,MS_STRICTATIME }, /* update access time strictly */
202 { "auto", 0, 0 }, /* Can be mounted using -a */
203 { "noauto", 0, 0 }, /* Can only be mounted explicitly */
204 { "nousers", 1, 0 }, /* Forbid ordinary user to mount */
205 { "nouser", 1, 0 }, /* Forbid ordinary user to mount */
206 { "noowner", 1, 0 }, /* Device owner has no special privs */
207 { "_netdev", 0, 0 }, /* Device accessible only via network */
211 /****************************************************************************/
213 /* 1 = don't pass on to lustre
214 0 = pass on to lustre */
215 static int parse_one_option(const char *check, int *flagp)
217 const struct opt_map *opt;
219 for (opt = &opt_map[0]; opt->opt != NULL; opt++) {
220 if (strncmp(check, opt->opt, strlen(opt->opt)) == 0) {
223 *flagp &= ~(opt->mask);
230 /* Assume any unknown options are valid and pass them on. The mount
231 will fail if lmd_parse, ll_options or ldiskfs doesn't recognize it.*/
235 static int append_option(char *options, size_t options_len,
236 const char *param, const char *value)
239 if (options[0] != '\0') {
240 rc = strlcat(options, ",", options_len);
241 if (rc >= options_len)
244 rc = strlcat(options, param, options_len);
245 if (rc >= options_len)
248 rc = strlcat(options, value, options_len);
249 if (rc >= options_len)
254 fprintf(stderr, "error: mount options %s%s too long\n", param, value);
258 /* Replace options with subset of Lustre-specific options, and
259 fill in mount flags */
260 int parse_options(struct mount_opts *mop, char *orig_options,
261 int *flagp, size_t options_len)
263 char *options, *opt, *nextopt, *arg, *val;
266 options = calloc(strlen(orig_options) + 1, 1);
268 nextopt = orig_options;
269 while ((opt = strsep(&nextopt, ","))) {
274 /* Handle retries in a slightly different
277 val = strchr(opt, '=');
278 /* please note that some ldiskfs mount options are also in
279 * the form of param=value. We should pay attention not to
280 * remove those mount options, see bug 22097. */
281 if (val && strncmp(arg, "max_sectors_kb", 14) == 0) {
282 mop->mo_max_sectors_kb = atoi(val + 1);
284 strncmp(arg, "md_stripe_cache_size", 20) == 0) {
285 mop->mo_md_stripe_cache_size = atoi(val + 1);
286 } else if (val && strncmp(arg, "retry", 5) == 0) {
287 mop->mo_retry = atoi(val + 1);
288 if (mop->mo_retry > MAX_RETRIES)
289 mop->mo_retry = MAX_RETRIES;
290 else if (mop->mo_retry < 0)
292 } else if (val && strncmp(arg, "mgssec", 6) == 0) {
293 rc = append_option(options, options_len, opt, NULL);
296 } else if (strncmp(arg, "nosvc", 5) == 0) {
298 rc = append_option(options, options_len, opt, NULL);
301 } else if (strcmp(opt, "force") == 0) {
302 /* XXX special check for 'force' option */
304 printf("force: %d\n", mop->mo_force);
306 } else if (val && strncmp(opt, "skpath=", 7) == 0) {
307 if (strlen(val) + 1 >= sizeof(mop->mo_skpath)) {
309 "%s: shared key path too long\n",
314 strncpy(mop->mo_skpath, val + 1, strlen(val + 1));
316 } else if (parse_one_option(opt, flagp) == 0) {
317 /* pass this on as an option */
318 rc = append_option(options, options_len, opt, NULL);
323 #ifdef MS_STRICTATIME
324 #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(3, 2, 53, 0)
327 * In the future when upstream fixes land in all supported kernels
328 * we should stop forcing MS_STRICTATIME in lustre mounts.
329 * We override the kernel level default of MS_RELATIME for now
330 * due to a kernel vfs level bug in atime updates that fails
331 * to reset timestamps from the future.
333 #warn "remove MS_STRICTATIME override if kernel updates atime from the future"
335 /* set strictatime to default if NOATIME or RELATIME
336 not given explicit */
337 if (!(*flagp & (MS_NOATIME | MS_RELATIME)))
338 *flagp |= MS_STRICTATIME;
340 strcpy(orig_options, options);
347 /* Add mgsnids from ldd params */
348 static int add_mgsnids(struct mount_opts *mop, char *options,
349 const char *params, size_t options_len)
351 char *ptr = (char *)params;
355 while ((ptr = strstr(ptr, PARAM_MGSNODE)) != NULL) {
356 sep = strchr(ptr, ' ');
361 rc = append_option(options, options_len, ptr, NULL);
364 mop->mo_have_mgsnid++;
377 static int clear_update_ondisk(char *source, struct lustre_disk_data *ldd)
379 char wanted_mountopts[512] = "";
380 struct mkfs_opts mkop;
384 memset(&mkop, 0, sizeof(mkop));
386 mkop.mo_ldd.ldd_flags &= ~LDD_F_UPDATE;
387 mkop.mo_flags = MO_NOHOSTID_CHECK; /* Ignore missing hostid */
388 if (strlen(source) > sizeof(mkop.mo_device)-1) {
390 fprintf(stderr, "Device name too long: %s\n", source);
393 strncpy(mkop.mo_device, source, sizeof(mkop.mo_device));
395 ret = osd_prepare_lustre(&mkop,
396 wanted_mountopts, sizeof(wanted_mountopts));
399 fprintf(stderr, "Can't prepare device %s: %s\n",
400 source, strerror(ret));
404 /* Create the loopback file */
405 if (mkop.mo_flags & MO_IS_LOOP) {
406 ret = access(mkop.mo_device, F_OK);
410 fprintf(stderr, "Can't access device %s: %s\n",
411 source, strerror(ret));
415 ret = loop_setup(&mkop);
418 fprintf(stderr, "Loop device setup for %s failed: %s\n",
419 mkop.mo_device, strerror(ret));
423 ret = osd_write_ldd(&mkop);
426 fprintf(stderr, "failed to write local files: %s\n",
430 ret2 = loop_cleanup(&mkop);
437 static int parse_ldd(char *source, struct mount_opts *mop,
438 char *options, size_t options_len)
440 struct lustre_disk_data *ldd = &mop->mo_ldd;
445 rc = osd_is_lustre(source, &ldd->ldd_mount_type);
447 fprintf(stderr, "%s: %s has not been formatted with mkfs.lustre"
448 " or the backend filesystem type is not supported by "
449 "this tool\n", progname, source);
453 rc = osd_read_ldd(source, ldd);
455 fprintf(stderr, "%s: %s failed to read permanent mount"
456 " data: %s\n", progname, source,
457 rc >= 0 ? strerror(rc) : "");
461 if ((IS_MDT(ldd) || IS_OST(ldd)) &&
462 (ldd->ldd_flags & LDD_F_NEED_INDEX)) {
463 fprintf(stderr, "%s: %s has no index assigned "
464 "(probably formatted with old mkfs)\n",
469 if (ldd->ldd_flags & LDD_F_UPGRADE14) {
470 fprintf(stderr, "%s: we cannot upgrade %s from this (very old) "
471 "Lustre version\n", progname, source);
475 if (ldd->ldd_flags & LDD_F_UPDATE)
476 clear_update_ondisk(source, ldd);
478 /* Since we never rewrite ldd, ignore temp flags */
479 ldd->ldd_flags &= ~(LDD_F_VIRGIN | LDD_F_WRITECONF);
481 /* This is to make sure default options go first */
482 temp_options = strdup(options);
483 if (temp_options == NULL) {
484 fprintf(stderr, "%s: can't allocate memory for temp_options\n",
488 strncpy(options, ldd->ldd_mount_opts, options_len);
489 rc = append_option(options, options_len, temp_options, NULL);
494 /* svname of the form lustre:OST1234 means never registered */
495 rc = strlen(ldd->ldd_svname);
496 if (strcmp(ldd->ldd_svname, "MGS") != 0) {
498 fprintf(stderr, "%s: invalid name '%s'\n",
499 progname, ldd->ldd_svname);
501 } else if (ldd->ldd_svname[rc - 8] == ':') {
502 ldd->ldd_svname[rc - 8] = '-';
503 ldd->ldd_flags |= LDD_F_VIRGIN;
504 } else if (ldd->ldd_svname[rc - 8] == '=') {
505 ldd->ldd_svname[rc - 8] = '-';
506 ldd->ldd_flags |= LDD_F_WRITECONF;
509 /* backend osd type */
510 rc = append_option(options, options_len, "osd=",
511 mt_type(ldd->ldd_mount_type));
515 if (!mop->mo_have_mgsnid) {
516 /* Only use disk data if mount -o mgsnode=nid wasn't
518 if (ldd->ldd_flags & LDD_F_SV_TYPE_MGS) {
519 rc = append_option(options, options_len, "mgs", NULL);
522 mop->mo_have_mgsnid++;
524 if (add_mgsnids(mop, options, ldd->ldd_params,
529 /* Better have an mgsnid by now */
530 if (!mop->mo_have_mgsnid) {
531 fprintf(stderr, "%s: missing option mgsnode=<nid>\n",
536 if (ldd->ldd_flags & LDD_F_VIRGIN) {
537 rc = append_option(options, options_len, "virgin", NULL);
541 if (ldd->ldd_flags & LDD_F_UPDATE) {
542 rc = append_option(options, options_len, "update", NULL);
546 if (ldd->ldd_flags & LDD_F_WRITECONF) {
547 rc = append_option(options, options_len, "writeconf", NULL);
551 if (ldd->ldd_flags & LDD_F_NO_PRIMNODE) {
552 rc = append_option(options, options_len, "noprimnode", NULL);
557 /* prefix every lustre parameter with param= so that in-kernel
558 * mount can recognize them properly and send to MGS at registration */
559 start = ldd->ldd_params;
560 while (start && *start != '\0') {
561 while (*start == ' ') start++;
565 start = strchr(cur, ' ');
570 rc = append_option(options, options_len, "param=", cur);
575 /* svname must be last option */
576 rc = append_option(options, options_len, "svname=", ldd->ldd_svname);
581 static void set_defaults(struct mount_opts *mop)
583 memset(mop, 0, sizeof(*mop));
584 mop->mo_usource = NULL;
585 mop->mo_source = NULL;
590 mop->mo_have_mgsnid = 0;
591 mop->mo_md_stripe_cache_size = 16384;
592 mop->mo_orig_options = "";
594 mop->mo_max_sectors_kb = -1;
597 static int parse_opts(int argc, char *const argv[], struct mount_opts *mop)
599 static struct option long_opt[] = {
603 {"nomtab", 0, 0, 'n'},
604 {"options", 1, 0, 'o'},
605 {"verbose", 0, 0, 'v'},
606 {"version", 0, 0, 'V'},
609 char real_path[PATH_MAX] = {'\0'};
611 char path[256], name[256];
616 while ((opt = getopt_long(argc, argv, "fhno:vV",
617 long_opt, NULL)) != EOF){
621 printf("force: %d\n", mop->mo_force);
625 printf("fake: %d\n", mop->mo_fake);
632 printf("nomtab: %d\n", mop->mo_nomtab);
635 mop->mo_orig_options = optarg;
642 fprintf(stdout, "%s %s %s\n", progname,
643 LUSTRE_VERSION_STRING, WITH_LIBMOUNT);
646 fprintf(stderr, "%s: unknown option '%c'\n",
653 if (optind + 2 > argc) {
654 fprintf(stderr, "%s: too few arguments\n", progname);
658 mop->mo_usource = argv[optind];
659 if (!mop->mo_usource) {
664 * Try to get the real path to the device, in case it is a
665 * symbolic link for instance
667 if (realpath(mop->mo_usource, real_path) != NULL) {
668 ptr = strrchr(real_path, '/');
669 if (ptr && strncmp(ptr, "/dm-", 4) == 0 && isdigit(*(ptr + 4))) {
670 snprintf(path, sizeof(path), "/sys/block/%s/dm/name", ptr+1);
671 if ((f = fopen(path, "r"))) {
672 /* read "<name>\n" from sysfs */
673 if (fgets(name, sizeof(name), f) && (sz = strlen(name)) > 1) {
675 snprintf(real_path, sizeof(real_path), "/dev/mapper/%s", name);
680 mop->mo_usource = strdup(real_path);
683 ptr = strstr(mop->mo_usource, ":/");
685 mop->mo_source = convert_hostnames(mop->mo_usource);
689 mop->mo_source = strdup(mop->mo_usource);
692 if (realpath(argv[optind + 1], mop->mo_target) == NULL) {
694 fprintf(stderr, "warning: %s: cannot resolve: %s\n",
695 argv[optind + 1], strerror(errno));
702 /* change label from <fsname>:<index> to
703 * <fsname>-<index> to indicate the device has
704 * been registered. only if the label is
705 * supposed to be changed and target service
706 * is supposed to start */
707 static void label_lustre(struct mount_opts *mop)
712 if (mop->mo_ldd.ldd_flags & (LDD_F_VIRGIN | LDD_F_WRITECONF)) {
713 (void)osd_label_lustre(mop);
715 struct lustre_disk_data ldd;
718 /* device label could be changed after journal recovery,
719 * it should also be relabeled for mount has succeeded. */
720 memset(&ldd, 0, sizeof(ldd));
721 rc = osd_read_ldd(mop->mo_source, &ldd);
723 rc = strlen(ldd.ldd_svname);
724 if (rc >= 8 && ldd.ldd_svname[rc - 8] != '-')
725 (void)osd_label_lustre(mop);
730 int main(int argc, char *const argv[])
732 struct mount_opts mop;
740 progname = strrchr(argv[0], '/');
741 progname = progname ? progname + 1 : argv[0];
745 g_pagesize = sysconf(_SC_PAGESIZE);
746 if (g_pagesize == -1) {
748 printf("error: %d failed to get page size.\n", rc);
751 maxopt_len = MIN(g_pagesize, 64 * 1024);
753 rc = parse_opts(argc, argv, &mop);
758 for (i = 0; i < argc; i++)
759 printf("arg[%d] = %s\n", i, argv[i]);
760 printf("source = %s (%s), target = %s\n", mop.mo_usource,
761 mop.mo_source, mop.mo_target);
762 printf("options = %s\n", mop.mo_orig_options);
765 options = malloc(maxopt_len);
766 if (options == NULL) {
767 fprintf(stderr, "can't allocate memory for options\n");
772 if (strlen(mop.mo_orig_options) >= maxopt_len) {
773 fprintf(stderr, "error: mount options too long\n");
778 strcpy(options, mop.mo_orig_options);
779 rc = parse_options(&mop, options, &flags, maxopt_len);
781 fprintf(stderr, "%s: can't parse options: %s\n",
788 rc = check_mtab_entry(mop.mo_usource, mop.mo_source,
789 mop.mo_target, "lustre");
790 if (rc && !(flags & MS_REMOUNT)) {
791 fprintf(stderr, "%s: according to %s %s is "
792 "already mounted on %s\n", progname, MOUNTED,
793 mop.mo_usource, mop.mo_target);
797 if (!rc && (flags & MS_REMOUNT)) {
798 fprintf(stderr, "%s: according to %s %s is "
799 "not already mounted on %s\n", progname, MOUNTED,
800 mop.mo_usource, mop.mo_target);
805 if (flags & MS_REMOUNT)
808 rc = access(mop.mo_target, F_OK);
811 fprintf(stderr, "%s: %s inaccessible: %s\n", progname,
812 mop.mo_target, strerror(errno));
816 client = (strstr(mop.mo_usource, ":/") != NULL);
822 rc = parse_ldd(mop.mo_source, &mop, options, maxopt_len);
827 /* In Linux 2.4, the target device doesn't get passed to any of our
828 functions. So we'll stick it on the end of the options. */
829 rc = append_option(options, maxopt_len, "device=", mop.mo_source);
834 printf("mounting device %s at %s, flags=%#x options=%s\n",
835 mop.mo_source, mop.mo_target, flags, options);
837 if (!client && osd_tune_lustre(mop.mo_source, &mop)) {
839 fprintf(stderr, "%s: unable to set tunables for %s"
840 " (may cause reduced IO performance)\n",
841 argv[0], mop.mo_source);
845 if (mop.mo_skpath[0] != '\0') {
846 /* Treat shared key failures as fatal */
847 rc = load_shared_keys(&mop);
850 "%s: Error loading shared keys: %s\n",
851 progname, strerror(rc));
855 #endif /* HAVE_GSS */
858 /* flags and target get to lustre_get_sb(), but not
859 * lustre_fill_super(). Lustre ignores the flags, but mount
861 for (i = 0, rc = -EAGAIN; i <= mop.mo_retry && rc != 0; i++) {
862 rc = mount(mop.mo_source, mop.mo_target, "lustre",
863 flags, (void *)options);
869 fprintf(stderr, "%s: mount %s at %s "
870 "failed: %s retries left: "
871 "%d\n", basename(progname),
872 mop.mo_usource, mop.mo_target,
878 int limit = i/2 > 5 ? i/2 : 5;
893 cli = strrchr(mop.mo_usource, ':');
894 if (cli && (strlen(cli) > 2))
899 fprintf(stderr, "%s: mount %s at %s failed: %s\n", progname,
900 mop.mo_usource, mop.mo_target, strerror(errno));
902 fprintf(stderr, "Is the backend filesystem mounted?\n"
903 "Check /etc/mtab and /proc/mounts\n");
905 fprintf(stderr, "Are the lustre modules loaded?\n"
906 "Check /etc/modprobe.conf and "
907 "/proc/filesystems\n");
908 if (errno == ENOTBLK)
909 fprintf(stderr, "Do you need -o loop?\n");
910 if (errno == ENOMEDIUM)
912 "This filesystem needs at least 1 OST\n");
913 if (errno == ENOENT) {
914 fprintf(stderr, "Is the MGS specification correct?\n");
915 fprintf(stderr, "Is the filesystem name correct?\n");
916 fprintf(stderr, "If upgrading, is the copied client log"
917 " valid? (see upgrade docs)\n");
919 if (errno == EALREADY)
920 fprintf(stderr, "The target service is already running."
921 " (%s)\n", mop.mo_usource);
923 fprintf(stderr, "The target service failed to start "
924 "(bad config log?) (%s). "
925 "See /var/log/messages.\n", mop.mo_usource);
927 fprintf(stderr, "Is the MGS running?\n");
928 if (errno == EADDRINUSE)
929 fprintf(stderr, "The target service's index is already "
930 "in use. (%s)\n", mop.mo_usource);
931 if (errno == EINVAL) {
932 fprintf(stderr, "This may have multiple causes.\n");
934 fprintf(stderr, "Is '%s' the correct filesystem"
936 fprintf(stderr, "Are the mount options correct?\n");
937 fprintf(stderr, "Check the syslog for more info.\n");
940 /* May as well try to clean up loop devs */
941 if (strncmp(mop.mo_usource, "/dev/loop", 9) == 0) {
944 sprintf(cmd, "/sbin/losetup -d %s", mop.mo_usource);
945 if ((ret = system(cmd)) < 0)
948 rc = WEXITSTATUS(ret);
952 /* Deal with utab just for client. Note that we ignore
953 * the return value here since it is not worth to fail
954 * mount by prevent some rare cases */
955 if (strstr(mop.mo_usource, ":/") != NULL)
956 update_utab_entry(&mop);
957 if (!mop.mo_nomtab) {
958 rc = update_mtab_entry(mop.mo_usource, mop.mo_target,
959 "lustre", mop.mo_orig_options,
972 /* mo_usource should be freed, but we can rely on the kernel */