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/random.h>
47 #include <libcfs/linux/linux-uuid.h>
48 #include <linux/version.h>
49 #include <lustre_log.h>
50 #include <lustre_disk.h>
51 #include <uapi/linux/lustre/lustre_param.h>
53 static int (*client_fill_super)(struct super_block *sb,
54 struct vfsmount *mnt);
56 static void (*kill_super_cb)(struct super_block *sb);
58 /**************** config llog ********************/
61 * Get a config log from the MGS and process it.
62 * This func is called for both clients and servers.
63 * Continue to process new statements appended to the logs
64 * (whenever the config lock is revoked) until lustre_end_log
67 * @param sb The superblock is used by the MGC to write to the local copy of
69 * @param logname The name of the llog to replicate from the MGS
70 * @param cfg Since the same MGC may be used to follow multiple config logs
71 * (e.g. ost1, ost2, client), the config_llog_instance keeps the state for
72 * this log, and is added to the mgc's list of logs to follow.
74 int lustre_process_log(struct super_block *sb, char *logname,
75 struct config_llog_instance *cfg)
77 struct lustre_cfg *lcfg;
78 struct lustre_cfg_bufs *bufs;
79 struct lustre_sb_info *lsi = s2lsi(sb);
80 struct obd_device *mgc = lsi->lsi_mgc;
92 /* mgc_process_config */
93 lustre_cfg_bufs_reset(bufs, mgc->obd_name);
94 lustre_cfg_bufs_set_string(bufs, 1, logname);
95 lustre_cfg_bufs_set(bufs, 2, cfg, sizeof(*cfg));
96 lustre_cfg_bufs_set(bufs, 3, &sb, sizeof(sb));
97 OBD_ALLOC(lcfg, lustre_cfg_len(bufs->lcfg_bufcount, bufs->lcfg_buflen));
99 GOTO(out, rc = -ENOMEM);
100 lustre_cfg_init(lcfg, LCFG_LOG_START, bufs);
102 rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
103 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
108 LCONSOLE_ERROR_MSG(0x15b,
109 "%s: Configuration from log %s failed from MGS %d. Check client and MGS are on compatible version.\n",
110 mgc->obd_name, logname, rc);
112 LCONSOLE_ERROR_MSG(0x15c,
113 "%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",
114 mgc->obd_name, logname, rc);
116 /* class_obd_list(); */
119 EXPORT_SYMBOL(lustre_process_log);
121 /* Stop watching this config log for updates */
122 int lustre_end_log(struct super_block *sb, char *logname,
123 struct config_llog_instance *cfg)
125 struct lustre_cfg *lcfg;
126 struct lustre_cfg_bufs bufs;
127 struct lustre_sb_info *lsi = s2lsi(sb);
128 struct obd_device *mgc = lsi->lsi_mgc;
136 /* mgc_process_config */
137 lustre_cfg_bufs_reset(&bufs, mgc->obd_name);
138 lustre_cfg_bufs_set_string(&bufs, 1, logname);
140 lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg));
141 OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
144 lustre_cfg_init(lcfg, LCFG_LOG_END, &bufs);
145 rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
146 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
149 EXPORT_SYMBOL(lustre_end_log);
151 /**************** OBD start *******************/
154 * lustre_cfg_bufs are a holdover from 1.4; we can still set these up from
155 * lctl (and do for echo cli/srv.
157 static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd,
158 char *s1, char *s2, char *s3, char *s4)
160 struct lustre_cfg_bufs bufs;
161 struct lustre_cfg *lcfg = NULL;
164 CDEBUG(D_TRACE, "lcfg %s %#x %s %s %s %s\n", cfgname,
165 cmd, s1, s2, s3, s4);
167 lustre_cfg_bufs_reset(&bufs, cfgname);
169 lustre_cfg_bufs_set_string(&bufs, 1, s1);
171 lustre_cfg_bufs_set_string(&bufs, 2, s2);
173 lustre_cfg_bufs_set_string(&bufs, 3, s3);
175 lustre_cfg_bufs_set_string(&bufs, 4, s4);
177 OBD_ALLOC(lcfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
180 lustre_cfg_init(lcfg, cmd, &bufs);
181 lcfg->lcfg_nid = nid;
182 rc = class_process_config(lcfg);
183 OBD_FREE(lcfg, lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens));
188 * Call class_attach and class_setup. These methods in turn call
189 * OBD type-specific methods.
191 int lustre_start_simple(char *obdname, char *type, char *uuid,
192 char *s1, char *s2, char *s3, char *s4)
196 CDEBUG(D_MOUNT, "Starting OBD %s (typ=%s)\n", obdname, type);
198 rc = do_lcfg(obdname, 0, LCFG_ATTACH, type, uuid, NULL, NULL);
200 CERROR("%s attach error %d\n", obdname, rc);
203 rc = do_lcfg(obdname, 0, LCFG_SETUP, s1, s2, s3, s4);
205 CERROR("%s setup error %d\n", obdname, rc);
206 do_lcfg(obdname, 0, LCFG_DETACH, NULL, NULL, NULL, NULL);
211 static DEFINE_MUTEX(mgc_start_lock);
214 * Set up a MGC OBD to process startup logs
216 * \param sb [in] super block of the MGC OBD
218 * \retval 0 success, otherwise error code
220 int lustre_start_mgc(struct super_block *sb)
222 struct obd_connect_data *data = NULL;
223 struct lustre_sb_info *lsi = s2lsi(sb);
224 struct obd_device *obd;
225 struct obd_export *exp;
226 struct obd_uuid *uuid = NULL;
229 char nidstr[LNET_NIDSTR_SIZE];
230 char *mgcname = NULL, *niduuid = NULL, *mgssec = NULL;
232 int rc = 0, i = 0, j;
237 LASSERT(lsi->lsi_lmd);
239 /* Find the first non-lo MGS NID for our MGC name */
240 if (IS_SERVER(lsi)) {
241 /* mount -o mgsnode=nid */
242 ptr = lsi->lsi_lmd->lmd_mgs;
243 if (lsi->lsi_lmd->lmd_mgs &&
244 (class_parse_nid(lsi->lsi_lmd->lmd_mgs, &nid, &ptr) == 0)) {
246 } else if (IS_MGS(lsi)) {
247 struct lnet_process_id id;
249 while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
250 if (LNET_NETTYP(LNET_NIDNET(id.nid)) == LOLND)
257 } else { /* client */
258 /* Use NIDs from mount line: uml1,1@elan:uml2,2@elan:/lustre */
259 ptr = lsi->lsi_lmd->lmd_dev;
260 if (class_parse_nid(ptr, &nid, &ptr) == 0)
264 CERROR("No valid MGS NIDs found.\n");
268 mutex_lock(&mgc_start_lock);
270 libcfs_nid2str_r(nid, nidstr, sizeof(nidstr));
271 len = strlen(LUSTRE_MGC_OBDNAME) + strlen(nidstr) + 1;
272 OBD_ALLOC(mgcname, len);
273 OBD_ALLOC(niduuid, len + 2);
274 if (mgcname == NULL || niduuid == NULL)
275 GOTO(out_free, rc = -ENOMEM);
276 snprintf(mgcname, len, "%s%s", LUSTRE_MGC_OBDNAME, nidstr);
278 mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
282 GOTO(out_free, rc = -ENOMEM);
284 obd = class_name2obd(mgcname);
285 if (obd && !obd->obd_stopping) {
288 rc = obd_set_info_async(NULL, obd->obd_self_export,
289 strlen(KEY_MGSSEC), KEY_MGSSEC,
290 strlen(mgssec), mgssec, NULL);
294 /* Re-using an existing MGC */
295 atomic_inc(&obd->u.cli.cl_mgc_refcount);
297 /* IR compatibility check, only for clients */
298 if (lmd_is_client(lsi->lsi_lmd)) {
300 int vallen = sizeof(*data);
301 __u32 *flags = &lsi->lsi_lmd->lmd_flags;
303 rc = obd_get_info(NULL, obd->obd_self_export,
304 strlen(KEY_CONN_DATA), KEY_CONN_DATA,
307 has_ir = OCD_HAS_FLAG(data, IMP_RECOV);
308 if (has_ir ^ !(*flags & LMD_FLG_NOIR)) {
309 /* LMD_FLG_NOIR is for test purpose only */
311 "Mounting client with IR setting not compatible with current MGC. Using MGC setting that is IR %s",
312 has_ir ? "enabled" : "disabled");
314 *flags &= ~LMD_FLG_NOIR;
316 *flags |= LMD_FLG_NOIR;
322 * If we are restarting the MGS, don't try to keep the MGC's
323 * old connection, or registration will fail.
326 CDEBUG(D_MOUNT, "New MGS with live MGC\n");
331 * Try all connections, but only once (again).
332 * We don't want to block another target from starting
333 * (using its local copy of the log), but we do want to connect
334 * if at all possible.
337 CDEBUG(D_MOUNT, "%s:Set MGC reconnect %d\n", mgcname, recov_bk);
338 rc = obd_set_info_async(NULL, obd->obd_self_export,
339 sizeof(KEY_INIT_RECOV_BACKUP),
340 KEY_INIT_RECOV_BACKUP,
341 sizeof(recov_bk), &recov_bk, NULL);
345 CDEBUG(D_MOUNT, "Start MGC '%s'\n", mgcname);
347 /* Add the primary NIDs for the MGS */
349 snprintf(niduuid, len + 2, "%s_%x", mgcname, i);
350 if (IS_SERVER(lsi)) {
351 ptr = lsi->lsi_lmd->lmd_mgs;
352 CDEBUG(D_MOUNT, "mgs NIDs %s.\n", ptr);
354 /* Use local NIDs (including LO) */
355 struct lnet_process_id id;
357 while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
358 rc = do_lcfg(mgcname, id.nid, LCFG_ADD_UUID,
359 niduuid, NULL, NULL, NULL);
362 /* Use mgsnode= nids */
363 /* mount -o mgsnode=nid */
364 if (lsi->lsi_lmd->lmd_mgs) {
365 ptr = lsi->lsi_lmd->lmd_mgs;
366 } else if (class_find_param(ptr, PARAM_MGSNODE,
368 CERROR("No MGS NIDs given.\n");
369 GOTO(out_free, rc = -EINVAL);
372 * Add primary MGS NID(s).
373 * Multiple NIDs on one MGS node are separated
376 while (class_parse_nid(ptr, &nid, &ptr) == 0) {
377 rc = do_lcfg(mgcname, nid, LCFG_ADD_UUID,
378 niduuid, NULL, NULL, NULL);
381 /* Stop at the first failover NID */
386 } else { /* client */
387 /* Use NIDs from mount line: uml1,1@elan:uml2,2@elan:/lustre */
388 ptr = lsi->lsi_lmd->lmd_dev;
389 while (class_parse_nid(ptr, &nid, &ptr) == 0) {
390 rc = do_lcfg(mgcname, nid, LCFG_ADD_UUID,
391 niduuid, NULL, NULL, NULL);
394 /* Stop at the first failover NID */
400 CERROR("No valid MGS NIDs found.\n");
401 GOTO(out_free, rc = -EINVAL);
403 lsi->lsi_lmd->lmd_mgs_failnodes = 1;
405 /* Random uuid for MGC allows easier reconnects */
408 GOTO(out_free, rc = -ENOMEM);
410 generate_random_uuid(uuidc.b);
411 snprintf(uuid->uuid, UUID_SIZE, "%pU", uuidc.b);
414 rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
415 (char *)uuid->uuid, LUSTRE_MGS_OBDNAME,
416 niduuid, NULL, NULL);
420 /* Add any failover MGS NIDs */
422 while (ptr && ((*ptr == ':' ||
423 class_find_param(ptr, PARAM_MGSNODE, &ptr) == 0))) {
424 /* New failover node */
425 sprintf(niduuid, "%s_%x", mgcname, i);
427 while (class_parse_nid_quiet(ptr, &nid, &ptr) == 0) {
428 rc = do_lcfg(mgcname, nid, LCFG_ADD_UUID,
429 niduuid, NULL, NULL, NULL);
436 rc = do_lcfg(mgcname, 0, LCFG_ADD_CONN,
437 niduuid, NULL, NULL, NULL);
445 lsi->lsi_lmd->lmd_mgs_failnodes = i;
447 obd = class_name2obd(mgcname);
449 CERROR("Can't find mgcobd %s\n", mgcname);
450 GOTO(out_free, rc = -ENOTCONN);
453 rc = obd_set_info_async(NULL, obd->obd_self_export,
454 strlen(KEY_MGSSEC), KEY_MGSSEC,
455 strlen(mgssec), mgssec, NULL);
460 * Keep a refcount of servers/clients who started with "mount",
461 * so we know when we can get rid of the mgc.
463 atomic_set(&obd->u.cli.cl_mgc_refcount, 1);
465 /* We connect to the MGS at setup, and don't disconnect until cleanup */
466 data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT |
467 OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV |
468 OBD_CONNECT_LVB_TYPE |
469 OBD_CONNECT_BULK_MBITS | OBD_CONNECT_BARRIER;
471 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
472 data->ocd_connect_flags |= OBD_CONNECT_MNE_SWAB;
475 if (lmd_is_client(lsi->lsi_lmd) &&
476 lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR)
477 data->ocd_connect_flags &= ~OBD_CONNECT_IMP_RECOV;
478 data->ocd_version = LUSTRE_VERSION_CODE;
479 rc = obd_connect(NULL, &exp, obd, uuid, data, NULL);
481 CERROR("connect failed %d\n", rc);
485 obd->u.cli.cl_mgc_mgsexp = exp;
489 * Keep the MGC info in the sb. Note that many lsi's can point
494 mutex_unlock(&mgc_start_lock);
501 OBD_FREE(mgcname, len);
503 OBD_FREE(niduuid, len + 2);
507 static int lustre_stop_mgc(struct super_block *sb)
509 struct lustre_sb_info *lsi = s2lsi(sb);
510 struct obd_device *obd;
511 char *niduuid = NULL, *ptr = NULL;
512 int i, rc = 0, len = 0;
523 mutex_lock(&mgc_start_lock);
524 LASSERT(atomic_read(&obd->u.cli.cl_mgc_refcount) > 0);
525 if (!atomic_dec_and_test(&obd->u.cli.cl_mgc_refcount)) {
527 * This is not fatal, every client that stops
530 CDEBUG(D_MOUNT, "MGC still has %d references.\n",
531 atomic_read(&obd->u.cli.cl_mgc_refcount));
532 GOTO(out, rc = -EBUSY);
536 * The MGC has no recoverable data in any case.
537 * force shotdown set in umount_begin
539 obd->obd_no_recov = 1;
541 if (obd->u.cli.cl_mgc_mgsexp) {
543 * An error is not fatal, if we are unable to send the
544 * disconnect mgs ping evictor cleans up the export
546 rc = obd_disconnect(obd->u.cli.cl_mgc_mgsexp);
548 CDEBUG(D_MOUNT, "disconnect failed %d\n", rc);
552 * Save the obdname for cleaning the nid uuids, which are
555 len = strlen(obd->obd_name) + 6;
556 OBD_ALLOC(niduuid, len);
558 strcpy(niduuid, obd->obd_name);
559 ptr = niduuid + strlen(niduuid);
562 rc = class_manual_cleanup(obd);
566 /* Clean the nid uuids */
568 GOTO(out, rc = -ENOMEM);
570 for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) {
571 sprintf(ptr, "_%x", i);
572 rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID,
573 niduuid, NULL, NULL, NULL);
575 CERROR("del MDC UUID %s failed: rc = %d\n",
580 OBD_FREE(niduuid, len);
582 /* class_import_put will get rid of the additional connections */
583 mutex_unlock(&mgc_start_lock);
587 /***************** lustre superblock **************/
589 static struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
591 struct lustre_sb_info *lsi;
598 OBD_ALLOC_PTR(lsi->lsi_lmd);
604 lsi->lsi_lmd->lmd_exclude_count = 0;
605 lsi->lsi_lmd->lmd_recovery_time_soft = 0;
606 lsi->lsi_lmd->lmd_recovery_time_hard = 0;
607 s2lsi_nocast(sb) = lsi;
608 /* we take 1 extra ref for our setup */
609 atomic_set(&lsi->lsi_mounts, 1);
611 /* Default umount style */
612 lsi->lsi_flags = LSI_UMOUNT_FAILOVER;
613 INIT_LIST_HEAD(&lsi->lsi_lwp_list);
614 spin_lock_init(&lsi->lsi_lwp_lock);
619 static int lustre_free_lsi(struct super_block *sb)
621 struct lustre_sb_info *lsi = s2lsi(sb);
625 LASSERT(lsi != NULL);
626 CDEBUG(D_MOUNT, "Freeing lsi %p\n", lsi);
628 /* someone didn't call server_put_mount. */
629 LASSERT(atomic_read(&lsi->lsi_mounts) == 0);
631 if (lsi->lsi_lmd != NULL) {
632 if (lsi->lsi_lmd->lmd_dev != NULL)
633 OBD_FREE(lsi->lsi_lmd->lmd_dev,
634 strlen(lsi->lsi_lmd->lmd_dev) + 1);
635 if (lsi->lsi_lmd->lmd_profile != NULL)
636 OBD_FREE(lsi->lsi_lmd->lmd_profile,
637 strlen(lsi->lsi_lmd->lmd_profile) + 1);
638 if (lsi->lsi_lmd->lmd_fileset != NULL)
639 OBD_FREE(lsi->lsi_lmd->lmd_fileset,
640 strlen(lsi->lsi_lmd->lmd_fileset) + 1);
641 if (lsi->lsi_lmd->lmd_mgssec != NULL)
642 OBD_FREE(lsi->lsi_lmd->lmd_mgssec,
643 strlen(lsi->lsi_lmd->lmd_mgssec) + 1);
644 if (lsi->lsi_lmd->lmd_opts != NULL)
645 OBD_FREE(lsi->lsi_lmd->lmd_opts,
646 strlen(lsi->lsi_lmd->lmd_opts) + 1);
647 if (lsi->lsi_lmd->lmd_exclude_count)
648 OBD_FREE(lsi->lsi_lmd->lmd_exclude,
649 sizeof(lsi->lsi_lmd->lmd_exclude[0]) *
650 lsi->lsi_lmd->lmd_exclude_count);
651 if (lsi->lsi_lmd->lmd_mgs != NULL)
652 OBD_FREE(lsi->lsi_lmd->lmd_mgs,
653 strlen(lsi->lsi_lmd->lmd_mgs) + 1);
654 if (lsi->lsi_lmd->lmd_osd_type != NULL)
655 OBD_FREE(lsi->lsi_lmd->lmd_osd_type,
656 strlen(lsi->lsi_lmd->lmd_osd_type) + 1);
657 if (lsi->lsi_lmd->lmd_params != NULL)
658 OBD_FREE(lsi->lsi_lmd->lmd_params, 4096);
659 if (lsi->lsi_lmd->lmd_nidnet != NULL)
660 OBD_FREE(lsi->lsi_lmd->lmd_nidnet,
661 strlen(lsi->lsi_lmd->lmd_nidnet) + 1);
663 OBD_FREE_PTR(lsi->lsi_lmd);
666 LASSERT(lsi->lsi_llsbi == NULL);
668 s2lsi_nocast(sb) = NULL;
674 * The lsi has one reference for every server that is using the disk -
675 * e.g. MDT, MGS, and potentially MGC
677 int lustre_put_lsi(struct super_block *sb)
679 struct lustre_sb_info *lsi = s2lsi(sb);
683 LASSERT(lsi != NULL);
685 CDEBUG(D_MOUNT, "put %p %d\n", sb, atomic_read(&lsi->lsi_mounts));
686 if (atomic_dec_and_test(&lsi->lsi_mounts)) {
687 if (IS_SERVER(lsi) && lsi->lsi_osd_exp) {
688 lu_device_put(&lsi->lsi_dt_dev->dd_lu_dev);
689 lsi->lsi_osd_exp->exp_obd->obd_lvfs_ctxt.dt = NULL;
690 lsi->lsi_dt_dev = NULL;
691 obd_disconnect(lsi->lsi_osd_exp);
692 /* wait till OSD is gone */
693 obd_zombie_barrier();
702 * The goal of this function is to extract the file system name
703 * from the OBD name. This can come in two flavors. One is
704 * fsname-MDTXXXX or fsname-XXXXXXX were X is a hexadecimal
705 * number. In both cases we should return fsname. If it is
706 * not a valid OBD name it is assumed to be the file system
709 void obdname2fsname(const char *tgt, char *fsname, size_t buflen)
716 * First we have to see if the @tgt has '-' at all. It is
717 * valid for the user to request something like
718 * lctl set_param -P llite.lustre*.xattr_cache=0
720 ptr = strrchr(tgt, '-');
722 /* No '-' means it could end in '*' */
723 ptr = strchr(tgt, '*');
725 /* No '*' either. Assume tgt = fsname */
733 /* tgt format fsname-MDT0000-* */
734 if ((!strncmp(ptr, "-MDT", 4) ||
735 !strncmp(ptr, "-OST", 4)) &&
736 (isxdigit(ptr[4]) && isxdigit(ptr[5]) &&
737 isxdigit(ptr[6]) && isxdigit(ptr[7]))) {
743 * tgt_format fsname-cli'dev'-'uuid' except for the llite case
744 * which are named fsname-'uuid'. Examples:
746 * lustre-clilov-ffff88104db5b800
747 * lustre-ffff88104db5b800 (for llite device)
749 * The length of the OBD uuid can vary on different platforms.
750 * This test if any invalid characters are in string. Allow
751 * wildcards with '*' character.
754 if (!strspn(ptr, "0123456789abcdefABCDEF*")) {
760 * Now that we validated the device name lets extract the
761 * file system name. Most of the names in this class will
762 * have '-cli' in its name which needs to be dropped. If
763 * it doesn't have '-cli' then its a llite device which
764 * ptr already points to the start of the uuid string.
766 tmp = strstr(tgt, "-cli");
773 len = min_t(size_t, len, LUSTRE_MAXFSNAME);
774 snprintf(fsname, buflen, "%.*s", (int)len, tgt);
778 EXPORT_SYMBOL(obdname2fsname);
782 * <FSNAME><SEPARATOR><TYPE><INDEX>
783 * FSNAME is between 1 and 8 characters (inclusive).
784 * Excluded characters are '/' and ':'
785 * SEPARATOR is either ':' or '-'
786 * TYPE: "OST", "MDT", etc.
787 * INDEX: Hex representation of the index
791 * Get the fsname ("lustre") from the server name ("lustre-OST003F").
792 * @param [in] svname server name including type and index
793 * @param [out] fsname Buffer to copy filesystem name prefix into.
794 * Must have at least 'strlen(fsname) + 1' chars.
795 * @param [out] endptr if endptr isn't NULL it is set to end of fsname
798 int server_name2fsname(const char *svname, char *fsname, const char **endptr)
802 dash = svname + strnlen(svname, LUSTRE_MAXFSNAME);
803 for (; dash > svname && *dash != '-' && *dash != ':'; dash--)
808 if (fsname != NULL) {
809 strncpy(fsname, svname, dash - svname);
810 fsname[dash - svname] = '\0';
818 EXPORT_SYMBOL(server_name2fsname);
821 * Get service name (svname) from string
823 * if endptr isn't NULL it is set to end of fsname *
825 int server_name2svname(const char *label, char *svname, const char **endptr,
831 /* We use server_name2fsname() just for parsing */
832 rc = server_name2fsname(label, NULL, &dash);
839 if (strlcpy(svname, dash + 1, svsize) >= svsize)
844 EXPORT_SYMBOL(server_name2svname);
847 * check server name is OST.
849 int server_name_is_ost(const char *svname)
854 /* We use server_name2fsname() just for parsing */
855 rc = server_name2fsname(svname, NULL, &dash);
861 if (strncmp(dash, "OST", 3) == 0)
865 EXPORT_SYMBOL(server_name_is_ost);
868 * Get the index from the target name MDTXXXX/OSTXXXX
869 * rc = server type, or rc < 0 on error
871 int target_name2index(const char *tgtname, __u32 *idx, const char **endptr)
873 const char *dash = tgtname;
877 if (strncmp(dash, "MDT", 3) == 0)
878 rc = LDD_F_SV_TYPE_MDT;
879 else if (strncmp(dash, "OST", 3) == 0)
880 rc = LDD_F_SV_TYPE_OST;
886 if (strncmp(dash, "all", 3) == 0) {
889 return rc | LDD_F_SV_ALL;
892 index = simple_strtoul(dash, (char **)endptr, 16);
898 EXPORT_SYMBOL(target_name2index);
901 * Get the index from the OBD name.
902 * rc = server type, or
904 * if endptr isn't NULL it is set to end of name
906 int server_name2index(const char *svname, __u32 *idx, const char **endptr)
911 /* We use server_name2fsname() just for parsing */
912 rc = server_name2fsname(svname, NULL, &dash);
917 rc = target_name2index(dash, idx, endptr);
921 /* Account for -mdc after index that is possible when specifying mdt */
922 if (endptr != NULL && strncmp(LUSTRE_MDC_NAME, *endptr + 1,
923 sizeof(LUSTRE_MDC_NAME)-1) == 0)
924 *endptr += sizeof(LUSTRE_MDC_NAME);
928 EXPORT_SYMBOL(server_name2index);
930 /*************** mount common betweeen server and client ***************/
933 int lustre_common_put_super(struct super_block *sb)
939 CDEBUG(D_MOUNT, "dropping sb %p\n", sb);
941 /* Drop a ref to the MGC */
942 rc = lustre_stop_mgc(sb);
943 if (rc && (rc != -ENOENT)) {
945 CERROR("Can't stop MGC: %d\n", rc);
949 * BUSY just means that there's some other OBD that
950 * needs the mgc. Let him clean it up.
952 CDEBUG(D_MOUNT, "MGC still in use\n");
954 /* Drop a ref to the mounted disk */
959 EXPORT_SYMBOL(lustre_common_put_super);
961 static void lmd_print(struct lustre_mount_data *lmd)
965 PRINT_CMD(D_MOUNT, " mount data:\n");
966 if (lmd_is_client(lmd))
967 PRINT_CMD(D_MOUNT, "profile: %s\n", lmd->lmd_profile);
968 PRINT_CMD(D_MOUNT, "device: %s\n", lmd->lmd_dev);
969 PRINT_CMD(D_MOUNT, "flags: %x\n", lmd->lmd_flags);
972 PRINT_CMD(D_MOUNT, "options: %s\n", lmd->lmd_opts);
974 if (lmd->lmd_recovery_time_soft)
975 PRINT_CMD(D_MOUNT, "recovery time soft: %d\n",
976 lmd->lmd_recovery_time_soft);
978 if (lmd->lmd_recovery_time_hard)
979 PRINT_CMD(D_MOUNT, "recovery time hard: %d\n",
980 lmd->lmd_recovery_time_hard);
982 for (i = 0; i < lmd->lmd_exclude_count; i++) {
983 PRINT_CMD(D_MOUNT, "exclude %d: OST%04x\n", i,
984 lmd->lmd_exclude[i]);
988 /* Is this server on the exclusion list */
989 int lustre_check_exclusion(struct super_block *sb, char *svname)
991 struct lustre_sb_info *lsi = s2lsi(sb);
992 struct lustre_mount_data *lmd = lsi->lsi_lmd;
998 rc = server_name2index(svname, &index, NULL);
999 if (rc != LDD_F_SV_TYPE_OST)
1000 /* Only exclude OSTs */
1003 CDEBUG(D_MOUNT, "Check exclusion %s (%d) in %d of %s\n", svname,
1004 index, lmd->lmd_exclude_count, lmd->lmd_dev);
1006 for (i = 0; i < lmd->lmd_exclude_count; i++) {
1007 if (index == lmd->lmd_exclude[i]) {
1008 CWARN("Excluding %s (on exclusion list)\n", svname);
1015 /* mount -v -o exclude=lustre-OST0001:lustre-OST0002 -t lustre ... */
1016 static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
1018 const char *s1 = ptr, *s2;
1019 __u32 *exclude_list;
1026 * The shortest an ost name can be is 8 chars: -OST0000.
1027 * We don't actually know the fsname at this time, so in fact
1028 * a user could specify any fsname.
1030 devmax = strlen(ptr) / 8 + 1;
1032 /* temp storage until we figure out how many we have */
1033 OBD_ALLOC(exclude_list, sizeof(index) * devmax);
1037 /* we enter this fn pointing at the '=' */
1038 while (*s1 && *s1 != ' ' && *s1 != ',') {
1040 rc = server_name2index(s1, &index, &s2);
1042 CERROR("Can't parse server name '%s': rc = %d\n",
1046 if (rc == LDD_F_SV_TYPE_OST)
1047 exclude_list[lmd->lmd_exclude_count++] = index;
1049 CDEBUG(D_MOUNT, "ignoring exclude %.*s: type = %#x\n",
1050 (uint)(s2-s1), s1, rc);
1053 * now we are pointing at ':' (next exclude)
1054 * or ',' (end of excludes)
1056 if (lmd->lmd_exclude_count >= devmax)
1059 if (rc >= 0) /* non-err */
1062 if (lmd->lmd_exclude_count) {
1063 /* permanent, freed in lustre_free_lsi */
1064 OBD_ALLOC(lmd->lmd_exclude, sizeof(index) *
1065 lmd->lmd_exclude_count);
1066 if (lmd->lmd_exclude) {
1067 memcpy(lmd->lmd_exclude, exclude_list,
1068 sizeof(index) * lmd->lmd_exclude_count);
1071 lmd->lmd_exclude_count = 0;
1074 OBD_FREE(exclude_list, sizeof(index) * devmax);
1078 static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
1083 if (lmd->lmd_mgssec != NULL) {
1084 OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1);
1085 lmd->lmd_mgssec = NULL;
1088 tail = strchr(ptr, ',');
1090 length = strlen(ptr);
1092 length = tail - ptr;
1094 OBD_ALLOC(lmd->lmd_mgssec, length + 1);
1095 if (lmd->lmd_mgssec == NULL)
1098 memcpy(lmd->lmd_mgssec, ptr, length);
1099 lmd->lmd_mgssec[length] = '\0';
1103 static int lmd_parse_network(struct lustre_mount_data *lmd, char *ptr)
1108 if (lmd->lmd_nidnet != NULL) {
1109 OBD_FREE(lmd->lmd_nidnet, strlen(lmd->lmd_nidnet) + 1);
1110 lmd->lmd_nidnet = NULL;
1113 tail = strchr(ptr, ',');
1115 length = strlen(ptr);
1117 length = tail - ptr;
1119 OBD_ALLOC(lmd->lmd_nidnet, length + 1);
1120 if (lmd->lmd_nidnet == NULL)
1123 memcpy(lmd->lmd_nidnet, ptr, length);
1124 lmd->lmd_nidnet[length] = '\0';
1128 static int lmd_parse_string(char **handle, char *ptr)
1133 if ((handle == NULL) || (ptr == NULL))
1136 if (*handle != NULL) {
1137 OBD_FREE(*handle, strlen(*handle) + 1);
1141 tail = strchr(ptr, ',');
1143 length = strlen(ptr);
1145 length = tail - ptr;
1147 OBD_ALLOC(*handle, length + 1);
1148 if (*handle == NULL)
1151 memcpy(*handle, ptr, length);
1152 (*handle)[length] = '\0';
1157 /* Collect multiple values for mgsnid specifiers */
1158 static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
1166 /* Find end of NID-list */
1167 while (class_parse_nid_quiet(tail, &nid, &tail) == 0)
1170 length = tail - *ptr;
1172 LCONSOLE_ERROR_MSG(0x159, "Can't parse NID '%s'\n", *ptr);
1176 if (lmd->lmd_mgs != NULL)
1177 oldlen = strlen(lmd->lmd_mgs) + 1;
1179 OBD_ALLOC(mgsnid, oldlen + length + 1);
1183 if (lmd->lmd_mgs != NULL) {
1184 /* Multiple mgsnid= are taken to mean failover locations */
1185 memcpy(mgsnid, lmd->lmd_mgs, oldlen);
1186 mgsnid[oldlen - 1] = ':';
1187 OBD_FREE(lmd->lmd_mgs, oldlen);
1189 memcpy(mgsnid + oldlen, *ptr, length);
1190 mgsnid[oldlen + length] = '\0';
1191 lmd->lmd_mgs = mgsnid;
1198 * Find the first delimiter (comma or colon) from the specified \a buf and
1199 * make \a *endh point to the string starting with the delimiter. The commas
1200 * in expression list [...] will be skipped.
1202 * @buf a delimiter-separated string
1203 * @endh a pointer to a pointer that will point to the string
1204 * starting with the delimiter
1206 * RETURNS true if delimiter is found, false if delimiter is not found
1208 static bool lmd_find_delimiter(char *buf, char **endh)
1217 if (*c == ',' || *c == ':')
1220 pos = strcspn(c, "[:,]");
1224 /* Not a valid mount string */
1226 CWARN("invalid mount string format\n");
1234 /* invalid mount string */
1236 CWARN("invalid mount string format\n");
1251 * Find the first valid string delimited by comma or colon from the specified
1252 * \a buf and parse it to see whether it's a valid NID list. If yes, \a *endh
1253 * will point to the next string starting with the delimiter.
1255 * \param[in] buf a delimiter-separated string
1256 * \param[in] endh a pointer to a pointer that will point to the string
1257 * starting with the delimiter
1259 * \retval 0 if the string is a valid NID list
1260 * \retval 1 if the string is not a valid NID list
1262 static int lmd_parse_nidlist(char *buf, char **endh)
1264 struct list_head nidlist;
1271 while (*buf == ',' || *buf == ':')
1273 if (*buf == ' ' || *buf == '/' || *buf == '\0')
1276 if (!lmd_find_delimiter(buf, &endp))
1277 endp = buf + strlen(buf);
1282 INIT_LIST_HEAD(&nidlist);
1283 if (cfs_parse_nidlist(buf, strlen(buf), &nidlist) <= 0)
1285 cfs_free_nidlist(&nidlist);
1296 * Parse mount line options
1297 * e.g. mount -v -t lustre -o abort_recov uml1:uml2:/lustre-client /mnt/lustre
1298 * dev is passed as device=uml1:/lustre by mount.lustre
1300 static int lmd_parse(char *options, struct lustre_mount_data *lmd)
1302 char *s1, *s2, *devname = NULL;
1303 struct lustre_mount_data *raw = (struct lustre_mount_data *)options;
1310 LCONSOLE_ERROR_MSG(0x162,
1311 "Missing mount data: check /sbin/mount.lustre is installed.\n");
1315 /* Options should be a string - try to detect old lmd data */
1316 if ((raw->lmd_magic & 0xffffff00) == (LMD_MAGIC & 0xffffff00)) {
1317 LCONSOLE_ERROR_MSG(0x163,
1318 "Using an old version of /sbin/mount lustre. Please install version %s\n",
1319 LUSTRE_VERSION_STRING);
1322 lmd->lmd_magic = LMD_MAGIC;
1324 OBD_ALLOC(lmd->lmd_params, LMD_PARAMS_MAXLEN);
1325 if (lmd->lmd_params == NULL)
1327 lmd->lmd_params[0] = '\0';
1329 /* Set default flags here */
1334 int time_min = OBD_RECOVERY_TIME_MIN;
1337 /* Skip whitespace and extra commas */
1338 while (*s1 == ' ' || *s1 == ',')
1343 * Client options are parsed in ll_options: eg. flock,
1348 * Parse non-ldiskfs options here. Rather than modifying
1349 * ldiskfs, we just zero these out here
1351 if (strncmp(s1, "abort_recov", 11) == 0) {
1352 lmd->lmd_flags |= LMD_FLG_ABORT_RECOV;
1354 } else if (strncmp(s1, "recovery_time_soft=", 19) == 0) {
1355 lmd->lmd_recovery_time_soft =
1356 max_t(int, simple_strtoul(s1 + 19, NULL, 10),
1359 } else if (strncmp(s1, "recovery_time_hard=", 19) == 0) {
1360 lmd->lmd_recovery_time_hard =
1361 max_t(int, simple_strtoul(s1 + 19, NULL, 10),
1364 } else if (strncmp(s1, "noir", 4) == 0) {
1365 lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */
1367 } else if (strncmp(s1, "nosvc", 5) == 0) {
1368 lmd->lmd_flags |= LMD_FLG_NOSVC;
1370 } else if (strncmp(s1, "nomgs", 5) == 0) {
1371 lmd->lmd_flags |= LMD_FLG_NOMGS;
1373 } else if (strncmp(s1, "noscrub", 7) == 0) {
1374 lmd->lmd_flags |= LMD_FLG_NOSCRUB;
1376 } else if (strncmp(s1, "skip_lfsck", 10) == 0) {
1377 lmd->lmd_flags |= LMD_FLG_SKIP_LFSCK;
1379 } else if (strncmp(s1, "rdonly_dev", 10) == 0) {
1380 lmd->lmd_flags |= LMD_FLG_DEV_RDONLY;
1382 } else if (strncmp(s1, PARAM_MGSNODE,
1383 sizeof(PARAM_MGSNODE) - 1) == 0) {
1384 s2 = s1 + sizeof(PARAM_MGSNODE) - 1;
1386 * Assume the next mount opt is the first
1387 * invalid NID we get to.
1389 rc = lmd_parse_mgs(lmd, &s2);
1394 } else if (strncmp(s1, "writeconf", 9) == 0) {
1395 lmd->lmd_flags |= LMD_FLG_WRITECONF;
1397 } else if (strncmp(s1, "update", 6) == 0) {
1398 lmd->lmd_flags |= LMD_FLG_UPDATE;
1400 } else if (strncmp(s1, "virgin", 6) == 0) {
1401 lmd->lmd_flags |= LMD_FLG_VIRGIN;
1403 } else if (strncmp(s1, "noprimnode", 10) == 0) {
1404 lmd->lmd_flags |= LMD_FLG_NO_PRIMNODE;
1406 } else if (strncmp(s1, "mgssec=", 7) == 0) {
1407 rc = lmd_parse_mgssec(lmd, s1 + 7);
1411 /* ost exclusion list */
1412 } else if (strncmp(s1, "exclude=", 8) == 0) {
1413 rc = lmd_make_exclusion(lmd, s1 + 7);
1417 } else if (strncmp(s1, "mgs", 3) == 0) {
1419 lmd->lmd_flags |= LMD_FLG_MGS;
1421 } else if (strncmp(s1, "svname=", 7) == 0) {
1422 rc = lmd_parse_string(&lmd->lmd_profile, s1 + 7);
1426 } else if (strncmp(s1, "param=", 6) == 0) {
1427 size_t length, params_length;
1430 if (lmd_find_delimiter(s1 + 6, &tail)) {
1431 char *param_str = tail + 1;
1432 int supplementary = 1;
1434 while (lmd_parse_nidlist(param_str,
1438 length = param_str - s1 - supplementary;
1440 length = strlen(s1);
1443 params_length = strlen(lmd->lmd_params);
1444 if (params_length + length + 1 >= LMD_PARAMS_MAXLEN)
1446 strncat(lmd->lmd_params, s1 + 6, length);
1447 lmd->lmd_params[params_length + length] = '\0';
1448 strlcat(lmd->lmd_params, " ", LMD_PARAMS_MAXLEN);
1449 s3 = s1 + 6 + length;
1451 } else if (strncmp(s1, "osd=", 4) == 0) {
1452 rc = lmd_parse_string(&lmd->lmd_osd_type, s1 + 4);
1458 * Linux 2.4 doesn't pass the device, so we stuck it at
1459 * the end of the options.
1461 else if (strncmp(s1, "device=", 7) == 0) {
1464 * terminate options right before device. device
1465 * must be the last one.
1469 } else if (strncmp(s1, "network=", 8) == 0) {
1470 rc = lmd_parse_network(lmd, s1 + 8);
1474 /* check if LNet dynamic peer discovery is activated */
1475 if (LNetGetPeerDiscoveryStatus()) {
1476 CERROR("LNet Dynamic Peer Discovery is enabled "
1477 "on this node. 'network' mount option "
1478 "cannot be taken into account.\n");
1486 s2 = strchr(s3, ',');
1494 memmove(s1, s2, strlen(s2) + 1);
1500 LCONSOLE_ERROR_MSG(0x164,
1501 "Can't find device name (need mount option 'device=...')\n");
1505 s1 = strstr(devname, ":/");
1508 lmd->lmd_flags |= LMD_FLG_CLIENT;
1509 /* Remove leading /s from fsname */
1510 while (*++s1 == '/')
1513 while (*s2 != '/' && *s2 != '\0')
1515 /* Freed in lustre_free_lsi */
1516 OBD_ALLOC(lmd->lmd_profile, s2 - s1 + 8);
1517 if (!lmd->lmd_profile)
1520 strncat(lmd->lmd_profile, s1, s2 - s1);
1521 strncat(lmd->lmd_profile, "-client", 7);
1524 s2 = s1 + strlen(s1) - 1;
1525 /* Remove padding /s from fileset */
1529 OBD_ALLOC(lmd->lmd_fileset, s2 - s1 + 2);
1530 if (lmd->lmd_fileset == NULL) {
1531 OBD_FREE(lmd->lmd_profile,
1532 strlen(lmd->lmd_profile) + 1);
1535 strncat(lmd->lmd_fileset, s1, s2 - s1 + 1);
1539 if (lmd->lmd_nidnet != NULL) {
1540 /* 'network=' mount option forbidden for server */
1541 OBD_FREE(lmd->lmd_nidnet, strlen(lmd->lmd_nidnet) + 1);
1542 lmd->lmd_nidnet = NULL;
1545 "%s: option 'network=' not allowed for Lustre servers: rc = %d\n",
1551 /* Freed in lustre_free_lsi */
1552 OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1);
1555 strncpy(lmd->lmd_dev, devname, strlen(devname)+1);
1557 /* Save mount options */
1558 s1 = options + strlen(options) - 1;
1559 while (s1 >= options && (*s1 == ',' || *s1 == ' '))
1561 while (*options && (*options == ',' || *options == ' '))
1563 if (*options != 0) {
1564 /* Freed in lustre_free_lsi */
1565 OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1);
1568 strncpy(lmd->lmd_opts, options, strlen(options)+1);
1572 lmd->lmd_magic = LMD_MAGIC;
1577 CERROR("Bad mount options %s\n", options);
1581 struct lustre_mount_data2 {
1583 struct vfsmount *lmd2_mnt;
1587 * This is the entry point for the mount call into Lustre.
1588 * This is called when a server or client is mounted,
1589 * and this is where we start setting things up.
1590 * @param data Mount options (e.g. -o flock,abort_recov)
1592 static int lustre_fill_super(struct super_block *sb, void *data, int silent)
1594 struct lustre_mount_data *lmd;
1595 struct lustre_mount_data2 *lmd2 = data;
1596 struct lustre_sb_info *lsi;
1601 CDEBUG(D_MOUNT|D_VFSTRACE, "VFS Op: sb %p\n", sb);
1603 lsi = lustre_init_lsi(sb);
1609 * Disable lockdep during mount, because mount locking patterns are
1615 * LU-639: the OBD cleanup of last mount may not finish yet, wait here.
1617 obd_zombie_barrier();
1619 /* Figure out the lmd from the mount options */
1620 if (lmd_parse((char *)(lmd2->lmd2_data), lmd)) {
1622 GOTO(out, rc = -EINVAL);
1625 if (lmd_is_client(lmd)) {
1626 CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile);
1627 if (client_fill_super == NULL)
1628 request_module("lustre");
1629 if (client_fill_super == NULL) {
1630 LCONSOLE_ERROR_MSG(0x165,
1631 "Nothing registered for client mount! Is the 'lustre' module loaded?\n");
1635 rc = lustre_start_mgc(sb);
1637 lustre_common_put_super(sb);
1640 /* Connect and start */
1641 /* (should always be ll_fill_super) */
1642 rc = (*client_fill_super)(sb, lmd2->lmd2_mnt);
1643 /* c_f_s will call lustre_common_put_super on failure */
1646 #ifdef HAVE_SERVER_SUPPORT
1647 CDEBUG(D_MOUNT, "Mounting server from %s\n", lmd->lmd_dev);
1648 rc = server_fill_super(sb);
1650 * s_f_s calls lustre_start_mgc after the mount because we need
1651 * the MGS NIDs which are stored on disk. Plus, we may
1652 * need to start the MGS first.
1654 /* s_f_s will call server_put_super on failure */
1656 CERROR("client-side-only module, cannot handle server mount\n");
1662 * If error happens in fill_super() call, @lsi will be killed there.
1663 * This is why we do not put it here.
1668 CERROR("Unable to mount %s (%d)\n",
1669 s2lsi(sb) ? lmd->lmd_dev : "", rc);
1671 CDEBUG(D_SUPER, "Mount %s complete\n",
1680 * We can't call ll_fill_super by name because it lives in a module that
1681 * must be loaded after this one.
1683 void lustre_register_client_fill_super(int (*cfs)(struct super_block *sb,
1684 struct vfsmount *mnt))
1686 client_fill_super = cfs;
1688 EXPORT_SYMBOL(lustre_register_client_fill_super);
1690 void lustre_register_kill_super_cb(void (*cfs)(struct super_block *sb))
1692 kill_super_cb = cfs;
1694 EXPORT_SYMBOL(lustre_register_kill_super_cb);
1696 /***************** FS registration ******************/
1697 #ifdef HAVE_FSTYPE_MOUNT
1698 static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags,
1699 const char *devname, void *data)
1701 struct lustre_mount_data2 lmd2 = {
1705 return mount_nodev(fs_type, flags, &lmd2, lustre_fill_super);
1708 static int lustre_get_sb(struct file_system_type *fs_type, int flags,
1709 const char *devname, void *data, struct vfsmount *mnt)
1711 struct lustre_mount_data2 lmd2 = {
1716 return get_sb_nodev(fs_type, flags, &lmd2, lustre_fill_super, mnt);
1720 static void lustre_kill_super(struct super_block *sb)
1722 struct lustre_sb_info *lsi = s2lsi(sb);
1724 if (kill_super_cb && lsi && !IS_SERVER(lsi))
1725 (*kill_super_cb)(sb);
1727 kill_anon_super(sb);
1730 /* Register the "lustre" fs type */
1731 static struct file_system_type lustre_fs_type = {
1732 .owner = THIS_MODULE,
1734 #ifdef HAVE_FSTYPE_MOUNT
1735 .mount = lustre_mount,
1737 .get_sb = lustre_get_sb,
1739 .kill_sb = lustre_kill_super,
1740 .fs_flags = FS_REQUIRES_DEV | FS_HAS_FIEMAP | FS_RENAME_DOES_D_MOVE,
1742 MODULE_ALIAS_FS("lustre");
1744 int lustre_register_fs(void)
1746 return register_filesystem(&lustre_fs_type);
1749 int lustre_unregister_fs(void)
1751 return unregister_filesystem(&lustre_fs_type);