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 if (strlcpy(svname, dash + 1, svsize) >= svsize)
856 EXPORT_SYMBOL(server_name2svname);
857 #endif /* HAVE_SERVER_SUPPORT */
860 * check server name is OST.
862 int server_name_is_ost(const char *svname)
867 /* We use server_name2fsname() just for parsing */
868 rc = server_name2fsname(svname, NULL, &dash);
874 if (strncmp(dash, "OST", 3) == 0)
878 EXPORT_SYMBOL(server_name_is_ost);
881 * Get the index from the target name MDTXXXX/OSTXXXX
882 * rc = server type, or rc < 0 on error
884 int target_name2index(const char *tgtname, u32 *idx, const char **endptr)
886 const char *dash = tgtname;
890 if (strncmp(dash, "MDT", 3) == 0)
891 type = LDD_F_SV_TYPE_MDT;
892 else if (strncmp(dash, "OST", 3) == 0)
893 type = LDD_F_SV_TYPE_OST;
899 if (strncmp(dash, "all", 3) == 0) {
902 return type | LDD_F_SV_ALL;
905 len = strspn(dash, "0123456789ABCDEFabcdef");
909 if (strlen(dash) != len) {
913 memcpy(num, dash, sizeof(num) - 1);
914 rc = kstrtou16(num, 16, &index);
918 rc = kstrtou16(dash, 16, &index);
927 *endptr = dash + len;
931 EXPORT_SYMBOL(target_name2index);
934 * Get the index from the OBD name.
935 * rc = server type, or
937 * if endptr isn't NULL it is set to end of name
939 int server_name2index(const char *svname, __u32 *idx, const char **endptr)
944 /* We use server_name2fsname() just for parsing */
945 rc = server_name2fsname(svname, NULL, &dash);
950 rc = target_name2index(dash, idx, endptr);
954 /* Account for -mdc after index that is possible when specifying mdt */
955 if (endptr != NULL && strncmp(LUSTRE_MDC_NAME, *endptr + 1,
956 sizeof(LUSTRE_MDC_NAME)-1) == 0)
957 *endptr += sizeof(LUSTRE_MDC_NAME);
961 EXPORT_SYMBOL(server_name2index);
963 /*************** mount common betweeen server and client ***************/
966 int lustre_common_put_super(struct super_block *sb)
972 CDEBUG(D_MOUNT, "dropping sb %p\n", sb);
974 /* Drop a ref to the MGC */
975 rc = lustre_stop_mgc(sb);
976 if (rc && (rc != -ENOENT)) {
978 CERROR("Can't stop MGC: %d\n", rc);
982 * BUSY just means that there's some other OBD that
983 * needs the mgc. Let him clean it up.
985 CDEBUG(D_MOUNT, "MGC still in use\n");
987 /* Drop a ref to the mounted disk */
992 EXPORT_SYMBOL(lustre_common_put_super);
994 static void lmd_print(struct lustre_mount_data *lmd)
998 PRINT_CMD(D_MOUNT, " mount data:\n");
999 if (lmd_is_client(lmd))
1000 PRINT_CMD(D_MOUNT, "profile: %s\n", lmd->lmd_profile);
1001 PRINT_CMD(D_MOUNT, "device: %s\n", lmd->lmd_dev);
1004 PRINT_CMD(D_MOUNT, "options: %s\n", lmd->lmd_opts);
1006 if (lmd->lmd_recovery_time_soft)
1007 PRINT_CMD(D_MOUNT, "recovery time soft: %d\n",
1008 lmd->lmd_recovery_time_soft);
1010 if (lmd->lmd_recovery_time_hard)
1011 PRINT_CMD(D_MOUNT, "recovery time hard: %d\n",
1012 lmd->lmd_recovery_time_hard);
1014 for (i = 0; i < lmd->lmd_exclude_count; i++) {
1015 PRINT_CMD(D_MOUNT, "exclude %d: OST%04x\n", i,
1016 lmd->lmd_exclude[i]);
1020 /* Is this server on the exclusion list */
1021 int lustre_check_exclusion(struct super_block *sb, char *svname)
1023 struct lustre_sb_info *lsi = s2lsi(sb);
1024 struct lustre_mount_data *lmd = lsi->lsi_lmd;
1030 rc = server_name2index(svname, &index, NULL);
1031 if (rc != LDD_F_SV_TYPE_OST)
1032 /* Only exclude OSTs */
1035 CDEBUG(D_MOUNT, "Check exclusion %s (%d) in %d of %s\n", svname,
1036 index, lmd->lmd_exclude_count, lmd->lmd_dev);
1038 for (i = 0; i < lmd->lmd_exclude_count; i++) {
1039 if (index == lmd->lmd_exclude[i]) {
1040 CWARN("Excluding %s (on exclusion list)\n", svname);
1047 /* mount -v -o exclude=lustre-OST0001:lustre-OST0002 -t lustre ... */
1048 static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
1050 const char *s1 = ptr, *s2;
1051 __u32 *exclude_list;
1058 * The shortest an ost name can be is 8 chars: -OST0000.
1059 * We don't actually know the fsname at this time, so in fact
1060 * a user could specify any fsname.
1062 devmax = strlen(ptr) / 8 + 1;
1064 /* temp storage until we figure out how many we have */
1065 OBD_ALLOC_PTR_ARRAY(exclude_list, devmax);
1069 /* we enter this fn pointing at the '=' */
1070 while (*s1 && *s1 != ' ' && *s1 != ',') {
1072 rc = server_name2index(s1, &index, &s2);
1074 CERROR("Can't parse server name '%s': rc = %d\n",
1078 if (rc == LDD_F_SV_TYPE_OST)
1079 exclude_list[lmd->lmd_exclude_count++] = index;
1081 CDEBUG(D_MOUNT, "ignoring exclude %.*s: type = %#x\n",
1082 (uint)(s2-s1), s1, rc);
1085 * now we are pointing at ':' (next exclude)
1086 * or ',' (end of excludes)
1088 if (lmd->lmd_exclude_count >= devmax)
1091 if (rc >= 0) /* non-err */
1094 if (lmd->lmd_exclude_count) {
1095 /* permanent, freed in lustre_free_lsi */
1096 OBD_ALLOC_PTR_ARRAY(lmd->lmd_exclude,
1097 lmd->lmd_exclude_count);
1098 if (lmd->lmd_exclude) {
1099 memcpy(lmd->lmd_exclude, exclude_list,
1100 sizeof(index) * lmd->lmd_exclude_count);
1103 lmd->lmd_exclude_count = 0;
1106 OBD_FREE_PTR_ARRAY(exclude_list, devmax);
1110 static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
1112 int length = strlen(ptr);
1114 if (lmd->lmd_mgssec != NULL) {
1115 OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1);
1116 lmd->lmd_mgssec = NULL;
1119 OBD_ALLOC(lmd->lmd_mgssec, length + 1);
1120 if (lmd->lmd_mgssec == NULL)
1123 memcpy(lmd->lmd_mgssec, ptr, length);
1124 lmd->lmd_mgssec[length] = '\0';
1128 static int lmd_parse_network(struct lustre_mount_data *lmd, char *ptr)
1130 int length = strlen(ptr);
1132 if (lmd->lmd_nidnet != NULL) {
1133 OBD_FREE(lmd->lmd_nidnet, strlen(lmd->lmd_nidnet) + 1);
1134 lmd->lmd_nidnet = NULL;
1137 OBD_ALLOC(lmd->lmd_nidnet, length + 1);
1138 if (lmd->lmd_nidnet == NULL)
1141 memcpy(lmd->lmd_nidnet, ptr, length);
1142 lmd->lmd_nidnet[length] = '\0';
1146 static int lmd_parse_string(char **handle, char *ptr)
1148 if (!handle || !ptr)
1151 OBD_FREE(*handle, strlen(*handle) + 1);
1154 *handle = kstrdup(ptr, GFP_NOFS);
1158 OBD_ALLOC_POST(*handle, strlen(ptr) + 1, "kmalloced");
1163 /* Collect multiple values for mgsnid specifiers */
1164 static int lmd_parse_mgs(struct lustre_mount_data *lmd, char *ptr, char **tail)
1166 int length = strlen(ptr);
1167 struct lnet_nid nid;
1172 /* Find end of NID-list */
1173 while (class_parse_nid_quiet(*tail, &nid, tail) == 0)
1176 if (next && next != *tail)
1177 length += *tail - next + 1;
1179 LCONSOLE_ERROR_MSG(0x159, "Can't parse NID '%s'\n", ptr);
1183 if (lmd->lmd_mgs != NULL)
1184 oldlen = strlen(lmd->lmd_mgs) + 1;
1186 OBD_ALLOC(mgsnid, oldlen + length + 1);
1190 if (lmd->lmd_mgs != NULL) {
1191 /* Multiple mgsnid= are taken to mean failover locations */
1192 memcpy(mgsnid, lmd->lmd_mgs, oldlen);
1193 mgsnid[oldlen - 1] = ':';
1194 OBD_FREE(lmd->lmd_mgs, oldlen);
1197 if (next && next != *tail)
1198 snprintf(mgsnid + oldlen, length + 1, "%s,%.*s", ptr,
1199 (int)(*tail - next + 1), next);
1201 snprintf(mgsnid + oldlen, length + 1, "%s", ptr);
1202 lmd->lmd_mgs = mgsnid;
1207 enum lmd_mnt_flags {
1208 LMD_OPT_RECOVERY_TIME_SOFT = LMD_FLG_NUM_FLAGS + 1,
1209 LMD_OPT_RECOVERY_TIME_HARD,
1221 static const match_table_t lmd_flags_table = {
1222 {LMD_FLG_SKIP_LFSCK, "skip_lfsck"},
1223 {LMD_FLG_ABORT_RECOV, "abort_recov"},
1224 {LMD_FLG_ABORT_RECOV, "abort_recovery"},
1225 {LMD_FLG_NOSVC, "nosvc"},
1226 {LMD_FLG_MGS, "mgs"},
1227 {LMD_FLG_NOMGS, "nomgs"},
1228 {LMD_FLG_WRITECONF, "writeconf"},
1229 {LMD_FLG_NOIR, "noir"},
1230 {LMD_FLG_NOSCRUB, "noscrub"},
1231 {LMD_FLG_NO_PRIMNODE, "noprimnode"},
1232 {LMD_FLG_VIRGIN, "virgin"},
1233 {LMD_FLG_UPDATE, "update"},
1234 {LMD_FLG_DEV_RDONLY, "rdonly_dev"},
1235 {LMD_FLG_NO_CREATE, "no_create"},
1236 {LMD_FLG_NO_CREATE, "no_precreate"},
1237 {LMD_FLG_LOCAL_RECOV, "localrecov"},
1238 {LMD_FLG_ABORT_RECOV_MDT, "abort_recov_mdt"},
1239 {LMD_FLG_ABORT_RECOV_MDT, "abort_recovery_mdt"},
1240 {LMD_FLG_NO_LOCAL_LOGS, "nolocallogs"},
1242 {LMD_OPT_RECOVERY_TIME_SOFT, "recovery_time_soft=%u"},
1243 {LMD_OPT_RECOVERY_TIME_HARD, "recovery_time_hard=%u"},
1244 {LMD_OPT_MGSNODE, "mgsnode=%s"},
1245 {LMD_OPT_MGSSEC, "mgssec=%s"},
1246 {LMD_OPT_EXCLUDE, "exclude=%s"},
1247 {LMD_OPT_SVNAME, "svname=%s"},
1248 {LMD_OPT_PARAM, "param=%s"},
1249 {LMD_OPT_OSD, "osd=%s"},
1250 {LMD_OPT_NETWORK, "network=%s"},
1251 {LMD_OPT_DEVICE, "device=%s"}, /* should be last */
1252 {LMD_NUM_MOUNT_OPT, NULL}
1256 * Find the first delimiter; comma; from the specified \a buf and
1257 * make \a *endh point to the string starting with the delimiter.
1258 * The character ':' is also a delimiter for Lustre but not match_table
1259 * so the string is not split on it. Making it safe to ignore.
1261 * @buf a delimiter-separated string
1262 * @endh a pointer to a pointer that will point to the string
1263 * starting with the delimiter
1265 * Returns: true if delimiter is found, false if delimiter is not found
1267 static bool lmd_find_delimiter(char *buf, char **endh)
1269 substring_t args[LMD_NUM_MOUNT_OPT];
1277 /* No more options so we are done */
1278 end = strchr(buf, ',');
1283 tmp = kstrndup(buf, len, GFP_KERNEL);
1288 args[0].from = NULL;
1289 token = match_token(tmp, lmd_flags_table, args);
1291 if (token != LMD_NUM_MOUNT_OPT)
1301 * Make sure the string in \a buf is of a valid formt.
1303 * @buf a delimiter-separated string
1305 * Returns: true if string valid, false if string contains errors
1307 static bool lmd_validate_param(char *buf)
1315 pos = strcspn(c, "[]");
1320 /* Not a valid mount string */
1322 CWARN("invalid mount string format\n");
1327 char *right = strchr(c, ']'), *tmp;
1329 /* invalid mount string */
1331 CWARN("invalid mount string format\n");
1336 /* Test for [ .. [ .. ] */
1337 tmp = strchr(c, '[');
1338 if (tmp && tmp < right) {
1339 CWARN("invalid mount string format\n");
1343 /* Test for [ .. @ .. ] which means brackets
1344 * span more than one NID string.
1346 tmp = strchr(c, '@');
1347 if (tmp && tmp < right) {
1348 CWARN("invalid mount string format\n");
1360 * Find the first valid string delimited by comma or colon from the specified
1361 * @buf and parse it to see whether it's a valid nid list. If yes, @*endh
1362 * will point to the next string starting with the delimiter.
1364 * @buf: a delimiter-separated string
1366 * Returns: false if the string is a valid nid list
1367 * true if the string is not a valid nid list
1369 static bool lmd_parse_nidlist(char *buf)
1378 end = strchr(buf, '=');
1382 while ((end = strchr(buf, '@')) != NULL) {
1383 size_t pos = strcspn(end, ":,");
1389 /* FIXME !!! Add IPv6 support to cfs_parse_nidlist */
1390 if (strchr(buf, ':')) {
1391 struct lnet_nid nid;
1393 if (libcfs_strnid(&nid, buf) < 0) {
1398 if (cfs_parse_nidlist(buf, &nidlist) < 0) {
1402 cfs_free_nidlist(&nidlist);
1415 * Parse mount line options
1416 * e.g. mount -v -t lustre -o abort_recov uml1:uml2:/lustre-client /mnt/lustre
1417 * dev is passed as device=uml1:/lustre by mount.lustre_tgt
1419 int lmd_parse(char *options, struct lustre_mount_data *lmd)
1421 char *s1, *s2, *opts, *orig_opts, *devname = NULL;
1422 struct lustre_mount_data *raw = (struct lustre_mount_data *)options;
1428 LCONSOLE_ERROR_MSG(0x162,
1429 "Missing mount data: check /sbin/mount.lustre_tgt is installed.\n");
1433 /* Options should be a string - try to detect old lmd data */
1434 if ((raw->lmd_magic & 0xffffff00) == (LMD_MAGIC & 0xffffff00)) {
1435 LCONSOLE_ERROR_MSG(0x163,
1436 "Using an old version of /sbin/mount.lustre. Please install version %s\n",
1437 LUSTRE_VERSION_STRING);
1440 lmd->lmd_magic = LMD_MAGIC;
1442 /* Don't stomp on lmd_opts */
1443 opts = kstrdup(options, GFP_KERNEL);
1449 OBD_ALLOC(lmd->lmd_params, LMD_PARAMS_MAXLEN);
1450 if (!lmd->lmd_params)
1451 GOTO(invalid, rc = -ENOMEM);
1452 lmd->lmd_params[0] = '\0';
1454 /* Set default flags here */
1455 while ((s1 = strsep(&opts, ",")) != NULL) {
1456 int time_min = OBD_RECOVERY_TIME_MIN, tmp;
1457 substring_t args[LMD_NUM_MOUNT_OPT];
1463 * Initialize args struct so we know whether arg was
1464 * found; some options take optional arguments.
1467 args[0].from = NULL;
1468 token = match_token(s1, lmd_flags_table, args);
1469 if (token == LMD_NUM_MOUNT_OPT) {
1470 if (match_wildcard("iam", s1) ||
1471 match_wildcard("hsm", s1))
1474 /* Normally we would error but client and
1475 * server mounting is intertwine. So pass
1476 * off unknown args to ll_options instead.
1480 /* We found a known server option. Filter out
1481 * the result out of the options string. The
1482 * reset will be stored in lmd_opts.
1484 char *tmp = strstr(options, s1);
1486 if (strcmp(tmp, s1) != 0) {
1487 s2 = tmp + strlen(s1) + 1;
1488 memmove(tmp, s2, strlen(s2) + 1);
1495 * Client options are parsed in ll_options: eg. flock,
1500 * Parse non-ldiskfs options here. Rather than modifying
1501 * ldiskfs, we just zero these out here
1504 case LMD_FLG_ABORT_RECOV_MDT:
1505 case LMD_FLG_ABORT_RECOV:
1506 case LMD_FLG_NO_CREATE:
1507 case LMD_FLG_NOIR: /* test purpose only. */
1510 case LMD_FLG_NOSCRUB:
1511 case LMD_FLG_SKIP_LFSCK:
1512 case LMD_FLG_DEV_RDONLY:
1513 case LMD_FLG_WRITECONF:
1514 case LMD_FLG_NO_LOCAL_LOGS:
1515 case LMD_FLG_UPDATE:
1516 case LMD_FLG_VIRGIN:
1517 case LMD_FLG_NO_PRIMNODE:
1518 case LMD_FLG_MGS: /* We are an MGS */
1519 case LMD_FLG_LOCAL_RECOV:
1520 set_bit(token, lmd->lmd_flags);
1522 case LMD_OPT_RECOVERY_TIME_SOFT:
1523 rc = match_int(args, &tmp);
1525 lmd->lmd_recovery_time_soft = max_t(int, tmp,
1528 case LMD_OPT_RECOVERY_TIME_HARD:
1529 rc = match_int(args, &tmp);
1531 lmd->lmd_recovery_time_hard = max_t(int, tmp,
1534 case LMD_OPT_MGSNODE:
1535 /* Assume the next mount opt is the first
1536 * invalid NID we get to.
1538 rc = lmd_parse_mgs(lmd, args->from, &opts);
1542 if (strcmp(options, opts) != 0) {
1543 s2 = strstr(options, opts);
1548 case LMD_OPT_MGSSEC:
1549 rc = lmd_parse_mgssec(lmd, args->from);
1551 case LMD_OPT_EXCLUDE:
1552 /* ost exclusion list */
1553 rc = lmd_make_exclusion(lmd, args->from);
1555 case LMD_OPT_SVNAME:
1556 rc = lmd_parse_string(&lmd->lmd_profile, args->from);
1558 case LMD_OPT_PARAM: {
1559 size_t length = strlen(args->from), params_length;
1560 char *tail = NULL, *entry;
1562 params_length = strlen(lmd->lmd_params);
1563 if (params_length + length + 1 >= LMD_PARAMS_MAXLEN) {
1567 entry = lmd->lmd_params + params_length;
1568 strncat(lmd->lmd_params, args->from, length);
1570 /* Find end of param string */
1571 while (lmd_find_delimiter(opts, &tail)) {
1572 params_length = strlen(lmd->lmd_params);
1573 /* match_table splits by ',' so fill it in */
1574 lmd->lmd_params[params_length++] = ',';
1576 length = tail - opts + 1;
1579 if (params_length + length + 1 >=
1580 LMD_PARAMS_MAXLEN) {
1585 strscpy(lmd->lmd_params + params_length,
1590 lmd->lmd_params[params_length + length] = '\0';
1592 if (!lmd_validate_param(entry)) {
1597 /* param contains NIDs */
1598 if (strchr(entry, '@') && lmd_parse_nidlist(entry)) {
1603 /* remove params from opts string from options string */
1604 if (strlen(args->from) != strlen(entry)) {
1605 char *tmp = entry + strlen(args->from) + 1;
1607 s2 = strstr(options, tmp);
1609 size_t len = strlen(s2) - strlen(tmp);
1611 memmove(s2, s2 + strlen(tmp) + 1, len);
1615 strlcat(lmd->lmd_params, " ", LMD_PARAMS_MAXLEN);
1622 rc = lmd_parse_string(&lmd->lmd_osd_type, args->from);
1624 case LMD_OPT_DEVICE: {
1627 /* match_table splits strings at ',' so we need to
1628 * piece things back together.
1631 len = strlen(opts) + 1;
1633 /* Move to last part of device string */
1634 s2 = strchr(opts, '/');
1636 GOTO(invalid, rc = -EINVAL);
1638 /* See if more options exist */
1639 s2 = strchr(s2, ',');
1643 len += strlen(args->from) + 1;
1645 /* Freed in lustre_free_lsi */
1646 OBD_ALLOC(lmd->lmd_dev, len);
1648 GOTO(invalid, rc = -ENOMEM);
1651 snprintf(lmd->lmd_dev, len, "%s,%s",
1654 strscpy(lmd->lmd_dev, args->from, len);
1656 devname = lmd->lmd_dev;
1658 /* remove the split string 'opts' from options */
1660 s1 = strstr(options, opts);
1662 /* opts start after args->from so
1665 len -= strlen(args->from) + 2;
1667 memmove(options, s2, strlen(s2) + 1);
1673 case LMD_OPT_NETWORK:
1674 rc = lmd_parse_network(lmd, args->from);
1675 /* check if LNet dynamic peer discovery is activated */
1676 if (LNetGetPeerDiscoveryStatus()) {
1677 CERROR("LNet Dynamic Peer Discovery is enabled on this node. 'network' mount option cannot be taken into account.\n");
1687 LCONSOLE_ERROR_MSG(0x164,
1688 "Can't find device name (need mount option 'device=...')\n");
1689 GOTO(invalid, rc = -ENODEV);
1692 s1 = strstr(devname, ":/");
1695 set_bit(LMD_FLG_CLIENT, lmd->lmd_flags);
1696 /* Remove leading /s from fsname */
1697 while (*++s1 == '/')
1700 while (*s2 != '/' && *s2 != '\0')
1702 /* Freed in lustre_free_lsi */
1703 OBD_ALLOC(lmd->lmd_profile, s2 - s1 + 8);
1704 if (!lmd->lmd_profile)
1705 GOTO(invalid, rc = -ENOMEM);
1707 strncat(lmd->lmd_profile, s1, s2 - s1);
1708 strncat(lmd->lmd_profile, "-client", 7);
1711 s2 = s1 + strlen(s1) - 1;
1712 /* Remove padding /s from fileset */
1716 OBD_ALLOC(lmd->lmd_fileset, s2 - s1 + 2);
1717 if (!lmd->lmd_fileset)
1718 GOTO(invalid, rc = -ENOMEM);
1719 strncat(lmd->lmd_fileset, s1, s2 - s1 + 1);
1723 if (lmd->lmd_nidnet != NULL) {
1724 /* 'network=' mount option forbidden for server */
1725 OBD_FREE(lmd->lmd_nidnet, strlen(lmd->lmd_nidnet) + 1);
1726 lmd->lmd_nidnet = NULL;
1728 CERROR("%s: option 'network=' not allowed for Lustre servers: rc = %d\n",
1734 /* Save mount options */
1735 s1 = options + strlen(options) - 1;
1736 while (s1 >= options && (*s1 == ',' || *s1 == ' '))
1738 while (*options && (*options == ',' || *options == ' '))
1740 if (*options != 0) {
1741 /* Freed in lustre_free_lsi */
1742 OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1);
1744 GOTO(invalid, rc = -ENOMEM);
1745 strncpy(lmd->lmd_opts, options, strlen(options));
1751 CERROR("Bad mount options %s\n", options);
1756 EXPORT_SYMBOL(lmd_parse);