Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / obdclass / obd_mount.c
index 71ea569..72b5128 100644 (file)
@@ -521,10 +521,13 @@ static int server_start_mgs(struct super_block *sb)
 
         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). "
@@ -564,7 +567,6 @@ DECLARE_MUTEX(mgc_start_lock);
  */
 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;
@@ -765,14 +767,13 @@ static int lustre_start_mgc(struct super_block *sb)
         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:
@@ -1149,7 +1150,9 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt)
         if (rc) {
                 CERROR("failed to start server %s: %d\n",
                        lsi->lsi_ldd->ldd_svname, rc);
-                server_deregister_mount(lsi->lsi_ldd->ldd_svname);
+                /* 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);
         }
 
@@ -1353,6 +1356,10 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb)
                 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);
@@ -1375,8 +1382,8 @@ static void server_wait_finished(struct vfsmount *mnt)
         init_waitqueue_head(&waitq);
 
         while ((atomic_read(&mnt->mnt_count) > 1) && (retries > 0)) {
-                LCONSOLE_WARN("Mount still busy with %d refs, waiting for "
-                              "%d secs...\n",
+                LCONSOLE_WARN("%s: Mount still busy with %d refs, waiting for "
+                              "%d secs...\n", mnt->mnt_devname,
                               atomic_read(&mnt->mnt_count), retries);
 
                 /* Wait for a bit */
@@ -1385,8 +1392,8 @@ static void server_wait_finished(struct vfsmount *mnt)
                 l_wait_event(waitq, 0, &lwi);
         }
         if (atomic_read(&mnt->mnt_count) > 1) {
-                CERROR("Mount %p is still busy (%d refs), giving up.\n",
-                       mnt, atomic_read(&mnt->mnt_count));
+                CERROR("%s: Mount still busy (%d refs), giving up.\n",
+                       mnt->mnt_devname, atomic_read(&mnt->mnt_count));
         }
 }
 
@@ -1407,6 +1414,8 @@ static void server_put_super(struct super_block *sb)
         OBD_ALLOC(tmpname, tmpname_sz);
         memcpy(tmpname, lsi->lsi_ldd->ldd_svname, tmpname_sz);
         CDEBUG(D_MOUNT, "server put_super %s\n", tmpname);
+        if (IS_MDT(lsi->lsi_ldd) && (lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC))
+                snprintf(tmpname, tmpname_sz, "MGS");
 
         /* Stop the target */
         if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC) &&
@@ -1654,7 +1663,9 @@ static int server_fill_super(struct super_block *sb)
                 GOTO(out_mnt, rc);
 
         LCONSOLE_WARN("Server %s on device %s has started\n",
-                      lsi->lsi_ldd->ldd_svname, lsi->lsi_lmd->lmd_dev);
+                      ((lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC) &&
+                       (IS_MDT(lsi->lsi_ldd))) ? "MGS" : lsi->lsi_ldd->ldd_svname,
+                      lsi->lsi_lmd->lmd_dev);
 
         RETURN(0);
 out_mnt:
@@ -1677,6 +1688,15 @@ int server_name2index(char *svname, __u32 *idx, char **endptr)
         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)