From 0b5402fc6b7225b89bf8a3dd809b4e100b3ea150 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 4 Jul 2004 13:44:48 +0000 Subject: We only need to check for overlaps if we increasing access counts. --- sys/geom/geom_slice.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/sys/geom/geom_slice.c b/sys/geom/geom_slice.c index 736ab0c..549005b 100644 --- a/sys/geom/geom_slice.c +++ b/sys/geom/geom_slice.c @@ -99,23 +99,25 @@ g_slice_access(struct g_provider *pp, int dr, int dw, int de) cp = LIST_FIRST(&gp->consumer); KASSERT (cp != NULL, ("g_slice_access but no consumer")); gsp = gp->softc; - gsl = &gsp->slices[pp->index]; - for (u = 0; u < gsp->nslice; u++) { - gsl2 = &gsp->slices[u]; - if (gsl2->length == 0) - continue; - if (u == pp->index) - continue; - if (gsl->offset + gsl->length <= gsl2->offset) - continue; - if (gsl2->offset + gsl2->length <= gsl->offset) - continue; - /* overlap */ - pp2 = gsl2->provider; - if ((pp->acw + dw) > 0 && pp2->ace > 0) - return (EPERM); - if ((pp->ace + de) > 0 && pp2->acw > 0) - return (EPERM); + if (dr > 0 || dw > 0 || de > 0) { + gsl = &gsp->slices[pp->index]; + for (u = 0; u < gsp->nslice; u++) { + gsl2 = &gsp->slices[u]; + if (gsl2->length == 0) + continue; + if (u == pp->index) + continue; + if (gsl->offset + gsl->length <= gsl2->offset) + continue; + if (gsl2->offset + gsl2->length <= gsl->offset) + continue; + /* overlap */ + pp2 = gsl2->provider; + if ((pp->acw + dw) > 0 && pp2->ace > 0) + return (EPERM); + if ((pp->ace + de) > 0 && pp2->acw > 0) + return (EPERM); + } } /* On first open, grab an extra "exclusive" bit */ if (cp->acr == 0 && cp->acw == 0 && cp->ace == 0) -- cgit v1.1