}
EXPORT_SYMBOL(server_get_mount);
-/*
- * Used by mdt to get mount_info from obdname.
- * There are no blocking when using the mount_info.
- * Do not use server_get_mount for this purpose.
+/**
+ * server_put_mount: to be called from obd_cleanup methods
+ * @name: obd name
+ * @dereg_mnt: 0 or 1 depending on whether the mount is to be deregistered or
+ * not
+ *
+ * The caller decides whether server_deregister_mount() needs to be called or
+ * not. Calling of server_deregister_mount() does not depend on refcounting on
+ * lsi because we could have say the mgs and mds on the same node and we
+ * unmount the mds, then the ref on the lsi would still be non-zero but we
+ * would still want to deregister the mds mount.
*/
-struct lustre_mount_info *server_get_mount_2(const char *name)
-{
- struct lustre_mount_info *lmi;
- ENTRY;
-
- mutex_lock(&lustre_mount_info_lock);
- lmi = server_find_mount(name);
- mutex_unlock(&lustre_mount_info_lock);
- if (!lmi)
- CERROR("Can't find mount for %s\n", name);
-
- RETURN(lmi);
-}
-EXPORT_SYMBOL(server_get_mount_2);
-
-/* to be called from obd_cleanup methods */
-int server_put_mount(const char *name)
+int server_put_mount(const char *name, bool dereg_mnt)
{
struct lustre_mount_info *lmi;
struct lustre_sb_info *lsi;
CDEBUG(D_MOUNT, "Last put of mount %p from %s\n",
lmi->lmi_sb, name);
- /* this obd should never need the mount again */
- server_deregister_mount(name);
+ if (dereg_mnt)
+ /* this obd should never need the mount again */
+ server_deregister_mount(name);
RETURN(0);
}
EXPORT_SYMBOL(server_put_mount);
-/* Corresponding to server_get_mount_2 */
-int server_put_mount_2(const char *name, struct vfsmount *mnt)
-{
- ENTRY;
- RETURN(0);
-}
-EXPORT_SYMBOL(server_put_mount_2);
-
/* Set up a MGS to serve startup logs */
static int server_start_mgs(struct super_block *sb)
{
char lwp_name[24];
int rc;
- lmi = server_get_mount_2(dev);
+ lmi = server_get_mount(dev);
if (lmi == NULL)
return NULL;
if (rc != 0) {
CERROR("%s: failed to get fsname: rc = %d\n",
lsi->lsi_svname, rc);
- return NULL;
+ goto err_lmi;
}
snprintf(lwp_name, sizeof(lwp_name), "%s-MDT%04x", fsname, idx);
}
spin_unlock(&lsi->lsi_lwp_lock);
+err_lmi:
+ server_put_mount(dev, false);
+
return exp;
}
EXPORT_SYMBOL(lustre_find_lwp_by_index);
lustre_cfg_string(cfg, 1));
lcfg = lustre_cfg_new(LCFG_ADD_CONN, bufs);
-
+ if (lcfg == NULL)
+ GOTO(out_cfg, rc = -ENOMEM);
rc = class_add_conn(lwp, lcfg);
if (rc)
CERROR("%s: can't add conn: rc = %d\n", lwpname, rc);
-out:
- if (bufs != NULL)
- OBD_FREE_PTR(bufs);
if (lcfg != NULL)
lustre_cfg_free(lcfg);
+out_cfg:
+ if (bufs != NULL)
+ OBD_FREE_PTR(bufs);
+out:
if (lwpname != NULL)
OBD_FREE(lwpname, MTI_NAME_MAXLEN);
RETURN(rc);
*ptr = '-';
break;
}
-
*ptr = '-';
+
+ if (IS_MDT(lsi) && idx != 0)
+ break;
+
rc = lustre_lwp_add_conn(lcfg, lsi, idx);
break;
}