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
This commit is contained in:
Edward Tomasz Napierala 2017-10-04 12:25:39 +00:00
parent 253f5a2edb
commit b73e1f746a
2 changed files with 15 additions and 2 deletions

View File

@ -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 *indent, struct g_geom *gp,
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();
}

View File

@ -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;