*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* lustre/obdclass/obd_mount.c
*
#include <lustre_log.h>
#include <lustre_disk.h>
#include <uapi/linux/lustre/lustre_param.h>
-#include <libcfs/crypto/llcrypt.h>
-
-static DEFINE_SPINLOCK(client_lock);
-static struct module *client_mod;
-static int (*client_fill_super)(struct super_block *sb);
-
-static void (*kill_super_cb)(struct super_block *sb);
+#include <lustre_crypto.h>
/**************** config llog ********************/
(class_parse_nid(lsi->lsi_lmd->lmd_mgs, &nid, &ptr) == 0)) {
i++;
} else if (IS_MGS(lsi)) {
- struct lnet_process_id id;
+ struct lnet_processid id;
while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
- if (id.nid == LNET_NID_LO_0)
+ if (nid_is_lo0(&id.nid))
continue;
- nid = id.nid;
+ nid = lnet_nid_to_nid4(&id.nid);
i++;
break;
}
CDEBUG(D_MOUNT, "mgs NIDs %s.\n", ptr);
if (IS_MGS(lsi)) {
/* Use local NIDs (including LO) */
- struct lnet_process_id id;
+ struct lnet_processid id;
while ((rc = LNetGetId(i++, &id)) != -ENOENT) {
- rc = do_lcfg(mgcname, id.nid, LCFG_ADD_UUID,
+ rc = do_lcfg(mgcname, lnet_nid_to_nid4(&id.nid),
+ LCFG_ADD_UUID,
niduuid, NULL, NULL, NULL);
}
} else {
data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_AT |
OBD_CONNECT_FULL20 | OBD_CONNECT_IMP_RECOV |
OBD_CONNECT_LVB_TYPE |
- OBD_CONNECT_BULK_MBITS | OBD_CONNECT_BARRIER;
+ OBD_CONNECT_BULK_MBITS | OBD_CONNECT_BARRIER |
+ OBD_CONNECT_FLAGS2;
+ data->ocd_connect_flags2 = OBD_CONNECT2_REP_MBITS;
if (lmd_is_client(lsi->lsi_lmd) &&
lsi->lsi_lmd->lmd_flags & LMD_FLG_NOIR)
OBD_FREE(niduuid, len + 2);
RETURN(rc);
}
+EXPORT_SYMBOL(lustre_start_mgc);
static int lustre_stop_mgc(struct super_block *sb)
{
struct lustre_sb_info *lsi = s2lsi(sb);
struct obd_device *obd;
- char *niduuid = NULL, *ptr = NULL;
- int i, rc = 0, len = 0;
+ char niduuid[MAX_OBD_NAME + 6], *ptr = NULL;
+ int i, rc = 0;
ENTRY;
}
/*
- * Save the obdname for cleaning the nid uuids, which are
- * obdname_XX
+ * Cache the obdname for cleaning the nid uuids, which are
+ * obdname_XX before calling class_manual_cleanup
*/
- len = strlen(obd->obd_name) + 6;
- OBD_ALLOC(niduuid, len);
- if (niduuid) {
- strcpy(niduuid, obd->obd_name);
- ptr = niduuid + strlen(niduuid);
- }
+ strcpy(niduuid, obd->obd_name);
+ ptr = niduuid + strlen(niduuid);
rc = class_manual_cleanup(obd);
if (rc)
GOTO(out, rc);
- /* Clean the nid uuids */
- if (!niduuid)
- GOTO(out, rc = -ENOMEM);
-
for (i = 0; i < lsi->lsi_lmd->lmd_mgs_failnodes; i++) {
sprintf(ptr, "_%x", i);
rc = do_lcfg(LUSTRE_MGC_OBDNAME, 0, LCFG_DEL_UUID,
niduuid, rc);
}
out:
- if (niduuid)
- OBD_FREE(niduuid, len);
-
/* class_import_put will get rid of the additional connections */
mutex_unlock(&mgc_start_lock);
RETURN(rc);
/***************** lustre superblock **************/
-static struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
+struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
{
struct lustre_sb_info *lsi;
RETURN(lsi);
}
+EXPORT_SYMBOL(lustre_init_lsi);
static int lustre_free_lsi(struct super_block *sb)
{
* e.g. mount -v -t lustre -o abort_recov uml1:uml2:/lustre-client /mnt/lustre
* dev is passed as device=uml1:/lustre by mount.lustre_tgt
*/
-static int lmd_parse(char *options, struct lustre_mount_data *lmd)
+int lmd_parse(char *options, struct lustre_mount_data *lmd)
{
char *s1, *s2, *devname = NULL;
struct lustre_mount_data *raw = (struct lustre_mount_data *)options;
* Parse non-ldiskfs options here. Rather than modifying
* ldiskfs, we just zero these out here
*/
- if (strncmp(s1, "abort_recov", 11) == 0) {
- lmd->lmd_flags |= LMD_FLG_ABORT_RECOV;
- clear++;
- } else if (strncmp(s1, "abort_recov_mdt", 15) == 0) {
+ if (!strncmp(s1, "abort_recov_mdt", 15) ||
+ !strncmp(s1, "abort_recovery_mdt", 18)) {
lmd->lmd_flags |= LMD_FLG_ABORT_RECOV_MDT;
clear++;
+ } else if (strncmp(s1, "abort_recov", 11) == 0) {
+ lmd->lmd_flags |= LMD_FLG_ABORT_RECOV;
+ clear++;
} else if (strncmp(s1, "recovery_time_soft=", 19) == 0) {
lmd->lmd_recovery_time_soft =
max_t(int, simple_strtoul(s1 + 19, NULL, 10),
} else if (strncmp(s1, "writeconf", 9) == 0) {
lmd->lmd_flags |= LMD_FLG_WRITECONF;
clear++;
+ } else if (strncmp(s1, "nolocallogs", 11) == 0) {
+ lmd->lmd_flags |= LMD_FLG_NO_LOCAL_LOGS;
+ clear++;
} else if (strncmp(s1, "update", 6) == 0) {
lmd->lmd_flags |= LMD_FLG_UPDATE;
clear++;
CERROR("Bad mount options %s\n", options);
RETURN(-EINVAL);
}
-
-/**
- * This is the entry point for the mount call into Lustre.
- * This is called when a server or client is mounted,
- * and this is where we start setting things up.
- * @param data Mount options (e.g. -o flock,abort_recov)
- */
-static int lustre_fill_super(struct super_block *sb, void *lmd2_data,
- int silent)
-{
- struct lustre_mount_data *lmd;
- struct lustre_sb_info *lsi;
- int rc;
-
- ENTRY;
-
- CDEBUG(D_MOUNT|D_VFSTRACE, "VFS Op: sb %p\n", sb);
-
- lsi = lustre_init_lsi(sb);
- if (!lsi)
- RETURN(-ENOMEM);
- lmd = lsi->lsi_lmd;
-
- /*
- * Disable lockdep during mount, because mount locking patterns are
- * 'special'.
- */
- lockdep_off();
-
- /*
- * LU-639: the OBD cleanup of last mount may not finish yet, wait here.
- */
- obd_zombie_barrier();
-
- /* Figure out the lmd from the mount options */
- if (lmd_parse(lmd2_data, lmd)) {
- lustre_put_lsi(sb);
- GOTO(out, rc = -EINVAL);
- }
-
- if (lmd_is_client(lmd)) {
- bool have_client = false;
-
- CDEBUG(D_MOUNT, "Mounting client %s\n", lmd->lmd_profile);
- if (!client_fill_super)
- request_module("lustre");
- spin_lock(&client_lock);
- if (client_fill_super && try_module_get(client_mod))
- have_client = true;
- spin_unlock(&client_lock);
- if (!have_client) {
- LCONSOLE_ERROR_MSG(0x165,
- "Nothing registered for client mount! Is the 'lustre' module loaded?\n");
- lustre_put_lsi(sb);
- rc = -ENODEV;
- } else {
- rc = lustre_start_mgc(sb);
- if (rc) {
- lustre_common_put_super(sb);
- GOTO(out, rc);
- }
- /* Connect and start */
- /* (should always be ll_fill_super) */
- rc = (*client_fill_super)(sb);
- /* c_f_s will call lustre_common_put_super on failure,
- * which takes care of the module reference.
- */
- }
- } else {
-#ifdef HAVE_SERVER_SUPPORT
- CDEBUG(D_MOUNT, "Mounting server from %s\n", lmd->lmd_dev);
- rc = server_fill_super(sb);
- /*
- * s_f_s calls lustre_start_mgc after the mount because we need
- * the MGS NIDs which are stored on disk. Plus, we may
- * need to start the MGS first.
- */
- /* s_f_s will call server_put_super on failure */
-#else
- CERROR("client-side-only module, cannot handle server mount\n");
- rc = -EINVAL;
-#endif
- }
-
- /*
- * If error happens in fill_super() call, @lsi will be killed there.
- * This is why we do not put it here.
- */
- GOTO(out, rc);
-out:
- if (rc) {
- CERROR("Unable to mount %s (%d)\n",
- s2lsi(sb) ? lmd->lmd_dev : "", rc);
- } else {
- CDEBUG(D_SUPER, "Mount %s complete\n",
- lmd->lmd_dev);
- }
- lockdep_on();
- return rc;
-}
-
-
-/*
- * We can't call ll_fill_super by name because it lives in a module that
- * must be loaded after this one.
- */
-void lustre_register_super_ops(struct module *mod,
- int (*cfs)(struct super_block *sb),
- void (*ksc)(struct super_block *sb))
-{
- spin_lock(&client_lock);
- client_mod = mod;
- client_fill_super = cfs;
- kill_super_cb = ksc;
- spin_unlock(&client_lock);
-}
-EXPORT_SYMBOL(lustre_register_super_ops);
-
-/***************** FS registration ******************/
-static struct dentry *lustre_mount(struct file_system_type *fs_type, int flags,
- const char *devname, void *data)
-{
- return mount_nodev(fs_type, flags, data, lustre_fill_super);
-}
-
-static void lustre_kill_super(struct super_block *sb)
-{
- struct lustre_sb_info *lsi = s2lsi(sb);
-
- if (kill_super_cb && lsi && !IS_SERVER(lsi))
- (*kill_super_cb)(sb);
-
- kill_anon_super(sb);
-}
-
-#ifdef HAVE_SERVER_SUPPORT
-/* Register the "lustre_tgt" fs type.
- *
- * Right now this isn't any different than the normal "lustre" filesystem
- * type, but it is added so that there is some compatibility to allow
- * changing documentation and scripts to start using the "lustre_tgt" type
- * at mount time. That will simplify test interop, and in case of upgrades
- * that change to the new type and then need to roll back for some reason.
- *
- * The long-term goal is to disentangle the client and server mount code.
- */
-static struct file_system_type lustre_fs_type_tgt = {
- .owner = THIS_MODULE,
- .name = "lustre_tgt",
- .mount = lustre_mount,
- .kill_sb = lustre_kill_super,
- .fs_flags = FS_REQUIRES_DEV | FS_RENAME_DOES_D_MOVE,
-};
-MODULE_ALIAS_FS("lustre_tgt");
-
-#define register_filesystem_tgt(fstype) \
-do { \
- int _rc; \
- \
- _rc = register_filesystem(fstype); \
- if (_rc && _rc != -EBUSY) { \
- /* Don't fail if server code also registers "lustre_tgt" */ \
- CERROR("obdclass: register fstype '%s' failed: rc = %d\n", \
- (fstype)->name, _rc); \
- return _rc; \
- } \
-} while (0)
-#define unregister_filesystem_tgt(fstype) unregister_filesystem(fstype)
-#else
-#define register_filesystem_tgt(fstype) do {} while (0)
-#define unregister_filesystem_tgt(fstype) do {} while (0)
-#endif
-
-/* Register the "lustre" fs type */
-static struct file_system_type lustre_fs_type = {
- .owner = THIS_MODULE,
- .name = "lustre",
- .mount = lustre_mount,
- .kill_sb = lustre_kill_super,
- .fs_flags = FS_RENAME_DOES_D_MOVE,
-};
-MODULE_ALIAS_FS("lustre");
-
-int lustre_register_fs(void)
-{
- register_filesystem_tgt(&lustre_fs_type_tgt);
-
- return register_filesystem(&lustre_fs_type);
-}
-
-int lustre_unregister_fs(void)
-{
- unregister_filesystem_tgt(&lustre_fs_type_tgt);
-
- return unregister_filesystem(&lustre_fs_type);
-}
+EXPORT_SYMBOL(lmd_parse);