PATCH: never fail close requests
Poul-Henning Kamp
phk at phk.freebsd.dk
Thu Feb 12 14:52:53 PST 2004
This patch adds a KASSERT in geom_subr.c which explodes if
an access method returns an error to a request which have no
positive access counts.
In other words: it is _always_ legal to close and there is no
need to check the error return for a g_access() call which has
no positive counts for read, write or exclusive.
I'll commit this in a couple of days, but wanted to give you
guys a heads-up first so we can see if anything explodes on this.
Thanks to Pawel for finding a few places where this was a problem.
Poul-Henning
Index: geom/geom_bsd.c
===================================================================
RCS file: /home/ncvs/src/sys/geom/geom_bsd.c,v
retrieving revision 1.67
diff -u -r1.67 geom_bsd.c
--- geom/geom_bsd.c 12 Feb 2004 22:42:11 -0000 1.67
+++ geom/geom_bsd.c 12 Feb 2004 22:46:40 -0000
@@ -569,7 +569,7 @@
} while (0);
/* Success or failure, we can close our provider now. */
- error = g_access(cp, -1, 0, 0);
+ g_access(cp, -1, 0, 0);
/* If we have configured any providers, return the new geom. */
if (gsp->nprovider > 0) {
Index: geom/geom_fox.c
===================================================================
RCS file: /home/ncvs/src/sys/geom/geom_fox.c,v
retrieving revision 1.5
diff -u -r1.5 geom_fox.c
--- geom/geom_fox.c 12 Feb 2004 22:42:11 -0000 1.5
+++ geom/geom_fox.c 12 Feb 2004 22:47:54 -0000
@@ -90,8 +90,7 @@
cp1 = LIST_NEXT(sc->opath, consumer);
- error = g_access(sc->opath, -sc->cr, -sc->cw, -(sc->ce + 1));
- KASSERT(error == 0, ("Failed close of old path %d", error));
+ g_access(sc->opath, -sc->cr, -sc->cw, -(sc->ce + 1));
/*
* The attempt to reopen it with a exclusive count
Index: geom/geom_subr.c
===================================================================
RCS file: /home/ncvs/src/sys/geom/geom_subr.c,v
retrieving revision 1.70
diff -u -r1.70 geom_subr.c
--- geom/geom_subr.c 12 Feb 2004 22:42:11 -0000 1.70
+++ geom/geom_subr.c 12 Feb 2004 22:49:41 -0000
@@ -627,6 +627,9 @@
/* Ok then... */
error = pp->geom->access(pp, dcr, dcw, dce);
+ KASSERT(dcr > 0 || dcw > 0 || dce > 0 || error == 0,
+ ("Geom provider %s::%s failed closeing ->access()",
+ pp->geom->class->name, pp->name));
if (!error) {
/*
* If we open first write, spoil any partner consumers.
Index: geom/bde/g_bde.c
===================================================================
RCS file: /home/ncvs/src/sys/geom/bde/g_bde.c,v
retrieving revision 1.25
diff -u -r1.25 g_bde.c
--- geom/bde/g_bde.c 12 Feb 2004 22:42:11 -0000 1.25
+++ geom/bde/g_bde.c 12 Feb 2004 22:49:15 -0000
@@ -226,7 +226,6 @@
{
struct g_consumer *cp;
struct g_provider *pp;
- int error;
struct g_bde_softc *sc;
g_trace(G_T_TOPOLOGY, "g_bde_destroy_geom(%s, %s)", mp->name, gp->name);
@@ -244,8 +243,7 @@
KASSERT(cp != NULL, ("NULL consumer"));
sc->dead = 1;
wakeup(sc);
- error = g_access(cp, -1, -1, -1);
- KASSERT(error == 0, ("error on close"));
+ g_access(cp, -1, -1, -1);
g_detach(cp);
g_destroy_consumer(cp);
while (sc->dead != 2 && !LIST_EMPTY(&pp->consumers))
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the freebsd-geom
mailing list