svn commit: r324276 - head/sys/geom/mountver

Edward Tomasz Napierala trasz at FreeBSD.org
Wed Oct 4 12:25:41 UTC 2017


Author: trasz
Date: Wed Oct  4 12:25:39 2017
New Revision: 324276
URL: https://svnweb.freebsd.org/changeset/base/324276

Log:
  Don't destroy gmountver(8) devices on shutdown, unless they are orphaned.
  Otherwise we would fail to sync the filesystem on reboot.
  
  MFC after:	2 weeks
  Sponsored by:	DARPA, AFRL

Modified:
  head/sys/geom/mountver/g_mountver.c
  head/sys/geom/mountver/g_mountver.h

Modified: head/sys/geom/mountver/g_mountver.c
==============================================================================
--- head/sys/geom/mountver/g_mountver.c	Wed Oct  4 12:23:34 2017	(r324275)
+++ head/sys/geom/mountver/g_mountver.c	Wed Oct  4 12:25:39 2017	(r324276)
@@ -190,6 +190,11 @@ g_mountver_start(struct bio *bp)
 	 * requests in order to maintain ordering.
 	 */
 	if (sc->sc_orphaned || !TAILQ_EMPTY(&sc->sc_queue)) {
+		if (sc->sc_shutting_down) {
+			G_MOUNTVER_LOGREQ(bp, "Discarding request due to shutdown.");
+			g_io_deliver(bp, ENXIO);
+			return;
+		}
 		G_MOUNTVER_LOGREQ(bp, "Queueing request.");
 		g_mountver_queue(bp);
 		if (!sc->sc_orphaned)
@@ -607,13 +612,20 @@ g_mountver_dumpconf(struct sbuf *sb, const char *inden
 static void
 g_mountver_shutdown_pre_sync(void *arg, int howto)
 {
+	struct g_mountver_softc *sc;
 	struct g_class *mp;
 	struct g_geom *gp, *gp2;
 
 	mp = arg;
 	g_topology_lock();
-	LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2)
-		g_mountver_destroy(gp, 1);
+	LIST_FOREACH_SAFE(gp, &mp->geom, geom, gp2) {
+		if (gp->softc == NULL)
+			continue;
+		sc = gp->softc;
+		sc->sc_shutting_down = 1;
+		if (sc->sc_orphaned)
+			g_mountver_destroy(gp, 1);
+	}
 	g_topology_unlock();
 }
 

Modified: head/sys/geom/mountver/g_mountver.h
==============================================================================
--- head/sys/geom/mountver/g_mountver.h	Wed Oct  4 12:23:34 2017	(r324275)
+++ head/sys/geom/mountver/g_mountver.h	Wed Oct  4 12:25:39 2017	(r324276)
@@ -62,6 +62,7 @@ struct g_mountver_softc {
 	char				*sc_provider_name;
 	char				sc_ident[DISK_IDENT_SIZE];
 	int				sc_orphaned;
+	int				sc_shutting_down;
 	int				sc_access_r;
 	int				sc_access_w;
 	int				sc_access_e;


More information about the svn-src-all mailing list