lsi = s2lsi(lmi->lmi_sb);
mntget(lmi->lmi_mnt);
atomic_inc(&lsi->lsi_mounts);
-
+
CDEBUG(D_MOUNT, "get_mnt %p from %s, refs=%d, vfscount=%d\n",
lmi->lmi_mnt, name, atomic_read(&lsi->lsi_mounts),
atomic_read(&lmi->lmi_mnt->mnt_count));
rc = server_register_mount(LUSTRE_MGS_OBDNAME, sb, mnt);
- if (!rc &&
- ((rc = lustre_start_simple(LUSTRE_MGS_OBDNAME, LUSTRE_MGS_NAME,
- LUSTRE_MGS_OBDNAME, 0, 0))))
- server_deregister_mount(LUSTRE_MGS_OBDNAME);
+ if (!rc) {
+ rc = lustre_start_simple(LUSTRE_MGS_OBDNAME, LUSTRE_MGS_NAME,
+ LUSTRE_MGS_OBDNAME, 0, 0);
+ /* Do NOT call server_deregister_mount() here. This leads to
+ * inability cleanup cleanly and free lsi and other stuff when
+ * mgs calls server_put_mount() in error handling case. -umka */
+ }
if (rc)
LCONSOLE_ERROR_MSG(0x15e, "Failed to start MGS '%s' (%d). "
*/
static int lustre_start_mgc(struct super_block *sb)
{
- struct lustre_handle mgc_conn = {0, };
struct obd_connect_data *data = NULL;
struct lustre_sb_info *lsi = s2lsi(sb);
struct obd_device *obd;
struct obd_uuid *uuid;
class_uuid_t uuidc;
lnet_nid_t nid;
- char *mgcname, *niduuid;
+ char *mgcname, *niduuid, *mgssec;
char *ptr;
int recov_bk;
int rc = 0, i = 0, j, len;
GOTO(out_free, rc = -ENOMEM);
sprintf(mgcname, "%s%s", LUSTRE_MGC_OBDNAME, libcfs_nid2str(nid));
+ mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
+
mutex_down(&mgc_start_lock);
obd = class_name2obd(mgcname);
if (obd && !obd->obd_stopping) {
+ rc = obd_set_info_async(obd->obd_self_export,
+ strlen(KEY_MGSSEC), KEY_MGSSEC,
+ strlen(mgssec), mgssec, NULL);
+ if (rc)
+ GOTO(out_free, rc);
+
/* Re-using an existing MGC */
atomic_inc(&obd->u.cli.cl_mgc_refcount);
GOTO(out_free, rc = -ENOTCONN);
}
+ rc = obd_set_info_async(obd->obd_self_export,
+ strlen(KEY_MGSSEC), KEY_MGSSEC,
+ strlen(mgssec), mgssec, NULL);
+ if (rc)
+ GOTO(out_free, rc);
+
/* Keep a refcount of servers/clients who started with "mount",
so we know when we can get rid of the mgc. */
atomic_set(&obd->u.cli.cl_mgc_refcount, 1);
data->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_FID |
OBD_CONNECT_AT;
data->ocd_version = LUSTRE_VERSION_CODE;
- rc = obd_connect(NULL, &mgc_conn, obd, &(obd->obd_uuid), data, NULL);
+ rc = obd_connect(NULL, &exp, obd, &(obd->obd_uuid), data, NULL);
OBD_FREE_PTR(data);
if (rc) {
CERROR("connect failed %d\n", rc);
GOTO(out, rc);
}
- exp = class_conn2export(&mgc_conn);
obd->u.cli.cl_mgc_mgsexp = exp;
out:
if (rc) {
CERROR("failed to start server %s: %d\n",
lsi->lsi_ldd->ldd_svname, rc);
+ /* Do NOT call server_deregister_mount() here. This makes it
+ * impossible to find mount later in cleanup time and leaves
+ * @lsi and othder stuff leaked. -umka */
GOTO(out_mgc, rc);
}
if (lsi->lsi_lmd->lmd_profile != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_profile,
strlen(lsi->lsi_lmd->lmd_profile) + 1);
+ if (lsi->lsi_lmd->lmd_mgssec != NULL)
+ OBD_FREE(lsi->lsi_lmd->lmd_mgssec,
+ strlen(lsi->lsi_lmd->lmd_mgssec) + 1);
if (lsi->lsi_lmd->lmd_opts != NULL)
OBD_FREE(lsi->lsi_lmd->lmd_opts,
strlen(lsi->lsi_lmd->lmd_opts) + 1);
GOTO(out_free, rc);
}
+ if (lmd->lmd_flags & LMD_FLG_ABORT_RECOV)
+ simple_truncate(mnt->mnt_sb->s_root, mnt, LAST_RCVD,
+ LR_CLIENT_START);
+
OBD_PAGE_FREE(__page);
lsi->lsi_ldd = ldd; /* freed at lsi cleanup */
CDEBUG(D_SUPER, "%s: mnt = %p\n", lmd->lmd_dev, mnt);
}
/* Start MGS before MGC */
- if (IS_MGS(lsi->lsi_ldd) && !(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOMGS)) {
+ if (IS_MGS(lsi->lsi_ldd) && !(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOMGS)){
rc = server_start_mgs(sb);
if (rc)
GOTO(out_mnt, rc);
{
unsigned long index;
int rc;
- char *dash = strchr(svname, '-');
+ char *dash = strrchr(svname, '-');
if (!dash)
return(-EINVAL);
+ /* intepret <fsname>-MDTXXXXX-mdc as mdt, the better way is to pass
+ * in the fsname, then determine the server index */
+ if (!strcmp(LUSTRE_MDC_NAME, dash + 1)) {
+ dash--;
+ for (; dash > svname && *dash != '-'; dash--);
+ if (dash == svname)
+ return(-EINVAL);
+ }
+
if (strncmp(dash + 1, "MDT", 3) == 0)
rc = LDD_F_SV_TYPE_MDT;
else if (strncmp(dash + 1, "OST", 3) == 0)
rc = LDD_F_SV_TYPE_OST;
else
return(-EINVAL);
+ if (strcmp(dash + 4, "all") == 0)
+ return rc | LDD_F_SV_ALL;
index = simple_strtoul(dash + 4, endptr, 16);
*idx = index;
RETURN(rc);
}
+static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
+{
+ char *tail;
+ int length;
+
+ if (lmd->lmd_mgssec != NULL) {
+ OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1);
+ lmd->lmd_mgssec = NULL;
+ }
+
+ tail = strchr(ptr, ',');
+ if (tail == NULL)
+ length = strlen(ptr);
+ else
+ length = tail - ptr;
+
+ OBD_ALLOC(lmd->lmd_mgssec, length + 1);
+ if (lmd->lmd_mgssec == NULL)
+ return -ENOMEM;
+
+ memcpy(lmd->lmd_mgssec, ptr, length);
+ lmd->lmd_mgssec[length] = '\0';
+ return 0;
+}
+
/* mount -v -t lustre uml1:uml2:/lustre-client /mnt/lustre */
static int lmd_parse(char *options, struct lustre_mount_data *lmd)
{
} else if (strncmp(s1, "nomgs", 5) == 0) {
lmd->lmd_flags |= LMD_FLG_NOMGS;
clear++;
+ } else if (strncmp(s1, "mgssec=", 7) == 0) {
+ rc = lmd_parse_mgssec(lmd, s1 + 7);
+ if (rc)
+ goto invalid;
+ clear++;
/* ost exclusion list */
} else if (strncmp(s1, "exclude=", 8) == 0) {
rc = lmd_make_exclusion(lmd, s1 + 7);
RETURN(-ENOMEM);
lmd = lsi->lsi_lmd;
+ /*
+ * Disable lockdep during mount, because mount locking patterns are
+ * `special'.
+ */
+ lockdep_off();
+
/* Figure out the lmd from the mount options */
if (lmd_parse((char *)data, lmd)) {
lustre_put_lsi(sb);
CERROR("Unable to mount %s (%d)\n",
s2lsi(sb) ? lmd->lmd_dev : "", rc);
} else {
- CDEBUG(D_SUPER, "Mount %s complete\n",
+ CDEBUG(D_SUPER, "Mount %s complete\n",
lmd->lmd_dev);
}
+ lockdep_on();
return rc;
}