Whamcloud - gitweb
LU-5573 obdclass: strengthen against concurrent server mounts
[fs/lustre-release.git] / lustre / obdclass / obd_mount_server.c
index 2459473..6ca841f 100644 (file)
@@ -1669,7 +1669,6 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
        struct dt_device_param    p;
        char                      flagstr[16];
        int                       rc;
-       bool                     already_started = 0;
        ENTRY;
 
        CDEBUG(D_MOUNT,
@@ -1694,11 +1693,13 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
                LASSERT(obd);
        } else {
                CDEBUG(D_MOUNT, "%s already started\n", lsi->lsi_osd_obdname);
-               already_started = 1;
                /* but continue setup to allow special case of MDT and internal
-                * MGT being started separately, that will be identified in
-                * caller server_fill_super().
-                */
+                * MGT being started separately. */
+               if (!((IS_MGS(lsi) && (lsi->lsi_lmd->lmd_flags &
+                                     LMD_FLG_NOMGS)) ||
+                    (IS_MDT(lsi) && (lsi->lsi_lmd->lmd_flags &
+                                     LMD_FLG_NOSVC))))
+                       RETURN(-EALREADY);
        }
 
        rc = obd_connect(NULL, &lsi->lsi_osd_exp,
@@ -1707,12 +1708,10 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
        OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_CONNECT, 10);
 
        if (rc) {
-               if (!already_started) {
-                       obd->obd_force = 1;
-                       class_manual_cleanup(obd);
-                       lsi->lsi_dt_dev = NULL;
-               }
-               GOTO(out, rc);
+               obd->obd_force = 1;
+               class_manual_cleanup(obd);
+               lsi->lsi_dt_dev = NULL;
+               RETURN(rc);
        }
 
        LASSERT(obd->obd_lu_dev);
@@ -1726,7 +1725,7 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags)
 
        dt_conf_get(NULL, lsi->lsi_dt_dev, &p);
 out:
-       RETURN(already_started ? -EALREADY : rc);
+       RETURN(rc);
 }
 
 /** Fill in the superblock info for a Lustre server.
@@ -1746,9 +1745,7 @@ int server_fill_super(struct super_block *sb)
 
        /* Start low level OSD */
        rc = osd_start(lsi, sb->s_flags);
-       /* Handle separate nosvc and nomgs case */
-       if (rc && ((rc != -EALREADY) || !(lsi->lsi_lmd->lmd_flags &
-                                       (LMD_FLG_NOSVC|LMD_FLG_NOMGS)))) {
+       if (rc) {
                CERROR("Unable to start osd on %s: %d\n",
                       lsi->lsi_lmd->lmd_dev, rc);
                lustre_put_lsi(sb);