From cfdb91850cec60ea14aa12003b06f6d44aeee874 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Sun, 29 Dec 2019 19:33:41 +0000 Subject: [PATCH] Missed part of r356162. If we postpone consumer destruction till close, then the close calls should not be ignored. Delay geom withering till the last close too. MFC after: 2 weeks X-MFC-with: r356162 Sponsored by: iXsystems, Inc. --- sys/geom/shsec/g_shsec.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c index c84a0e9a7b08..f889b5628671 100644 --- a/sys/geom/shsec/g_shsec.c +++ b/sys/geom/shsec/g_shsec.c @@ -184,7 +184,7 @@ g_shsec_orphan(struct g_consumer *cp) g_shsec_remove_disk(cp); /* If there are no valid disks anymore, remove device. */ - if (g_shsec_nvalid(sc) == 0) + if (LIST_EMPTY(&gp->consumer)) g_shsec_destroy(sc, 1); } @@ -199,21 +199,6 @@ g_shsec_access(struct g_provider *pp, int dr, int dw, int de) gp = pp->geom; sc = gp->softc; - if (sc == NULL) { - /* - * It looks like geom is being withered. - * In that case we allow only negative requests. - */ - KASSERT(dr <= 0 && dw <= 0 && de <= 0, - ("Positive access request (device=%s).", pp->name)); - if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && - (pp->ace + de) == 0) { - G_SHSEC_DEBUG(0, "Device %s definitely destroyed.", - gp->name); - } - return (0); - } - /* On first open, grab an extra "exclusive" bit */ if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0) de++; @@ -232,6 +217,11 @@ g_shsec_access(struct g_provider *pp, int dr, int dw, int de) g_destroy_consumer(cp1); } } + + /* If there are no valid disks anymore, remove device. */ + if (LIST_EMPTY(&gp->consumer)) + g_shsec_destroy(sc, 1); + return (error); fail: