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/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/obdclass/obd_mount.c
34 * Client mount routines
36 * Author: Nathan Rutman <nathan@clusterfs.com>
40 #define DEBUG_SUBSYSTEM S_CLASS
41 #define D_MOUNT (D_SUPER|D_CONFIG/*|D_WARNING */)
42 #define PRINT_CMD CDEBUG
45 #include <obd_class.h>
46 #include <linux/version.h>
47 #include <lustre_log.h>
48 #include <lustre_disk.h>
49 #include <uapi/linux/lustre/lustre_param.h>
51 static int (*client_fill_super)(struct super_block *sb,
52 struct vfsmount *mnt);
54 static void (*kill_super_cb)(struct super_block *sb);
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);
114 /* class_obd_list(); */
117 EXPORT_SYMBOL(lustre_process_log);
119 /* Stop watching this config log for updates */
120 int lustre_end_log(struct super_block *sb, char *logname,
121 struct config_llog_instance *cfg)
123 struct lustre_cfg *lcfg;
124 struct lustre_cfg_bufs bufs;
125 struct lustre_sb_info *lsi = s2lsi(sb);
126 struct obd_device *mgc = lsi->lsi_mgc;
134 /* mgc_process_config */
135 lustre_cfg_bufs_reset(&bufs, mgc->obd_name);
136 lustre_cfg_bufs_set_string(&bufs, 1, logname);
138 lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg));
139 OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
142 lustre_cfg_init(lcfg, LCFG_LOG_END, &bufs);
143 rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
144 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
147 EXPORT_SYMBOL(lustre_end_log);
149 /**************** OBD start *******************/
152 * lustre_cfg_bufs are a holdover from 1.4; we can still set these up from
153 * lctl (and do for echo cli/srv.
155 static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
156 char *s1, char *s2, char *s3, char *s4)
158 struct lustre_cfg_bufs bufs;
159 struct lustre_cfg *lcfg = NULL;
162 CDEBUG(D_TRACE, "lcfg %s %#x %s %s %s %s\n", cfgname,
163 cmd, s1, s2, s3, s4);
165 lustre_cfg_bufs_reset(&bufs, cfgname);
167 lustre_cfg_bufs_set_string(&bufs, 1, s1);
169 lustre_cfg_bufs_set_string(&bufs, 2, s2);
171 lustre_cfg_bufs_set_string(&bufs, 3, s3);
173 lustre_cfg_bufs_set_string(&bufs, 4, s4);
175 OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
178 lustre_cfg_init(lcfg, cmd, &bufs);
179 lcfg->lcfg_nid = nid;
180 rc = class_process_config(lcfg);
181 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
186 * Call class_attach and class_setup. These methods in turn call
187 * OBD type-specific methods.
189 int lustre_start_simple(char *obdname, char *type, char *uuid,
190 char *s1, char *s2, char *s3, char *s4)
194 CDEBUG(D_MOUNT, "Starting OBD %s (typ=%s)\n", obdname, type);
196 rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, NULL, NULL);
198 CERROR("%s attach error %d\n", obdname, rc);
201 rc = do_lcfg(obdname, 0, LCFG_SETUP, s1, s2, s3, s4);
203 CERROR("%s setup error %d\n", obdname, rc);
204 do_lcfg(obdname, 0, LCFG_DETACH, NULL, NULL, NULL, NULL);
209 static DEFINE_MUTEX(mgc_start_lock);
212 * Set up a MGC OBD to process startup logs
214 * \param sb [in] super block of the MGC OBD
216 * \retval 0 success, otherwise error code
218 int lustre_start_mgc(struct super_block *sb)
220 struct obd_connect_data *data = NULL;
221 struct lustre_sb_info *lsi = s2lsi(sb);
222 struct obd_device *obd;
223 struct obd_export *exp;
224 struct obd_uuid *uuid = NULL;
227 char nidstr[LNET_NIDSTR_SIZE];
228 char *mgcname = NULL, *niduuid = NULL, *mgssec = NULL;
230 int rc = 0, i = 0, j;
235 LASSERT(lsi->lsi_lmd);
237 /* Find the first non-lo MGS NID for our MGC name */
238 if (IS_SERVER(lsi)) {
239 /* mount -o mgsnode=nid */
240 ptr = lsi->lsi_lmd->lmd_mgs;
241 if (lsi->lsi_lmd->lmd_mgs &&
242 (class_parse_nid(lsi->lsi_lmd->lmd_mgs, &nid, &ptr) == 0)) {
244 } else if (IS_MGS(lsi)) {
245 struct lnet_process_id id;
247 while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
248 if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND)
255 } else { /* client */
256 /* Use NIDs from mount line: uml1,1@elan:uml2,2@elan:/lustre */
257 ptr = lsi->lsi_lmd->lmd_dev;
258 if (class_parse_nid(ptr, &nid, &ptr) == 0)
262 CERROR("No valid MGS NIDs found.\n");
266 mutex_lock(&mgc_start_lock);
268 libcfs_nid2str_r(nid, nidstr, sizeof(nidstr));
269 len = strlen(LUSTRE_MGC_OBDNAME) + strlen(nidstr) + 1;
270 OBD_ALLOC(mgcname, len);
271 OBD_ALLOC(niduuid, len + 2);
272 if (mgcname == NULL || niduuid == NULL)
273 GOTO(out_free, rc = -ENOMEM);
274 snprintf(mgcname, len, "%s%s", LUSTRE_MGC_OBDNAME, nidstr);
276 mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
280 GOTO(out_free, rc = -ENOMEM);
282 obd = class_name2obd(mgcname);
283 if (obd && !obd->obd_stopping) {
286 rc = obd_set_info_async(NULL, obd->obd_self_export,
287 strlen(KEY_MGSSEC), KEY_MGSSEC,
288 strlen(mgssec), mgssec, NULL);
292 /* Re-using an existing MGC */
293 atomic_inc(&obd->u.cli.cl_mgc_refcount);
295 /* IR compatibility check, only for clients */
296 if (lmd_is_client(lsi->lsi_lmd)) {
298 int vallen = sizeof(*data);
299 __u32 *flags = &lsi->lsi_lmd->lmd_flags;
301 rc = obd_get_info(NULL, obd->obd_self_export,
302 strlen(KEY_CONN_DATA), KEY_CONN_DATA,
305 has_ir = OCD_HAS_FLAG(data, IMP_RECOV);
306 if (has_ir ^ !(*flags & LMD_FLG_NOIR)) {
307 /* LMD_FLG_NOIR is for test purpose only */
309 "Mounting client with IR setting not compatible with current MGC. Using MGC setting that is IR %s",
310 has_ir ? "enabled" : "disabled");
312 *flags &= ~LMD_FLG_NOIR;
314 *flags |= LMD_FLG_NOIR;
320 * If we are restarting the MGS, don't try to keep the MGC's
321 * old connection, or registration will fail.
324 CDEBUG(D_MOUNT, "New MGS with live MGC\n");
329 * Try all connections, but only once (again).
330 * We don't want to block another target from starting
331 * (using its local copy of the log), but we do want to connect
332 * if at all possible.
335 CDEBUG(D_MOUNT, "%s:Set MGC reconnect %d\n", mgcname, recov_bk);
336 rc = obd_set_info_async(NULL, obd->obd_self_export,
337 sizeof(KEY_INIT_RECOV_BACKUP),
338 KEY_INIT_RECOV_BACKUP,
339 sizeof(recov_bk), &recov_bk, NULL);
343 CDEBUG(D_MOUNT, "Start MGC '%s'\n", mgcname);
345 /* Add the primary NIDs for the MGS */
347 snprintf(niduuid, len + 2, "%s_%x", mgcname, i);
348 if (IS_SERVER(lsi)) {
349 ptr = lsi->lsi_lmd->lmd_mgs;
350 CDEBUG(D_MOUNT, "mgs NIDs %s.\n", ptr);
352 /* Use local NIDs (including LO) */
353 struct lnet_process_id id;
355 while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
356 rc = do_lcfg(mgcname, id.nid, LCFG_ADD_UUID,
357 niduuid, NULL, NULL, NULL);
360 /* Use mgsnode= nids */
361 /* mount -o mgsnode=nid */
362 if (lsi->lsi_lmd->lmd_mgs) {
363 ptr = lsi->lsi_lmd->lmd_mgs;
364 } else if (class_find_param(ptr, PARAM_MGSNODE,
366 CERROR("No MGS NIDs given.\n");
367 GOTO(out_free, rc = -EINVAL);
370 * Add primary MGS NID(s).
371 * Multiple NIDs on one MGS node are separated
374 while (class_parse_nid(ptr, &nid, &ptr) == 0) {
375 rc = do_lcfg(mgcname, nid, LCFG_ADD_UUID,
376 niduuid, NULL, NULL, NULL);
379 /* Stop at the first failover NID */
384 } else { /* client */
385 /* Use NIDs from mount line: uml1,1@elan:uml2,2@elan:/lustre */
386 ptr = lsi->lsi_lmd->lmd_dev;
387 while (class_parse_nid(ptr, &nid, &ptr) == 0) {
388 rc = do_lcfg(mgcname, nid, LCFG_ADD_UUID,
389 niduuid, NULL, NULL, NULL);
392 /* Stop at the first failover NID */
398 CERROR("No valid MGS NIDs found.\n");
399 GOTO(out_free, rc = -EINVAL);
401 lsi->lsi_lmd->lmd_mgs_failnodes = 1;
403 /* Random uuid for MGC allows easier reconnects */
406 GOTO(out_free, rc = -ENOMEM);
408 ll_generate_random_uuid(uuidc);
409 class_uuid_unparse(uuidc, uuid);
412 rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
413 (char *)uuid->uuid, LUSTRE_MGS_OBDNAME,
414 niduuid, NULL, NULL);
418 /* Add any failover MGS NIDs */
420 while (ptr && ((*ptr == ':' ||
421 class_find_param(ptr, PARAM_MGSNODE, &ptr) == 0))) {
422 /* New failover node */
423 sprintf(niduuid, "%s_%x", mgcname, i);
425 while (class_parse_nid_quiet(ptr, &nid, &ptr) == 0) {
426 rc = do_lcfg(mgcname, nid, LCFG_ADD_UUID,
427 niduuid, NULL, NULL, NULL);
434 rc = do_lcfg(mgcname, 0, LCFG_ADD_CONN,
435 niduuid, NULL, NULL, NULL);
443 lsi->lsi_lmd->lmd_mgs_failnodes = i;
445 obd = class_name2obd(mgcname);
447 CERROR("Can't find mgcobd %s\n", mgcname);
448 GOTO(out_free, rc = -ENOTCONN);
451 rc = obd_set_info_async(NULL, obd->obd_self_export,
452 strlen(KEY_MGSSEC), KEY_MGSSEC,
453 strlen(mgssec), mgssec, NULL);
458 * Keep a refcount of servers/clients who started with "mount",
459 * so we know when we can get rid of the mgc.
461 atomic_set(&obd->u.cli.cl_mgc_refcount, 1);
463 /* We connect to the MGS at setup, and don't disconnect until cleanup */
464 data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT |
465 OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV |
466 OBD_CONNECT_LVB_TYPE |
467 OBD_CONNECT_BULK_MBITS | OBD_CONNECT_BARRIER;
469 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
470 data->ocd_connect_flags |= OBD_CONNECT_MNE_SWAB;
473 if (lmd_is_client(lsi->lsi_lmd) &&
474 lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR)
475 data->ocd_connect_flags &= ~OBD_CONNECT_IMP_RECOV;
476 data->ocd_version = LUSTRE_VERSION_CODE;
477 rc = obd_connect(NULL, &exp, obd, uuid, data, NULL);
479 CERROR("connect failed %d\n", rc);
483 obd->u.cli.cl_mgc_mgsexp = exp;
487 * Keep the MGC info in the sb. Note that many lsi's can point
492 mutex_unlock(&mgc_start_lock);
499 OBD_FREE(mgcname, len);
501 OBD_FREE(niduuid, len + 2);
506 * Appended to obdname to form "obdname_XXXX".
508 #define MGC_IDX_LEN sizeof("_XXXX")
510 static int lustre_stop_mgc(struct super_block *sb)
512 struct lustre_sb_info *lsi = s2lsi(sb);
513 struct obd_device *obd;
514 char *niduuid = NULL, *ptr = NULL;
515 int i, rc = 0, len = 0;
526 mutex_lock(&mgc_start_lock);
527 LASSERT(atomic_read(&obd->u.cli.cl_mgc_refcount) > 0);
528 if (!atomic_dec_and_test(&obd->u.cli.cl_mgc_refcount)) {
530 * This is not fatal, every client that stops
533 CDEBUG(D_MOUNT, "MGC still has %d references.\n",
534 atomic_read(&obd->u.cli.cl_mgc_refcount));
535 GOTO(out, rc = -EBUSY);
539 * The MGC has no recoverable data in any case.
540 * force shotdown set in umount_begin
542 obd->obd_no_recov = 1;
544 if (obd->u.cli.cl_mgc_mgsexp) {
546 * An error is not fatal, if we are unable to send the
547 * disconnect mgs ping evictor cleans up the export
549 rc = obd_disconnect(obd->u.cli.cl_mgc_mgsexp);
551 CDEBUG(D_MOUNT, "disconnect failed %d\n", rc);
555 * Save the obdname for cleaning the NID uuids, which are
558 len = strlen(obd->obd_name) + MGC_IDX_LEN;
559 OBD_ALLOC(niduuid, len);
561 strlcpy(niduuid, obd->obd_name, len);
562 ptr = niduuid + strlen(niduuid);
565 rc = class_manual_cleanup(obd);
569 /* Clean the NID uuids */
571 GOTO(out, rc = -ENOMEM);
573 for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) {
574 snprintf(ptr, MGC_IDX_LEN, "_%x", i);
575 rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID,
576 niduuid, NULL, NULL, NULL);
578 CERROR("del MDC UUID %s failed: rc = %d\n",
583 OBD_FREE(niduuid, len);
585 /* class_import_put will get rid of the additional connections */
586 mutex_unlock(&mgc_start_lock);
590 /***************** lustre superblock **************/
592 static struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
594 struct lustre_sb_info *lsi;
601 OBD_ALLOC_PTR(lsi->lsi_lmd);
607 lsi->lsi_lmd->lmd_exclude_count = 0;
608 lsi->lsi_lmd->lmd_recovery_time_soft = 0;
609 lsi->lsi_lmd->lmd_recovery_time_hard = 0;
610 s2lsi_nocast(sb) = lsi;
611 /* we take 1 extra ref for our setup */
612 atomic_set(&lsi->lsi_mounts, 1);
614 /* Default umount style */
615 lsi->lsi_flags = LSI_UMOUNT_FAILOVER;
616 INIT_LIST_HEAD(&lsi->lsi_lwp_list);
617 spin_lock_init(&lsi->lsi_lwp_lock);
622 static int lustre_free_lsi(struct super_block *sb)
624 struct lustre_sb_info *lsi = s2lsi(sb);
628 LASSERT(lsi != NULL);
629 CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi);
631 /* someone didn't call server_put_mount. */
632 LASSERT(atomic_read(&lsi->lsi_mounts) == 0);
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);
671 s2lsi_nocast(sb) = NULL;
677 * The lsi has one reference for every server that is using the disk -
678 * e.g. MDT, MGS, and potentially MGC
680 int lustre_put_lsi(struct super_block *sb)
682 struct lustre_sb_info *lsi = s2lsi(sb);
686 LASSERT(lsi != NULL);
688 CDEBUG(D_MOUNT, "put %p %d\n", sb, atomic_read(&lsi->lsi_mounts));
689 if (atomic_dec_and_test(&lsi->lsi_mounts)) {
690 if (IS_SERVER(lsi) && lsi->lsi_osd_exp) {
691 lu_device_put(&lsi->lsi_dt_dev->dd_lu_dev);
692 lsi->lsi_osd_exp->exp_obd->obd_lvfs_ctxt.dt = NULL;
693 lsi->lsi_dt_dev = NULL;
694 obd_disconnect(lsi->lsi_osd_exp);
695 /* wait till OSD is gone */
696 obd_zombie_barrier();
705 * The goal of this function is to extract the file system name
706 * from the OBD name. This can come in two flavors. One is
707 * fsname-MDTXXXX or fsname-XXXXXXX were X is a hexadecimal
708 * number. In both cases we should return fsname. If it is
709 * not a valid OBD name it is assumed to be the file system
712 void obdname2fsname(const char *tgt, char *fsname, size_t buflen)
719 * First we have to see if the @tgt has '-' at all. It is
720 * valid for the user to request something like
721 * lctl set_param -P llite.lustre*.xattr_cache=0
723 ptr = strrchr(tgt, '-');
725 /* No '-' means it could end in '*' */
726 ptr = strchr(tgt, '*');
728 /* No '*' either. Assume tgt = fsname */
736 /* tgt format fsname-MDT0000-* */
737 if ((!strncmp(ptr, "-MDT", 4) ||
738 !strncmp(ptr, "-OST", 4)) &&
739 (isxdigit(ptr[4]) && isxdigit(ptr[5]) &&
740 isxdigit(ptr[6]) && isxdigit(ptr[7]))) {
746 * tgt_format fsname-cli'dev'-'uuid' except for the llite case
747 * which are named fsname-'uuid'. Examples:
749 * lustre-clilov-ffff88104db5b800
750 * lustre-ffff88104db5b800 (for llite device)
752 * The length of the OBD uuid can vary on different platforms.
753 * This test if any invalid characters are in string. Allow
754 * wildcards with '*' character.
757 if (!strspn(ptr, "0123456789abcdefABCDEF*")) {
763 * Now that we validated the device name lets extract the
764 * file system name. Most of the names in this class will
765 * have '-cli' in its name which needs to be dropped. If
766 * it doesn't have '-cli' then its a llite device which
767 * ptr already points to the start of the uuid string.
769 tmp = strstr(tgt, "-cli");
776 len = min_t(size_t, len, LUSTRE_MAXFSNAME);
777 snprintf(fsname, buflen, "%.*s", (int)len, tgt);
781 EXPORT_SYMBOL(obdname2fsname);
785 * <FSNAME><SEPARATOR><TYPE><INDEX>
786 * FSNAME is between 1 and 8 characters (inclusive).
787 * Excluded characters are '/' and ':'
788 * SEPARATOR is either ':' or '-'
789 * TYPE: "OST", "MDT", etc.
790 * INDEX: Hex representation of the index
794 * Get the fsname ("lustre") from the server name ("lustre-OST003F").
795 * @param [in] svname server name including type and index
796 * @param [out] fsname Buffer to copy filesystem name prefix into.
797 * Must have at least 'strlen(fsname) + 1' chars.
798 * @param [out] endptr if endptr isn't NULL it is set to end of fsname
801 int server_name2fsname(const char *svname, char *fsname, const char **endptr)
805 dash = svname + strnlen(svname, LUSTRE_MAXFSNAME);
806 for (; dash > svname && *dash != '-' && *dash != ':'; dash--)
811 if (fsname != NULL) {
812 strncpy(fsname, svname, dash - svname);
813 fsname[dash - svname] = '\0';
821 EXPORT_SYMBOL(server_name2fsname);
824 * Get service name (svname) from string
826 * if endptr isn't NULL it is set to end of fsname *
828 int server_name2svname(const char *label, char *svname, const char **endptr,
834 /* We use server_name2fsname() just for parsing */
835 rc = server_name2fsname(label, NULL, &dash);
842 if (strlcpy(svname, dash + 1, svsize) >= svsize)
847 EXPORT_SYMBOL(server_name2svname);
850 * check server name is OST.
852 int server_name_is_ost(const char *svname)
857 /* We use server_name2fsname() just for parsing */
858 rc = server_name2fsname(svname, NULL, &dash);
864 if (strncmp(dash, "OST", 3) == 0)
868 EXPORT_SYMBOL(server_name_is_ost);
871 * Get the index from the target name MDTXXXX/OSTXXXX
872 * rc = server type, or rc < 0 on error
874 int target_name2index(const char *tgtname, __u32 *idx, const char **endptr)
876 const char *dash = tgtname;
880 if (strncmp(dash, "MDT", 3) == 0)
881 rc = LDD_F_SV_TYPE_MDT;
882 else if (strncmp(dash, "OST", 3) == 0)
883 rc = LDD_F_SV_TYPE_OST;
889 if (strncmp(dash, "all", 3) == 0) {
892 return rc | LDD_F_SV_ALL;
896 if (!(kstrtoul(dash, 16, &index)))
904 EXPORT_SYMBOL(target_name2index);
907 * Get the index from the OBD name.
908 * rc = server type, or
910 * if endptr isn't NULL it is set to end of name
912 int server_name2index(const char *svname, __u32 *idx, const char **endptr)
917 /* We use server_name2fsname() just for parsing */
918 rc = server_name2fsname(svname, NULL, &dash);
923 rc = target_name2index(dash, idx, endptr);
927 /* Account for -mdc after index that is possible when specifying mdt */
928 if (endptr != NULL && strncmp(LUSTRE_MDC_NAME, *endptr + 1,
929 sizeof(LUSTRE_MDC_NAME)-1) == 0)
930 *endptr += sizeof(LUSTRE_MDC_NAME);
934 EXPORT_SYMBOL(server_name2index);
936 /*************** mount common betweeen server and client ***************/
939 int lustre_common_put_super(struct super_block *sb)
945 CDEBUG(D_MOUNT, "dropping sb %p\n", sb);
947 /* Drop a ref to the MGC */
948 rc = lustre_stop_mgc(sb);
949 if (rc && (rc != -ENOENT)) {
951 CERROR("Can't stop MGC: %d\n", rc);
955 * BUSY just means that there's some other OBD that
956 * needs the mgc. Let him clean it up.
958 CDEBUG(D_MOUNT, "MGC still in use\n");
960 /* Drop a ref to the mounted disk */
965 EXPORT_SYMBOL(lustre_common_put_super);
967 static void lmd_print(struct lustre_mount_data *lmd)
971 PRINT_CMD(D_MOUNT, " mount data:\n");
972 if (lmd_is_client(lmd))
973 PRINT_CMD(D_MOUNT, "profile: %s\n", lmd->lmd_profile);
974 PRINT_CMD(D_MOUNT, "device: %s\n", lmd->lmd_dev);
975 PRINT_CMD(D_MOUNT, "flags: %x\n", lmd->lmd_flags);
978 PRINT_CMD(D_MOUNT, "options: %s\n", lmd->lmd_opts);
980 if (lmd->lmd_recovery_time_soft)
981 PRINT_CMD(D_MOUNT, "recovery time soft: %d\n",
982 lmd->lmd_recovery_time_soft);
984 if (lmd->lmd_recovery_time_hard)
985 PRINT_CMD(D_MOUNT, "recovery time hard: %d\n",
986 lmd->lmd_recovery_time_hard);
988 for (i = 0; i < lmd->lmd_exclude_count; i++) {
989 PRINT_CMD(D_MOUNT, "exclude %d: OST%04x\n", i,
990 lmd->lmd_exclude[i]);
994 /* Is this server on the exclusion list */
995 int lustre_check_exclusion(struct super_block *sb, char *svname)
997 struct lustre_sb_info *lsi = s2lsi(sb);
998 struct lustre_mount_data *lmd = lsi->lsi_lmd;
1004 rc = server_name2index(svname, &index, NULL);
1005 if (rc != LDD_F_SV_TYPE_OST)
1006 /* Only exclude OSTs */
1009 CDEBUG(D_MOUNT, "Check exclusion %s (%d) in %d of %s\n", svname,
1010 index, lmd->lmd_exclude_count, lmd->lmd_dev);
1012 for (i = 0; i < lmd->lmd_exclude_count; i++) {
1013 if (index == lmd->lmd_exclude[i]) {
1014 CWARN("Excluding %s (on exclusion list)\n", svname);
1021 /* mount -v -o exclude=lustre-OST0001:lustre-OST0002 -t lustre ... */
1022 static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
1024 const char *s1 = ptr, *s2;
1025 __u32 *exclude_list;
1032 * The shortest an ost name can be is 8 chars: -OST0000.
1033 * We don't actually know the fsname at this time, so in fact
1034 * a user could specify any fsname.
1036 devmax = strlen(ptr) / 8 + 1;
1038 /* temp storage until we figure out how many we have */
1039 OBD_ALLOC(exclude_list, sizeof(index) * devmax);
1043 /* we enter this fn pointing at the '=' */
1044 while (*s1 && *s1 != ' ' && *s1 != ',') {
1046 rc = server_name2index(s1, &index, &s2);
1048 CERROR("Can't parse server name '%s': rc = %d\n",
1052 if (rc == LDD_F_SV_TYPE_OST)
1053 exclude_list[lmd->lmd_exclude_count++] = index;
1055 CDEBUG(D_MOUNT, "ignoring exclude %.*s: type = %#x\n",
1056 (uint)(s2-s1), s1, rc);
1059 * now we are pointing at ':' (next exclude)
1060 * or ',' (end of excludes)
1062 if (lmd->lmd_exclude_count >= devmax)
1065 if (rc >= 0) /* non-err */
1068 if (lmd->lmd_exclude_count) {
1069 /* permanent, freed in lustre_free_lsi */
1070 OBD_ALLOC(lmd->lmd_exclude, sizeof(index) *
1071 lmd->lmd_exclude_count);
1072 if (lmd->lmd_exclude) {
1073 memcpy(lmd->lmd_exclude, exclude_list,
1074 sizeof(index) * lmd->lmd_exclude_count);
1077 lmd->lmd_exclude_count = 0;
1080 OBD_FREE(exclude_list, sizeof(index) * devmax);
1084 static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
1089 if (lmd->lmd_mgssec != NULL) {
1090 OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1);
1091 lmd->lmd_mgssec = NULL;
1094 tail = strchr(ptr, ',');
1096 length = strlen(ptr);
1098 length = tail - ptr;
1100 OBD_ALLOC(lmd->lmd_mgssec, length + 1);
1101 if (lmd->lmd_mgssec == NULL)
1104 memcpy(lmd->lmd_mgssec, ptr, length);
1105 lmd->lmd_mgssec[length] = '\0';
1109 static int lmd_parse_network(struct lustre_mount_data *lmd, char *ptr)
1114 if (lmd->lmd_nidnet != NULL) {
1115 OBD_FREE(lmd->lmd_nidnet, strlen(lmd->lmd_nidnet) + 1);
1116 lmd->lmd_nidnet = NULL;
1119 tail = strchr(ptr, ',');
1121 length = strlen(ptr);
1123 length = tail - ptr;
1125 OBD_ALLOC(lmd->lmd_nidnet, length + 1);
1126 if (lmd->lmd_nidnet == NULL)
1129 memcpy(lmd->lmd_nidnet, ptr, length);
1130 lmd->lmd_nidnet[length] = '\0';
1134 static int lmd_parse_string(char **handle, char *ptr)
1139 if ((handle == NULL) || (ptr == NULL))
1142 if (*handle != NULL) {
1143 OBD_FREE(*handle, strlen(*handle) + 1);
1147 tail = strchr(ptr, ',');
1149 length = strlen(ptr);
1151 length = tail - ptr;
1153 OBD_ALLOC(*handle, length + 1);
1154 if (*handle == NULL)
1157 memcpy(*handle, ptr, length);
1158 (*handle)[length] = '\0';
1163 /* Collect multiple values for mgsnid specifiers */
1164 static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
1172 /* Find end of NID-list */
1173 while (class_parse_nid_quiet(tail, &nid, &tail) == 0)
1176 length = tail - *ptr;
1178 LCONSOLE_ERROR_MSG(0x159, "Can't parse NID '%s'\n", *ptr);
1182 if (lmd->lmd_mgs != NULL)
1183 oldlen = strlen(lmd->lmd_mgs) + 1;
1185 OBD_ALLOC(mgsnid, oldlen + length + 1);
1189 if (lmd->lmd_mgs != NULL) {
1190 /* Multiple mgsnid= are taken to mean failover locations */
1191 memcpy(mgsnid, lmd->lmd_mgs, oldlen);
1192 mgsnid[oldlen - 1] = ':';
1193 OBD_FREE(lmd->lmd_mgs, oldlen);
1195 memcpy(mgsnid + oldlen, *ptr, length);
1196 mgsnid[oldlen + length] = '\0';
1197 lmd->lmd_mgs = mgsnid;
1204 * Find the first delimiter (comma or colon) from the specified \a buf and
1205 * make \a *endh point to the string starting with the delimiter. The commas
1206 * in expression list [...] will be skipped.
1208 * @buf a delimiter-separated string
1209 * @endh a pointer to a pointer that will point to the string
1210 * starting with the delimiter
1212 * RETURNS true if delimiter is found, false if delimiter is not found
1214 static bool lmd_find_delimiter(char *buf, char **endh)
1223 if (*c == ',' || *c == ':')
1226 pos = strcspn(c, "[:,]");
1230 /* Not a valid mount string */
1232 CWARN("invalid mount string format\n");
1240 /* invalid mount string */
1242 CWARN("invalid mount string format\n");
1257 * Find the first valid string delimited by comma or colon from the specified
1258 * \a buf and parse it to see whether it's a valid NID list. If yes, \a *endh
1259 * will point to the next string starting with the delimiter.
1261 * \param[in] buf a delimiter-separated string
1262 * \param[in] endh a pointer to a pointer that will point to the string
1263 * starting with the delimiter
1265 * \retval 0 if the string is a valid NID list
1266 * \retval 1 if the string is not a valid NID list
1268 static int lmd_parse_nidlist(char *buf, char **endh)
1270 struct list_head nidlist;
1277 while (*buf == ',' || *buf == ':')
1279 if (*buf == ' ' || *buf == '/' || *buf == '\0')
1282 if (!lmd_find_delimiter(buf, &endp))
1283 endp = buf + strlen(buf);
1288 INIT_LIST_HEAD(&nidlist);
1289 if (cfs_parse_nidlist(buf, strlen(buf), &nidlist) <= 0)
1291 cfs_free_nidlist(&nidlist);
1302 * Parse mount line options
1303 * e.g. mount -v -t lustre -o abort_recov uml1:uml2:/lustre-client /mnt/lustre
1304 * dev is passed as device=uml1:/lustre by mount.lustre
1306 static int lmd_parse(char *options, struct lustre_mount_data *lmd)
1308 char *s1, *s2, *devname = NULL;
1309 struct lustre_mount_data *raw = (struct lustre_mount_data *)options;
1316 LCONSOLE_ERROR_MSG(0x162,
1317 "Missing mount data: check /sbin/mount.lustre is installed.\n");
1321 /* Options should be a string - try to detect old lmd data */
1322 if ((raw->lmd_magic & 0xffffff00) == (LMD_MAGIC & 0xffffff00)) {
1323 LCONSOLE_ERROR_MSG(0x163,
1324 "Using an old version of /sbin/mount lustre. Please install version %s\n",
1325 LUSTRE_VERSION_STRING);
1328 lmd->lmd_magic = LMD_MAGIC;
1330 OBD_ALLOC(lmd->lmd_params, LMD_PARAMS_MAXLEN);
1331 if (lmd->lmd_params == NULL)
1333 lmd->lmd_params[0] = '\0';
1335 /* Set default flags here */
1340 int time_min = OBD_RECOVERY_TIME_MIN;
1341 unsigned long result;
1344 /* Skip whitespace and extra commas */
1345 while (*s1 == ' ' || *s1 == ',')
1350 * Client options are parsed in ll_options: eg. flock,
1355 * Parse non-ldiskfs options here. Rather than modifying
1356 * ldiskfs, we just zero these out here
1358 if (strncmp(s1, "abort_recov", 11) == 0) {
1359 lmd->lmd_flags |= LMD_FLG_ABORT_RECOV;
1361 } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) {
1362 rc = kstrtoul(s1 + 19, 10, &result);
1365 lmd->lmd_recovery_time_soft = max_t(int, result,
1368 } else if (strncmp(s1, "recovery_time_hard=", 19) == 0) {
1369 rc = kstrtoul(s1 + 19, 10, &result);
1372 lmd->lmd_recovery_time_hard = max_t(int, result,
1375 } else if (strncmp(s1, "noir", 4) == 0) {
1376 lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */
1378 } else if (strncmp(s1, "nosvc", 5) == 0) {
1379 lmd->lmd_flags |= LMD_FLG_NOSVC;
1381 } else if (strncmp(s1, "nomgs", 5) == 0) {
1382 lmd->lmd_flags |= LMD_FLG_NOMGS;
1384 } else if (strncmp(s1, "noscrub", 7) == 0) {
1385 lmd->lmd_flags |= LMD_FLG_NOSCRUB;
1387 } else if (strncmp(s1, "skip_lfsck", 10) == 0) {
1388 lmd->lmd_flags |= LMD_FLG_SKIP_LFSCK;
1390 } else if (strncmp(s1, "rdonly_dev", 10) == 0) {
1391 lmd->lmd_flags |= LMD_FLG_DEV_RDONLY;
1393 } else if (strncmp(s1, PARAM_MGSNODE,
1394 sizeof(PARAM_MGSNODE) - 1) == 0) {
1395 s2 = s1 + sizeof(PARAM_MGSNODE) - 1;
1397 * Assume the next mount opt is the first
1398 * invalid NID we get to.
1400 rc = lmd_parse_mgs(lmd, &s2);
1405 } else if (strncmp(s1, "writeconf", 9) == 0) {
1406 lmd->lmd_flags |= LMD_FLG_WRITECONF;
1408 } else if (strncmp(s1, "update", 6) == 0) {
1409 lmd->lmd_flags |= LMD_FLG_UPDATE;
1411 } else if (strncmp(s1, "virgin", 6) == 0) {
1412 lmd->lmd_flags |= LMD_FLG_VIRGIN;
1414 } else if (strncmp(s1, "noprimnode", 10) == 0) {
1415 lmd->lmd_flags |= LMD_FLG_NO_PRIMNODE;
1417 } else if (strncmp(s1, "mgssec=", 7) == 0) {
1418 rc = lmd_parse_mgssec(lmd, s1 + 7);
1422 /* ost exclusion list */
1423 } else if (strncmp(s1, "exclude=", 8) == 0) {
1424 rc = lmd_make_exclusion(lmd, s1 + 7);
1428 } else if (strncmp(s1, "mgs", 3) == 0) {
1430 lmd->lmd_flags |= LMD_FLG_MGS;
1432 } else if (strncmp(s1, "svname=", 7) == 0) {
1433 rc = lmd_parse_string(&lmd->lmd_profile, s1 + 7);
1437 } else if (strncmp(s1, "param=", 6) == 0) {
1438 size_t length, params_length;
1441 if (lmd_find_delimiter(s1 + 6, &tail)) {
1442 char *param_str = tail + 1;
1443 int supplementary = 1;
1445 while (lmd_parse_nidlist(param_str,
1449 length = param_str - s1 - supplementary;
1451 length = strlen(s1);
1454 params_length = strlen(lmd->lmd_params);
1455 if (params_length + length + 1 >= LMD_PARAMS_MAXLEN)
1457 strncat(lmd->lmd_params, s1 + 6, length);
1458 lmd->lmd_params[params_length + length] = '\0';
1459 strlcat(lmd->lmd_params, " ", LMD_PARAMS_MAXLEN);
1460 s3 = s1 + 6 + length;
1462 } else if (strncmp(s1, "osd=", 4) == 0) {
1463 rc = lmd_parse_string(&lmd->lmd_osd_type, s1 + 4);
1469 * Linux 2.4 doesn't pass the device, so we stuck it at
1470 * the end of the options.
1472 else if (strncmp(s1, "device=", 7) == 0) {
1475 * terminate options right before device. device
1476 * must be the last one.
1480 } else if (strncmp(s1, "network=", 8) == 0) {
1481 rc = lmd_parse_network(lmd, s1 + 8);
1485 /* check if LNet dynamic peer discovery is activated */
1486 if (LNetGetPeerDiscoveryStatus()) {
1487 CERROR("LNet Dynamic Peer Discovery is enabled "
1488 "on this node. 'network' mount option "
1489 "cannot be taken into account.\n");
1497 s2 = strchr(s3, ',');
1505 memmove(s1, s2, strlen(s2) + 1);
1511 LCONSOLE_ERROR_MSG(0x164,
1512 "Can't find device name (need mount option 'device=...')\n");
1516 s1 = strstr(devname, ":/");
1519 lmd->lmd_flags |= LMD_FLG_CLIENT;
1520 /* Remove leading /s from fsname */
1521 while (*++s1 == '/')
1524 while (*s2 != '/' && *s2 != '\0')
1526 /* Freed in lustre_free_lsi */
1527 OBD_ALLOC(lmd->lmd_profile, s2 - s1 + 8);
1528 if (!lmd->lmd_profile)
1531 strncat(lmd->lmd_profile, s1, s2 - s1);
1532 strncat(lmd->lmd_profile, "-client", 7);
1535 s2 = s1 + strlen(s1) - 1;
1536 /* Remove padding /s from fileset */
1540 OBD_ALLOC(lmd->lmd_fileset, s2 - s1 + 2);
1541 if (lmd->lmd_fileset == NULL) {
1542 OBD_FREE(lmd->lmd_profile,
1543 strlen(lmd->lmd_profile) + 1);
1546 strncat(lmd->lmd_fileset, s1, s2 - s1 + 1);
1550 if (lmd->lmd_nidnet != NULL) {
1551 /* 'network=' mount option forbidden for server */
1552 OBD_FREE(lmd->lmd_nidnet, strlen(lmd->lmd_nidnet) + 1);
1553 lmd->lmd_nidnet = NULL;
1556 "%s: option 'network=' not allowed for Lustre servers: rc = %d\n",
1562 /* Freed in lustre_free_lsi */
1563 OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1);
1566 strncpy(lmd->lmd_dev, devname, strlen(devname)+1);
1568 /* Save mount options */
1569 s1 = options + strlen(options) - 1;
1570 while (s1 >= options && (*s1 == ',' || *s1 == ' '))
1572 while (*options && (*options == ',' || *options == ' '))
1574 if (*options != 0) {
1575 /* Freed in lustre_free_lsi */
1576 OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1);
1579 strncpy(lmd->lmd_opts, options, strlen(options)+1);
1583 lmd->lmd_magic = LMD_MAGIC;
1588 CERROR("Bad mount options %s\n", options);
1592 struct lustre_mount_data2 {
1594 struct vfsmount *lmd2_mnt;
1598 * This is the entry point for the mount call into Lustre.
1599 * This is called when a server or client is mounted,
1600 * and this is where we start setting things up.
1601 * @param data Mount options (e.g. -o flock,abort_recov)
1603 static int lustre_fill_super(struct super_block *sb, void *data, int silent)
1605 struct lustre_mount_data *lmd;
1606 struct lustre_mount_data2 *lmd2 = data;
1607 struct lustre_sb_info *lsi;
1612 CDEBUG(D_MOUNT|D_VFSTRACE, "VFS Op: sb %p\n", sb);
1614 lsi = lustre_init_lsi(sb);
1620 * Disable lockdep during mount, because mount locking patterns are
1626 * LU-639: the OBD cleanup of last mount may not finish yet, wait here.
1628 obd_zombie_barrier();
1630 /* Figure out the lmd from the mount options */
1631 if (lmd_parse((char *)(lmd2->lmd2_data), lmd)) {
1633 GOTO(out, rc = -EINVAL);
1636 if (lmd_is_client(lmd)) {
1637 CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile);
1638 if (client_fill_super == NULL)
1639 request_module("lustre");
1640 if (client_fill_super == NULL) {
1641 LCONSOLE_ERROR_MSG(0x165,
1642 "Nothing registered for client mount! Is the 'lustre' module loaded?\n");
1646 rc = lustre_start_mgc(sb);
1648 lustre_common_put_super(sb);
1651 /* Connect and start */
1652 /* (should always be ll_fill_super) */
1653 rc = (*client_fill_super)(sb, lmd2->lmd2_mnt);
1654 /* c_f_s will call lustre_common_put_super on failure */
1657 #ifdef HAVE_SERVER_SUPPORT
1658 CDEBUG(D_MOUNT, "Mounting server from %s\n", lmd->lmd_dev);
1659 rc = server_fill_super(sb);
1661 * s_f_s calls lustre_start_mgc after the mount because we need
1662 * the MGS NIDs which are stored on disk. Plus, we may
1663 * need to start the MGS first.
1665 /* s_f_s will call server_put_super on failure */
1667 CERROR("client-side-only module, cannot handle server mount\n");
1673 * If error happens in fill_super() call, @lsi will be killed there.
1674 * This is why we do not put it here.
1679 CERROR("Unable to mount %s (%d)\n",
1680 s2lsi(sb) ? lmd->lmd_dev : "", rc);
1682 CDEBUG(D_SUPER, "Mount %s complete\n",
1691 * We can't call ll_fill_super by name because it lives in a module that
1692 * must be loaded after this one.
1694 void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb,
1695 struct vfsmount *mnt))
1697 client_fill_super = cfs;
1699 EXPORT_SYMBOL(lustre_register_client_fill_super);
1701 void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb))
1703 kill_super_cb = cfs;
1705 EXPORT_SYMBOL(lustre_register_kill_super_cb);
1707 /***************** FS registration ******************/
1708 #ifdef HAVE_FSTYPE_MOUNT
1709 static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags,
1710 const char *devname, void *data)
1712 struct lustre_mount_data2 lmd2 = {
1716 return mount_nodev(fs_type, flags, &lmd2, lustre_fill_super);
1719 static int lustre_get_sb(struct file_system_type *fs_type, int flags,
1720 const char *devname, void *data, struct vfsmount *mnt)
1722 struct lustre_mount_data2 lmd2 = {
1727 return get_sb_nodev(fs_type, flags, &lmd2, lustre_fill_super, mnt);
1731 static void lustre_kill_super(struct super_block *sb)
1733 struct lustre_sb_info *lsi = s2lsi(sb);
1735 if (kill_super_cb && lsi && !IS_SERVER(lsi))
1736 (*kill_super_cb)(sb);
1738 kill_anon_super(sb);
1741 /* Register the "lustre" fs type */
1742 static struct file_system_type lustre_fs_type = {
1743 .owner = THIS_MODULE,
1745 #ifdef HAVE_FSTYPE_MOUNT
1746 .mount = lustre_mount,
1748 .get_sb = lustre_get_sb,
1750 .kill_sb = lustre_kill_super,
1751 .fs_flags = FS_REQUIRES_DEV | FS_HAS_FIEMAP | FS_RENAME_DOES_D_MOVE,
1753 MODULE_ALIAS_FS("lustre");
1755 int lustre_register_fs(void)
1757 return register_filesystem(&lustre_fs_type);
1760 int lustre_unregister_fs(void)
1762 return unregister_filesystem(&lustre_fs_type);