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, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
31 * lustre/obdclass/obd_mount.c
33 * Client mount routines
35 * Author: Nathan Rutman <nathan@clusterfs.com>
39 #define DEBUG_SUBSYSTEM S_CLASS
40 #define D_MOUNT (D_SUPER|D_CONFIG/*|D_WARNING */)
41 #define PRINT_CMD CDEBUG
43 #include <linux/types.h>
44 #include <linux/parser.h>
45 #include <linux/random.h>
46 #include <linux/uuid.h>
47 #include <linux/version.h>
50 #include <obd_class.h>
51 #include <lustre_crypto.h>
52 #include <lustre_log.h>
53 #include <lustre_disk.h>
54 #include <uapi/linux/lustre/lustre_param.h>
56 /**************** config llog ********************/
59 * Get a config log from the MGS and process it.
60 * This func is called for both clients and servers.
61 * Continue to process new statements appended to the logs
62 * (whenever the config lock is revoked) until lustre_end_log
65 * @param sb The superblock is used by the MGC to write to the local copy of
67 * @param logname The name of the llog to replicate from the MGS
68 * @param cfg Since the same MGC may be used to follow multiple config logs
69 * (e.g. ost1, ost2, client), the config_llog_instance keeps the state for
70 * this log, and is added to the mgc's list of logs to follow.
72 int lustre_process_log(struct super_block *sb, char *logname,
73 struct config_llog_instance *cfg)
75 struct lustre_cfg *lcfg;
76 struct lustre_cfg_bufs *bufs;
77 struct lustre_sb_info *lsi = s2lsi(sb);
78 struct obd_device *mgc = lsi->lsi_mgc;
90 /* mgc_process_config */
91 lustre_cfg_bufs_reset(bufs, mgc->obd_name);
92 lustre_cfg_bufs_set_string(bufs, 1, logname);
93 lustre_cfg_bufs_set(bufs, 2, cfg, sizeof(*cfg));
94 lustre_cfg_bufs_set(bufs, 3, &sb, sizeof(sb));
95 OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen));
97 GOTO(out, rc = -ENOMEM);
98 lustre_cfg_init(lcfg, LCFG_LOG_START, bufs);
100 rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
101 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
106 LCONSOLE_ERROR_MSG(0x15b,
107 "%s: Configuration from log %s failed from MGS %d. Check client and MGS are on compatible version.\n",
108 mgc->obd_name, logname, rc);
110 LCONSOLE_ERROR_MSG(0x15c,
111 "%s: Confguration from log %s failed from MGS %d. Communication error between node & MGS, a bad configuration, or other errors. See syslog for more info\n",
112 mgc->obd_name, logname, rc);
116 EXPORT_SYMBOL(lustre_process_log);
118 /* Stop watching this config log for updates */
119 int lustre_end_log(struct super_block *sb, char *logname,
120 struct config_llog_instance *cfg)
122 struct lustre_cfg *lcfg;
123 struct lustre_cfg_bufs bufs;
124 struct lustre_sb_info *lsi = s2lsi(sb);
125 struct obd_device *mgc = lsi->lsi_mgc;
133 /* mgc_process_config */
134 lustre_cfg_bufs_reset(&bufs, mgc->obd_name);
135 lustre_cfg_bufs_set_string(&bufs, 1, logname);
137 lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg));
138 OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
141 lustre_cfg_init(lcfg, LCFG_LOG_END, &bufs);
142 rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
143 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
146 EXPORT_SYMBOL(lustre_end_log);
148 /**************** OBD start *******************/
151 * lustre_cfg_bufs are a holdover from 1.4; we can still set these up from
152 * lctl (and do for echo cli/srv.
154 static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
155 char *s1, char *s2, char *s3, char *s4)
157 struct lustre_cfg_bufs bufs;
158 struct lustre_cfg *lcfg = NULL;
161 CDEBUG(D_TRACE, "lcfg %s %#x %s %s %s %s\n", cfgname,
162 cmd, s1, s2, s3, s4);
164 lustre_cfg_bufs_reset(&bufs, cfgname);
166 lustre_cfg_bufs_set_string(&bufs, 1, s1);
168 lustre_cfg_bufs_set_string(&bufs, 2, s2);
170 lustre_cfg_bufs_set_string(&bufs, 3, s3);
172 lustre_cfg_bufs_set_string(&bufs, 4, s4);
174 OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
177 lustre_cfg_init(lcfg, cmd, &bufs);
178 lcfg->lcfg_nid = nid;
179 rc = class_process_config(lcfg);
180 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
184 static int do_lcfg_nid(char *cfgname, struct lnet_nid *nid, int cmd,
190 if (nid_is_nid4(nid))
191 nid4 = lnet_nid_to_nid4(nid);
193 nidstr = libcfs_nidstr(nid);
194 return do_lcfg(cfgname, nid4, cmd, s1, nidstr, NULL, NULL);
198 * Call class_attach and class_setup. These methods in turn call
199 * OBD type-specific methods.
201 int lustre_start_simple(char *obdname, char *type, char *uuid,
202 char *s1, char *s2, char *s3, char *s4)
206 CDEBUG(D_MOUNT, "Starting OBD %s (typ=%s)\n", obdname, type);
208 rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, NULL, NULL);
210 CERROR("%s attach error %d\n", obdname, rc);
213 rc = do_lcfg(obdname, 0, LCFG_SETUP, s1, s2, s3, s4);
215 CERROR("%s setup error %d\n", obdname, rc);
216 do_lcfg(obdname, 0, LCFG_DETACH, NULL, NULL, NULL, NULL);
220 EXPORT_SYMBOL(lustre_start_simple);
222 static DEFINE_MUTEX(mgc_start_lock);
225 * Set up a MGC OBD to process startup logs
227 * \param sb [in] super block of the MGC OBD
229 * \retval 0 success, otherwise error code
231 int lustre_start_mgc(struct super_block *sb)
233 struct obd_connect_data *data = NULL;
234 struct lustre_sb_info *lsi = s2lsi(sb);
235 struct obd_device *obd;
236 struct obd_export *exp;
237 struct obd_uuid *uuid = NULL;
240 char nidstr[LNET_NIDSTR_SIZE];
241 char *mgcname = NULL, *niduuid = NULL, *mgssec = NULL;
243 int rc = 0, i = 0, j;
248 LASSERT(lsi->lsi_lmd);
250 /* Find the first non-lo MGS NID for our MGC name */
251 if (IS_SERVER(lsi)) {
252 /* mount -o mgsnode=nid */
253 ptr = lsi->lsi_lmd->lmd_mgs;
254 if (lsi->lsi_lmd->lmd_mgs &&
255 (class_parse_nid(lsi->lsi_lmd->lmd_mgs, &nid, &ptr) == 0)) {
257 } else if (IS_MGS(lsi)) {
258 struct lnet_processid id;
260 while ((rc = LNetGetId(i++, &id, true)) != -ENOENT) {
261 if (nid_is_lo0(&id.nid))
268 } else { /* client */
269 /* Use NIDs from mount line: uml1,1@elan:uml2,2@elan:/lustre */
270 ptr = lsi->lsi_lmd->lmd_dev;
271 if (class_parse_nid(ptr, &nid, &ptr) == 0)
275 CERROR("No valid MGS NIDs found.\n");
279 mutex_lock(&mgc_start_lock);
281 libcfs_nidstr_r(&nid, nidstr, sizeof(nidstr));
282 len = strlen(LUSTRE_MGC_OBDNAME) + strlen(nidstr) + 1;
283 OBD_ALLOC(mgcname, len);
284 OBD_ALLOC(niduuid, len + 2);
285 if (mgcname == NULL || niduuid == NULL)
286 GOTO(out_free, rc = -ENOMEM);
287 snprintf(mgcname, len, "%s%s", LUSTRE_MGC_OBDNAME, nidstr);
289 mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
293 GOTO(out_free, rc = -ENOMEM);
295 obd = class_name2obd(mgcname);
296 if (obd && !obd->obd_stopping) {
299 rc = obd_set_info_async(NULL, obd->obd_self_export,
300 strlen(KEY_MGSSEC), KEY_MGSSEC,
301 strlen(mgssec), mgssec, NULL);
305 /* Re-using an existing MGC */
306 atomic_inc(&obd->u.cli.cl_mgc_refcount);
308 /* IR compatibility check, only for clients */
309 if (lmd_is_client(lsi->lsi_lmd)) {
311 int vallen = sizeof(*data);
313 rc = obd_get_info(NULL, obd->obd_self_export,
314 strlen(KEY_CONN_DATA), KEY_CONN_DATA,
317 has_ir = OCD_HAS_FLAG(data, IMP_RECOV);
318 if (has_ir ^ !test_bit(LMD_FLG_NOIR,
319 lsi->lsi_lmd->lmd_flags)) {
320 /* LMD_FLG_NOIR is for test purpose only */
322 "Mounting client with IR setting not compatible with current MGC. Using MGC setting that is IR %s",
323 has_ir ? "enabled" : "disabled");
325 clear_bit(LMD_FLG_NOIR,
326 lsi->lsi_lmd->lmd_flags);
328 set_bit(LMD_FLG_NOIR,
329 lsi->lsi_lmd->lmd_flags);
336 * If we are restarting the MGS, don't try to keep the MGC's
337 * old connection, or registration will fail.
340 CDEBUG(D_MOUNT, "New MGS with live MGC\n");
345 * Try all connections, but only once (again).
346 * We don't want to block another target from starting
347 * (using its local copy of the log), but we do want to connect
348 * if at all possible.
351 CDEBUG(D_MOUNT, "%s:Set MGC reconnect %d\n", mgcname, recov_bk);
352 rc = obd_set_info_async(NULL, obd->obd_self_export,
353 sizeof(KEY_INIT_RECOV_BACKUP),
354 KEY_INIT_RECOV_BACKUP,
355 sizeof(recov_bk), &recov_bk, NULL);
359 CDEBUG(D_MOUNT, "Start MGC '%s'\n", mgcname);
361 /* Add the primary NIDs for the MGS */
363 snprintf(niduuid, len + 2, "%s_%x", mgcname, i);
364 if (IS_SERVER(lsi)) {
365 ptr = lsi->lsi_lmd->lmd_mgs;
366 CDEBUG(D_MOUNT, "mgs NIDs %s.\n", ptr);
368 /* Use local NIDs (including LO) */
369 struct lnet_processid id;
371 while ((rc = LNetGetId(i++, &id, true)) != -ENOENT) {
372 rc = do_lcfg_nid(mgcname, &id.nid,
377 /* Use mgsnode= nids */
378 /* mount -o mgsnode=nid */
379 if (lsi->lsi_lmd->lmd_mgs) {
380 ptr = lsi->lsi_lmd->lmd_mgs;
381 } else if (class_find_param(ptr, PARAM_MGSNODE,
383 CERROR("No MGS NIDs given.\n");
384 GOTO(out_free, rc = -EINVAL);
387 * Add primary MGS NID(s).
388 * Multiple NIDs on one MGS node are separated
391 while (class_parse_nid(ptr, &nid, &ptr) == 0) {
392 rc = do_lcfg_nid(mgcname, &nid,
397 /* Stop at the first failover NID */
402 } else { /* client */
403 /* Use NIDs from mount line: uml1,1@elan:uml2,2@elan:/lustre */
404 ptr = lsi->lsi_lmd->lmd_dev;
405 while (class_parse_nid(ptr, &nid, &ptr) == 0) {
406 rc = do_lcfg_nid(mgcname, &nid, LCFG_ADD_UUID,
410 /* Stop at the first failover NID */
416 CERROR("No valid MGS NIDs found.\n");
417 GOTO(out_free, rc = -EINVAL);
419 lsi->lsi_lmd->lmd_mgs_failnodes = 1;
421 /* Random uuid for MGC allows easier reconnects */
424 GOTO(out_free, rc = -ENOMEM);
426 generate_random_uuid(uuidc.b);
427 snprintf(uuid->uuid, sizeof(*uuid), "%pU", uuidc.b);
430 rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
431 (char *)uuid->uuid, LUSTRE_MGS_OBDNAME,
432 niduuid, NULL, NULL);
436 /* Add any failover MGS NIDs */
438 while (ptr && ((*ptr == ':' ||
439 class_find_param(ptr, PARAM_MGSNODE, &ptr) == 0))) {
440 /* New failover node */
441 sprintf(niduuid, "%s_%x", mgcname, i);
443 while (class_parse_nid_quiet(ptr, &nid, &ptr) == 0) {
444 rc = do_lcfg_nid(mgcname, &nid, LCFG_ADD_UUID,
452 rc = do_lcfg(mgcname, 0, LCFG_ADD_CONN,
453 niduuid, NULL, NULL, NULL);
461 lsi->lsi_lmd->lmd_mgs_failnodes = i;
463 obd = class_name2obd(mgcname);
465 CERROR("Can't find mgcobd %s\n", mgcname);
466 GOTO(out_free, rc = -ENOTCONN);
469 rc = obd_set_info_async(NULL, obd->obd_self_export,
470 strlen(KEY_MGSSEC), KEY_MGSSEC,
471 strlen(mgssec), mgssec, NULL);
476 * Keep a refcount of servers/clients who started with "mount",
477 * so we know when we can get rid of the mgc.
479 atomic_set(&obd->u.cli.cl_mgc_refcount, 1);
481 /* We connect to the MGS at setup, and don't disconnect until cleanup */
482 data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT |
483 OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV |
484 OBD_CONNECT_LVB_TYPE |
485 OBD_CONNECT_BULK_MBITS | OBD_CONNECT_BARRIER |
487 data->ocd_connect_flags2 = OBD_CONNECT2_REP_MBITS |
488 OBD_CONNECT2_LARGE_NID;
490 if (lmd_is_client(lsi->lsi_lmd) &&
491 test_bit(LMD_FLG_NOIR, lsi->lsi_lmd->lmd_flags))
492 data->ocd_connect_flags &= ~OBD_CONNECT_IMP_RECOV;
493 data->ocd_version = LUSTRE_VERSION_CODE;
494 rc = obd_connect(NULL, &exp, obd, uuid, data, NULL);
496 CERROR("connect failed %d\n", rc);
500 obd->u.cli.cl_mgc_mgsexp = exp;
504 * Keep the MGC info in the sb. Note that many lsi's can point
509 mutex_unlock(&mgc_start_lock);
516 OBD_FREE(mgcname, len);
518 OBD_FREE(niduuid, len + 2);
521 EXPORT_SYMBOL(lustre_start_mgc);
523 int lustre_stop_mgc(struct super_block *sb)
525 struct lustre_sb_info *lsi = s2lsi(sb);
526 struct obd_device *obd;
527 char niduuid[MAX_OBD_NAME + 6], *ptr = NULL;
539 mutex_lock(&mgc_start_lock);
540 LASSERT(atomic_read(&obd->u.cli.cl_mgc_refcount) > 0);
541 if (!atomic_dec_and_test(&obd->u.cli.cl_mgc_refcount)) {
543 * This is not fatal, every client that stops
546 CDEBUG(D_MOUNT, "MGC still has %d references.\n",
547 atomic_read(&obd->u.cli.cl_mgc_refcount));
548 GOTO(out, rc = -EBUSY);
552 * The MGC has no recoverable data in any case.
553 * force shotdown set in umount_begin
555 obd->obd_no_recov = 1;
557 if (obd->u.cli.cl_mgc_mgsexp) {
559 * An error is not fatal, if we are unable to send the
560 * disconnect mgs ping evictor cleans up the export
562 rc = obd_disconnect(obd->u.cli.cl_mgc_mgsexp);
564 CDEBUG(D_MOUNT, "disconnect failed %d\n", rc);
568 * Cache the obdname for cleaning the nid uuids, which are
569 * obdname_XX before calling class_manual_cleanup
571 strcpy(niduuid, obd->obd_name);
572 ptr = niduuid + strlen(niduuid);
574 rc = class_manual_cleanup(obd);
578 for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) {
579 sprintf(ptr, "_%x", i);
580 rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID,
581 niduuid, NULL, NULL, NULL);
583 CERROR("del MDC UUID %s failed: rc = %d\n",
587 /* class_import_put will get rid of the additional connections */
588 mutex_unlock(&mgc_start_lock);
591 EXPORT_SYMBOL(lustre_stop_mgc);
593 /***************** lustre superblock **************/
595 struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
597 struct lustre_sb_info *lsi;
604 OBD_ALLOC_PTR(lsi->lsi_lmd);
610 s2lsi_nocast(sb) = lsi;
611 /* we take 1 extra ref for our setup */
612 kref_init(&lsi->lsi_mounts);
614 /* Default umount style */
615 lsi->lsi_flags = LSI_UMOUNT_FAILOVER;
616 INIT_LIST_HEAD(&lsi->lsi_lwp_list);
617 mutex_init(&lsi->lsi_lwp_mutex);
621 EXPORT_SYMBOL(lustre_init_lsi);
623 static int lustre_free_lsi(struct lustre_sb_info *lsi)
627 LASSERT(lsi != NULL);
628 CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi);
630 /* someone didn't call server_put_mount. */
631 LASSERT(kref_read(&lsi->lsi_mounts) == 0);
633 llcrypt_sb_free(lsi);
634 if (lsi->lsi_lmd != NULL) {
635 if (lsi->lsi_lmd->lmd_dev != NULL)
636 OBD_FREE(lsi->lsi_lmd->lmd_dev,
637 strlen(lsi->lsi_lmd->lmd_dev) + 1);
638 if (lsi->lsi_lmd->lmd_profile != NULL)
639 OBD_FREE(lsi->lsi_lmd->lmd_profile,
640 strlen(lsi->lsi_lmd->lmd_profile) + 1);
641 if (lsi->lsi_lmd->lmd_fileset != NULL)
642 OBD_FREE(lsi->lsi_lmd->lmd_fileset,
643 strlen(lsi->lsi_lmd->lmd_fileset) + 1);
644 if (lsi->lsi_lmd->lmd_mgssec != NULL)
645 OBD_FREE(lsi->lsi_lmd->lmd_mgssec,
646 strlen(lsi->lsi_lmd->lmd_mgssec) + 1);
647 if (lsi->lsi_lmd->lmd_opts != NULL)
648 OBD_FREE(lsi->lsi_lmd->lmd_opts,
649 strlen(lsi->lsi_lmd->lmd_opts) + 1);
650 if (lsi->lsi_lmd->lmd_exclude_count)
651 OBD_FREE(lsi->lsi_lmd->lmd_exclude,
652 sizeof(lsi->lsi_lmd->lmd_exclude[0]) *
653 lsi->lsi_lmd->lmd_exclude_count);
654 if (lsi->lsi_lmd->lmd_mgs != NULL)
655 OBD_FREE(lsi->lsi_lmd->lmd_mgs,
656 strlen(lsi->lsi_lmd->lmd_mgs) + 1);
657 if (lsi->lsi_lmd->lmd_osd_type != NULL)
658 OBD_FREE(lsi->lsi_lmd->lmd_osd_type,
659 strlen(lsi->lsi_lmd->lmd_osd_type) + 1);
660 if (lsi->lsi_lmd->lmd_params != NULL)
661 OBD_FREE(lsi->lsi_lmd->lmd_params, 4096);
662 if (lsi->lsi_lmd->lmd_nidnet != NULL)
663 OBD_FREE(lsi->lsi_lmd->lmd_nidnet,
664 strlen(lsi->lsi_lmd->lmd_nidnet) + 1);
666 OBD_FREE_PTR(lsi->lsi_lmd);
669 LASSERT(lsi->lsi_llsbi == NULL);
675 static void lustre_put_lsi_free(struct kref *kref)
677 struct lustre_sb_info *lsi = container_of(kref, struct lustre_sb_info,
680 if (IS_SERVER(lsi) && lsi->lsi_osd_exp) {
681 lu_device_put(&lsi->lsi_dt_dev->dd_lu_dev);
682 lsi->lsi_osd_exp->exp_obd->obd_lvfs_ctxt.dt = NULL;
683 lsi->lsi_dt_dev = NULL;
684 obd_disconnect(lsi->lsi_osd_exp);
685 /* wait till OSD is gone */
686 obd_zombie_barrier();
688 lustre_free_lsi(lsi);
692 * The lsi has one reference for every server that is using the disk -
693 * e.g. MDT, MGS, and potentially MGC
695 int lustre_put_lsi(struct super_block *sb)
697 struct lustre_sb_info *lsi = s2lsi(sb);
701 LASSERT(lsi != NULL);
703 CDEBUG(D_MOUNT, "put %p %d\n", sb, kref_read(&lsi->lsi_mounts));
704 if (kref_put(&lsi->lsi_mounts, lustre_put_lsi_free)) {
705 s2lsi_nocast(sb) = NULL;
710 EXPORT_SYMBOL(lustre_put_lsi);
713 * The goal of this function is to extract the file system name
714 * from the OBD name. This can come in two flavors. One is
715 * fsname-MDTXXXX or fsname-XXXXXXX were X is a hexadecimal
716 * number. In both cases we should return fsname. If it is
717 * not a valid OBD name it is assumed to be the file system
720 void obdname2fsname(const char *tgt, char *fsname, size_t buflen)
727 * First we have to see if the @tgt has '-' at all. It is
728 * valid for the user to request something like
729 * lctl set_param -P llite.lustre*.xattr_cache=0
731 ptr = strrchr(tgt, '-');
733 /* No '-' means it could end in '*' */
734 ptr = strchr(tgt, '*');
736 /* No '*' either. Assume tgt = fsname */
744 /* tgt format fsname-MDT0000-* */
745 if ((!strncmp(ptr, "-MDT", 4) ||
746 !strncmp(ptr, "-OST", 4)) &&
747 (isxdigit(ptr[4]) && isxdigit(ptr[5]) &&
748 isxdigit(ptr[6]) && isxdigit(ptr[7]))) {
754 * tgt_format fsname-cli'dev'-'uuid' except for the llite case
755 * which are named fsname-'uuid'. Examples:
757 * lustre-clilov-ffff88104db5b800
758 * lustre-ffff88104db5b800 (for llite device)
760 * The length of the OBD uuid can vary on different platforms.
761 * This test if any invalid characters are in string. Allow
762 * wildcards with '*' character.
765 if (!strspn(ptr, "0123456789abcdefABCDEF*")) {
771 * Now that we validated the device name lets extract the
772 * file system name. Most of the names in this class will
773 * have '-cli' in its name which needs to be dropped. If
774 * it doesn't have '-cli' then its a llite device which
775 * ptr already points to the start of the uuid string.
777 tmp = strstr(tgt, "-cli");
784 len = min_t(size_t, len, LUSTRE_MAXFSNAME);
785 snprintf(fsname, buflen, "%.*s", (int)len, tgt);
789 EXPORT_SYMBOL(obdname2fsname);
793 * <FSNAME><SEPARATOR><TYPE><INDEX>
794 * FSNAME is between 1 and 8 characters (inclusive).
795 * Excluded characters are '/' and ':'
796 * SEPARATOR is either ':' or '-'
797 * TYPE: "OST", "MDT", etc.
798 * INDEX: Hex representation of the index
802 * Get the fsname ("lustre") from the server name ("lustre-OST003F").
803 * @param [in] svname server name including type and index
804 * @param [out] fsname Buffer to copy filesystem name prefix into.
805 * Must have at least 'strlen(fsname) + 1' chars.
806 * @param [out] endptr if endptr isn't NULL it is set to end of fsname
809 int server_name2fsname(const char *svname, char *fsname, const char **endptr)
813 dash = svname + strnlen(svname, LUSTRE_MAXFSNAME);
814 for (; dash > svname && *dash != '-' && *dash != ':'; dash--)
819 if (fsname != NULL) {
820 strncpy(fsname, svname, dash - svname);
821 fsname[dash - svname] = '\0';
829 EXPORT_SYMBOL(server_name2fsname);
831 #ifdef HAVE_SERVER_SUPPORT
833 * Get service name (svname) from string
835 * if endptr isn't NULL it is set to end of fsname *
837 int server_name2svname(const char *label, char *svname, const char **endptr,
843 /* We use server_name2fsname() just for parsing */
844 rc = server_name2fsname(label, NULL, &dash);
851 rc = strscpy(svname, dash + 1, svsize);
857 EXPORT_SYMBOL(server_name2svname);
858 #endif /* HAVE_SERVER_SUPPORT */
861 * check server name is OST.
863 int server_name_is_ost(const char *svname)
868 /* We use server_name2fsname() just for parsing */
869 rc = server_name2fsname(svname, NULL, &dash);
875 if (strncmp(dash, "OST", 3) == 0)
879 EXPORT_SYMBOL(server_name_is_ost);
882 * Get the index from the target name MDTXXXX/OSTXXXX
883 * rc = server type, or rc < 0 on error
885 int target_name2index(const char *tgtname, u32 *idx, const char **endptr)
887 const char *dash = tgtname;
891 if (strncmp(dash, "MDT", 3) == 0)
892 type = LDD_F_SV_TYPE_MDT;
893 else if (strncmp(dash, "OST", 3) == 0)
894 type = LDD_F_SV_TYPE_OST;
900 if (strncmp(dash, "all", 3) == 0) {
903 return type | LDD_F_SV_ALL;
906 len = strspn(dash, "0123456789ABCDEFabcdef");
910 if (strlen(dash) != len) {
914 memcpy(num, dash, sizeof(num) - 1);
915 rc = kstrtou16(num, 16, &index);
919 rc = kstrtou16(dash, 16, &index);
928 *endptr = dash + len;
932 EXPORT_SYMBOL(target_name2index);
935 * Get the index from the OBD name.
936 * rc = server type, or
938 * if endptr isn't NULL it is set to end of name
940 int server_name2index(const char *svname, __u32 *idx, const char **endptr)
945 /* We use server_name2fsname() just for parsing */
946 rc = server_name2fsname(svname, NULL, &dash);
951 rc = target_name2index(dash, idx, endptr);
955 /* Account for -mdc after index that is possible when specifying mdt */
956 if (endptr != NULL && strncmp(LUSTRE_MDC_NAME, *endptr + 1,
957 sizeof(LUSTRE_MDC_NAME)-1) == 0)
958 *endptr += sizeof(LUSTRE_MDC_NAME);
962 EXPORT_SYMBOL(server_name2index);
964 /*************** mount common betweeen server and client ***************/
967 int lustre_common_put_super(struct super_block *sb)
973 CDEBUG(D_MOUNT, "dropping sb %p\n", sb);
975 /* Drop a ref to the MGC */
976 rc = lustre_stop_mgc(sb);
977 if (rc && (rc != -ENOENT)) {
979 CERROR("Can't stop MGC: %d\n", rc);
983 * BUSY just means that there's some other OBD that
984 * needs the mgc. Let him clean it up.
986 CDEBUG(D_MOUNT, "MGC still in use\n");
988 /* Drop a ref to the mounted disk */
993 EXPORT_SYMBOL(lustre_common_put_super);
995 static void lmd_print(struct lustre_mount_data *lmd)
999 PRINT_CMD(D_MOUNT, " mount data:\n");
1000 if (lmd_is_client(lmd))
1001 PRINT_CMD(D_MOUNT, "profile: %s\n", lmd->lmd_profile);
1002 PRINT_CMD(D_MOUNT, "device: %s\n", lmd->lmd_dev);
1005 PRINT_CMD(D_MOUNT, "options: %s\n", lmd->lmd_opts);
1007 if (lmd->lmd_recovery_time_soft)
1008 PRINT_CMD(D_MOUNT, "recovery time soft: %d\n",
1009 lmd->lmd_recovery_time_soft);
1011 if (lmd->lmd_recovery_time_hard)
1012 PRINT_CMD(D_MOUNT, "recovery time hard: %d\n",
1013 lmd->lmd_recovery_time_hard);
1015 for (i = 0; i < lmd->lmd_exclude_count; i++) {
1016 PRINT_CMD(D_MOUNT, "exclude %d: OST%04x\n", i,
1017 lmd->lmd_exclude[i]);
1021 /* Is this server on the exclusion list */
1022 int lustre_check_exclusion(struct super_block *sb, char *svname)
1024 struct lustre_sb_info *lsi = s2lsi(sb);
1025 struct lustre_mount_data *lmd = lsi->lsi_lmd;
1031 rc = server_name2index(svname, &index, NULL);
1032 if (rc != LDD_F_SV_TYPE_OST)
1033 /* Only exclude OSTs */
1036 CDEBUG(D_MOUNT, "Check exclusion %s (%d) in %d of %s\n", svname,
1037 index, lmd->lmd_exclude_count, lmd->lmd_dev);
1039 for (i = 0; i < lmd->lmd_exclude_count; i++) {
1040 if (index == lmd->lmd_exclude[i]) {
1041 CWARN("Excluding %s (on exclusion list)\n", svname);
1048 /* mount -v -o exclude=lustre-OST0001:lustre-OST0002 -t lustre ... */
1049 static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
1051 const char *s1 = ptr, *s2;
1052 __u32 *exclude_list;
1059 * The shortest an ost name can be is 8 chars: -OST0000.
1060 * We don't actually know the fsname at this time, so in fact
1061 * a user could specify any fsname.
1063 devmax = strlen(ptr) / 8 + 1;
1065 /* temp storage until we figure out how many we have */
1066 OBD_ALLOC_PTR_ARRAY(exclude_list, devmax);
1070 /* we enter this fn pointing at the '=' */
1071 while (*s1 && *s1 != ' ' && *s1 != ',') {
1073 rc = server_name2index(s1, &index, &s2);
1075 CERROR("Can't parse server name '%s': rc = %d\n",
1079 if (rc == LDD_F_SV_TYPE_OST)
1080 exclude_list[lmd->lmd_exclude_count++] = index;
1082 CDEBUG(D_MOUNT, "ignoring exclude %.*s: type = %#x\n",
1083 (uint)(s2-s1), s1, rc);
1086 * now we are pointing at ':' (next exclude)
1087 * or ',' (end of excludes)
1089 if (lmd->lmd_exclude_count >= devmax)
1092 if (rc >= 0) /* non-err */
1095 if (lmd->lmd_exclude_count) {
1096 /* permanent, freed in lustre_free_lsi */
1097 OBD_ALLOC_PTR_ARRAY(lmd->lmd_exclude,
1098 lmd->lmd_exclude_count);
1099 if (lmd->lmd_exclude) {
1100 memcpy(lmd->lmd_exclude, exclude_list,
1101 sizeof(index) * lmd->lmd_exclude_count);
1104 lmd->lmd_exclude_count = 0;
1107 OBD_FREE_PTR_ARRAY(exclude_list, devmax);
1111 static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
1113 int length = strlen(ptr);
1115 if (lmd->lmd_mgssec != NULL) {
1116 OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1);
1117 lmd->lmd_mgssec = NULL;
1120 OBD_ALLOC(lmd->lmd_mgssec, length + 1);
1121 if (lmd->lmd_mgssec == NULL)
1124 memcpy(lmd->lmd_mgssec, ptr, length);
1125 lmd->lmd_mgssec[length] = '\0';
1129 static int lmd_parse_network(struct lustre_mount_data *lmd, char *ptr)
1131 int length = strlen(ptr);
1133 if (lmd->lmd_nidnet != NULL) {
1134 OBD_FREE(lmd->lmd_nidnet, strlen(lmd->lmd_nidnet) + 1);
1135 lmd->lmd_nidnet = NULL;
1138 OBD_ALLOC(lmd->lmd_nidnet, length + 1);
1139 if (lmd->lmd_nidnet == NULL)
1142 memcpy(lmd->lmd_nidnet, ptr, length);
1143 lmd->lmd_nidnet[length] = '\0';
1147 static int lmd_parse_string(char **handle, char *ptr)
1149 if (!handle || !ptr)
1152 OBD_FREE(*handle, strlen(*handle) + 1);
1155 *handle = kstrdup(ptr, GFP_NOFS);
1159 OBD_ALLOC_POST(*handle, strlen(ptr) + 1, "kmalloced");
1164 /* Collect multiple values for mgsnid specifiers */
1165 static int lmd_parse_mgs(struct lustre_mount_data *lmd, char *ptr, char **tail)
1167 int length = strlen(ptr);
1168 struct lnet_nid nid;
1173 /* Find end of NID-list */
1174 while (class_parse_nid_quiet(*tail, &nid, tail) == 0)
1177 if (next && next != *tail)
1178 length += *tail - next + 1;
1180 LCONSOLE_ERROR_MSG(0x159, "Can't parse NID '%s'\n", ptr);
1184 if (lmd->lmd_mgs != NULL)
1185 oldlen = strlen(lmd->lmd_mgs) + 1;
1187 OBD_ALLOC(mgsnid, oldlen + length + 1);
1191 if (lmd->lmd_mgs != NULL) {
1192 /* Multiple mgsnid= are taken to mean failover locations */
1193 memcpy(mgsnid, lmd->lmd_mgs, oldlen);
1194 mgsnid[oldlen - 1] = ':';
1195 OBD_FREE(lmd->lmd_mgs, oldlen);
1198 if (next && next != *tail)
1199 snprintf(mgsnid + oldlen, length + 1, "%s,%.*s", ptr,
1200 (int)(*tail - next + 1), next);
1202 snprintf(mgsnid + oldlen, length + 1, "%s", ptr);
1203 lmd->lmd_mgs = mgsnid;
1208 enum lmd_mnt_flags {
1209 LMD_OPT_RECOVERY_TIME_SOFT = LMD_FLG_NUM_FLAGS + 1,
1210 LMD_OPT_RECOVERY_TIME_HARD,
1222 static const match_table_t lmd_flags_table = {
1223 {LMD_FLG_SKIP_LFSCK, "skip_lfsck"},
1224 {LMD_FLG_ABORT_RECOV, "abort_recov"},
1225 {LMD_FLG_ABORT_RECOV, "abort_recovery"},
1226 {LMD_FLG_NOSVC, "nosvc"},
1227 {LMD_FLG_MGS, "mgs"},
1228 {LMD_FLG_NOMGS, "nomgs"},
1229 {LMD_FLG_WRITECONF, "writeconf"},
1230 {LMD_FLG_NOIR, "noir"},
1231 {LMD_FLG_NOSCRUB, "noscrub"},
1232 {LMD_FLG_NO_PRIMNODE, "noprimnode"},
1233 {LMD_FLG_VIRGIN, "virgin"},
1234 {LMD_FLG_UPDATE, "update"},
1235 {LMD_FLG_DEV_RDONLY, "rdonly_dev"},
1236 {LMD_FLG_NO_CREATE, "no_create"},
1237 {LMD_FLG_NO_CREATE, "no_precreate"},
1238 {LMD_FLG_LOCAL_RECOV, "localrecov"},
1239 {LMD_FLG_ABORT_RECOV_MDT, "abort_recov_mdt"},
1240 {LMD_FLG_ABORT_RECOV_MDT, "abort_recovery_mdt"},
1241 {LMD_FLG_NO_LOCAL_LOGS, "nolocallogs"},
1243 {LMD_OPT_RECOVERY_TIME_SOFT, "recovery_time_soft=%u"},
1244 {LMD_OPT_RECOVERY_TIME_HARD, "recovery_time_hard=%u"},
1245 {LMD_OPT_MGSNODE, "mgsnode=%s"},
1246 {LMD_OPT_MGSSEC, "mgssec=%s"},
1247 {LMD_OPT_EXCLUDE, "exclude=%s"},
1248 {LMD_OPT_SVNAME, "svname=%s"},
1249 {LMD_OPT_PARAM, "param=%s"},
1250 {LMD_OPT_OSD, "osd=%s"},
1251 {LMD_OPT_NETWORK, "network=%s"},
1252 {LMD_OPT_DEVICE, "device=%s"}, /* should be last */
1253 {LMD_NUM_MOUNT_OPT, NULL}
1257 * Find the first delimiter; comma; from the specified \a buf and
1258 * make \a *endh point to the string starting with the delimiter.
1259 * The character ':' is also a delimiter for Lustre but not match_table
1260 * so the string is not split on it. Making it safe to ignore.
1262 * @buf a delimiter-separated string
1263 * @endh a pointer to a pointer that will point to the string
1264 * starting with the delimiter
1266 * Returns: true if delimiter is found, false if delimiter is not found
1268 static bool lmd_find_delimiter(char *buf, char **endh)
1270 substring_t args[LMD_NUM_MOUNT_OPT];
1278 /* No more options so we are done */
1279 end = strchr(buf, ',');
1284 tmp = kstrndup(buf, len, GFP_KERNEL);
1289 args[0].from = NULL;
1290 token = match_token(tmp, lmd_flags_table, args);
1292 if (token != LMD_NUM_MOUNT_OPT)
1302 * Make sure the string in \a buf is of a valid formt.
1304 * @buf a delimiter-separated string
1306 * Returns: true if string valid, false if string contains errors
1308 static bool lmd_validate_param(char *buf)
1316 pos = strcspn(c, "[]");
1321 /* Not a valid mount string */
1323 CWARN("invalid mount string format\n");
1328 char *right = strchr(c, ']'), *tmp;
1330 /* invalid mount string */
1332 CWARN("invalid mount string format\n");
1337 /* Test for [ .. [ .. ] */
1338 tmp = strchr(c, '[');
1339 if (tmp && tmp < right) {
1340 CWARN("invalid mount string format\n");
1344 /* Test for [ .. @ .. ] which means brackets
1345 * span more than one NID string.
1347 tmp = strchr(c, '@');
1348 if (tmp && tmp < right) {
1349 CWARN("invalid mount string format\n");
1361 * Find the first valid string delimited by comma or colon from the specified
1362 * @buf and parse it to see whether it's a valid nid list. If yes, @*endh
1363 * will point to the next string starting with the delimiter.
1365 * @buf: a delimiter-separated string
1367 * Returns: false if the string is a valid nid list
1368 * true if the string is not a valid nid list
1370 static bool lmd_parse_nidlist(char *buf)
1379 end = strchr(buf, '=');
1383 while ((end = strchr(buf, '@')) != NULL) {
1384 size_t pos = strcspn(end, ":,");
1390 /* FIXME !!! Add IPv6 support to cfs_parse_nidlist */
1391 if (strchr(buf, ':')) {
1392 struct lnet_nid nid;
1394 if (libcfs_strnid(&nid, buf) < 0) {
1399 if (cfs_parse_nidlist(buf, &nidlist) < 0) {
1403 cfs_free_nidlist(&nidlist);
1416 * Parse mount line options
1417 * e.g. mount -v -t lustre -o abort_recov uml1:uml2:/lustre-client /mnt/lustre
1418 * dev is passed as device=uml1:/lustre by mount.lustre_tgt
1420 int lmd_parse(char *options, struct lustre_mount_data *lmd)
1422 char *s1, *s2, *opts, *orig_opts, *devname = NULL;
1423 struct lustre_mount_data *raw = (struct lustre_mount_data *)options;
1429 LCONSOLE_ERROR_MSG(0x162,
1430 "Missing mount data: check /sbin/mount.lustre_tgt is installed.\n");
1434 /* Options should be a string - try to detect old lmd data */
1435 if ((raw->lmd_magic & 0xffffff00) == (LMD_MAGIC & 0xffffff00)) {
1436 LCONSOLE_ERROR_MSG(0x163,
1437 "Using an old version of /sbin/mount.lustre. Please install version %s\n",
1438 LUSTRE_VERSION_STRING);
1441 lmd->lmd_magic = LMD_MAGIC;
1443 /* Don't stomp on lmd_opts */
1444 opts = kstrdup(options, GFP_KERNEL);
1450 OBD_ALLOC(lmd->lmd_params, LMD_PARAMS_MAXLEN);
1451 if (!lmd->lmd_params)
1452 GOTO(invalid, rc = -ENOMEM);
1453 lmd->lmd_params[0] = '\0';
1455 /* Set default flags here */
1456 while ((s1 = strsep(&opts, ",")) != NULL) {
1457 int time_min = OBD_RECOVERY_TIME_MIN, tmp;
1458 substring_t args[LMD_NUM_MOUNT_OPT];
1464 * Initialize args struct so we know whether arg was
1465 * found; some options take optional arguments.
1468 args[0].from = NULL;
1469 token = match_token(s1, lmd_flags_table, args);
1470 if (token == LMD_NUM_MOUNT_OPT) {
1471 if (match_wildcard("iam", s1) ||
1472 match_wildcard("hsm", s1))
1475 /* Normally we would error but client and
1476 * server mounting is intertwine. So pass
1477 * off unknown args to ll_options instead.
1481 /* We found a known server option. Filter out
1482 * the result out of the options string. The
1483 * reset will be stored in lmd_opts.
1485 char *tmp = strstr(options, s1);
1487 if (strcmp(tmp, s1) != 0) {
1488 s2 = tmp + strlen(s1) + 1;
1489 memmove(tmp, s2, strlen(s2) + 1);
1496 * Client options are parsed in ll_options: eg. flock,
1501 * Parse non-ldiskfs options here. Rather than modifying
1502 * ldiskfs, we just zero these out here
1505 case LMD_FLG_ABORT_RECOV_MDT:
1506 case LMD_FLG_ABORT_RECOV:
1507 case LMD_FLG_NO_CREATE:
1508 case LMD_FLG_NOIR: /* test purpose only. */
1511 case LMD_FLG_NOSCRUB:
1512 case LMD_FLG_SKIP_LFSCK:
1513 case LMD_FLG_DEV_RDONLY:
1514 case LMD_FLG_WRITECONF:
1515 case LMD_FLG_NO_LOCAL_LOGS:
1516 case LMD_FLG_UPDATE:
1517 case LMD_FLG_VIRGIN:
1518 case LMD_FLG_NO_PRIMNODE:
1519 case LMD_FLG_MGS: /* We are an MGS */
1520 case LMD_FLG_LOCAL_RECOV:
1521 set_bit(token, lmd->lmd_flags);
1523 case LMD_OPT_RECOVERY_TIME_SOFT:
1524 rc = match_int(args, &tmp);
1526 lmd->lmd_recovery_time_soft = max_t(int, tmp,
1529 case LMD_OPT_RECOVERY_TIME_HARD:
1530 rc = match_int(args, &tmp);
1532 lmd->lmd_recovery_time_hard = max_t(int, tmp,
1535 case LMD_OPT_MGSNODE:
1536 /* Assume the next mount opt is the first
1537 * invalid NID we get to.
1539 rc = lmd_parse_mgs(lmd, args->from, &opts);
1543 if (strcmp(options, opts) != 0) {
1544 s2 = strstr(options, opts);
1549 case LMD_OPT_MGSSEC:
1550 rc = lmd_parse_mgssec(lmd, args->from);
1552 case LMD_OPT_EXCLUDE:
1553 /* ost exclusion list */
1554 rc = lmd_make_exclusion(lmd, args->from);
1556 case LMD_OPT_SVNAME:
1557 rc = lmd_parse_string(&lmd->lmd_profile, args->from);
1559 case LMD_OPT_PARAM: {
1560 size_t length = strlen(args->from), params_length;
1561 char *tail = NULL, *entry;
1563 params_length = strlen(lmd->lmd_params);
1564 if (params_length + length + 1 >= LMD_PARAMS_MAXLEN) {
1568 entry = lmd->lmd_params + params_length;
1569 strncat(lmd->lmd_params, args->from, length);
1571 /* Find end of param string */
1572 while (lmd_find_delimiter(opts, &tail)) {
1573 params_length = strlen(lmd->lmd_params);
1574 /* match_table splits by ',' so fill it in */
1575 lmd->lmd_params[params_length++] = ',';
1577 length = tail - opts + 1;
1580 if (params_length + length + 1 >=
1581 LMD_PARAMS_MAXLEN) {
1586 strscpy(lmd->lmd_params + params_length,
1591 lmd->lmd_params[params_length + length] = '\0';
1593 if (!lmd_validate_param(entry)) {
1598 /* param contains NIDs */
1599 if (strchr(entry, '@') && lmd_parse_nidlist(entry)) {
1604 /* remove params from opts string from options string */
1605 if (strlen(args->from) != strlen(entry)) {
1606 char *tmp = entry + strlen(args->from) + 1;
1608 s2 = strstr(options, tmp);
1610 size_t len = strlen(s2) - strlen(tmp);
1612 memmove(s2, s2 + strlen(tmp) + 1, len);
1616 strlcat(lmd->lmd_params, " ", LMD_PARAMS_MAXLEN);
1623 rc = lmd_parse_string(&lmd->lmd_osd_type, args->from);
1625 case LMD_OPT_DEVICE: {
1628 /* match_table splits strings at ',' so we need to
1629 * piece things back together.
1632 len = strlen(opts) + 1;
1634 /* Move to last part of device string */
1635 s2 = strchr(opts, '/');
1637 GOTO(invalid, rc = -EINVAL);
1639 /* See if more options exist */
1640 s2 = strchr(s2, ',');
1644 len += strlen(args->from) + 1;
1646 /* Freed in lustre_free_lsi */
1647 OBD_ALLOC(lmd->lmd_dev, len);
1649 GOTO(invalid, rc = -ENOMEM);
1652 snprintf(lmd->lmd_dev, len, "%s,%s",
1655 strscpy(lmd->lmd_dev, args->from, len);
1657 devname = lmd->lmd_dev;
1659 /* remove the split string 'opts' from options */
1661 s1 = strstr(options, opts);
1663 /* opts start after args->from so
1666 len -= strlen(args->from) + 2;
1668 memmove(options, s2, strlen(s2) + 1);
1674 case LMD_OPT_NETWORK:
1675 rc = lmd_parse_network(lmd, args->from);
1676 /* check if LNet dynamic peer discovery is activated */
1677 if (LNetGetPeerDiscoveryStatus()) {
1678 CERROR("LNet Dynamic Peer Discovery is enabled on this node. 'network' mount option cannot be taken into account.\n");
1688 LCONSOLE_ERROR_MSG(0x164,
1689 "Can't find device name (need mount option 'device=...')\n");
1690 GOTO(invalid, rc = -ENODEV);
1693 s1 = strstr(devname, ":/");
1696 set_bit(LMD_FLG_CLIENT, lmd->lmd_flags);
1697 /* Remove leading /s from fsname */
1698 while (*++s1 == '/')
1701 while (*s2 != '/' && *s2 != '\0')
1703 /* Freed in lustre_free_lsi */
1704 OBD_ALLOC(lmd->lmd_profile, s2 - s1 + 8);
1705 if (!lmd->lmd_profile)
1706 GOTO(invalid, rc = -ENOMEM);
1708 strncat(lmd->lmd_profile, s1, s2 - s1);
1709 strncat(lmd->lmd_profile, "-client", 7);
1712 s2 = s1 + strlen(s1) - 1;
1713 /* Remove padding /s from fileset */
1717 OBD_ALLOC(lmd->lmd_fileset, s2 - s1 + 2);
1718 if (!lmd->lmd_fileset)
1719 GOTO(invalid, rc = -ENOMEM);
1720 strncat(lmd->lmd_fileset, s1, s2 - s1 + 1);
1724 if (lmd->lmd_nidnet != NULL) {
1725 /* 'network=' mount option forbidden for server */
1726 OBD_FREE(lmd->lmd_nidnet, strlen(lmd->lmd_nidnet) + 1);
1727 lmd->lmd_nidnet = NULL;
1729 CERROR("%s: option 'network=' not allowed for Lustre servers: rc = %d\n",
1735 /* Save mount options */
1736 s1 = options + strlen(options) - 1;
1737 while (s1 >= options && (*s1 == ',' || *s1 == ' '))
1739 while (*options && (*options == ',' || *options == ' '))
1741 if (*options != 0) {
1742 /* Freed in lustre_free_lsi */
1743 OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1);
1745 GOTO(invalid, rc = -ENOMEM);
1746 strncpy(lmd->lmd_opts, options, strlen(options));
1752 CERROR("Bad mount options %s\n", options);
1757 EXPORT_SYMBOL(lmd_parse);