Remove the absolute count g_access_abs() function since experience has

shown that it is not useful.

Rename the relative count g_access_rel() function to g_access(), only
the name has changed.

Change all g_access_rel() calls in our CVS tree to call g_access() instead.

Add an #ifndef BURN_BRIDGES #define of g_access_rel() for source
code compatibility.
This commit is contained in:
Poul-Henning Kamp 2004-02-12 22:42:11 +00:00
parent 63dfee8866
commit d2bae332d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125755
17 changed files with 55 additions and 71 deletions

View File

@ -108,7 +108,7 @@ g_bde_access(struct g_provider *pp, int dr, int dw, int de)
de--;
dr--;
}
return (g_access_rel(cp, dr, dw, de));
return (g_access(cp, dr, dw, de));
}
static void
@ -136,7 +136,7 @@ g_bde_create_geom(struct gctl_req *req, struct g_class *mp, struct g_provider *p
gp->spoiled = g_std_spoiled;
cp = g_new_consumer(gp);
g_attach(cp, pp);
error = g_access_rel(cp, 1, 1, 1);
error = g_access(cp, 1, 1, 1);
if (error) {
g_detach(cp);
g_destroy_consumer(cp);
@ -211,7 +211,7 @@ g_bde_create_geom(struct gctl_req *req, struct g_class *mp, struct g_provider *p
bzero(key, 16);
if (error == 0)
return;
g_access_rel(cp, -1, -1, -1);
g_access(cp, -1, -1, -1);
g_detach(cp);
g_destroy_consumer(cp);
if (gp->softc != NULL)
@ -244,7 +244,7 @@ g_bde_destroy_geom(struct gctl_req *req, struct g_class *mp, struct g_geom *gp)
KASSERT(cp != NULL, ("NULL consumer"));
sc->dead = 1;
wakeup(sc);
error = g_access_rel(cp, -1, -1, -1);
error = g_access(cp, -1, -1, -1);
KASSERT(error == 0, ("error on close"));
g_detach(cp);
g_destroy_consumer(cp);

View File

@ -202,8 +202,10 @@ void g_orphan_provider(struct g_provider *pp, int error);
void g_waitidle(void);
/* geom_subr.c */
int g_access_abs(struct g_consumer *cp, int nread, int nwrite, int nexcl);
int g_access_rel(struct g_consumer *cp, int nread, int nwrite, int nexcl);
int g_access(struct g_consumer *cp, int nread, int nwrite, int nexcl);
#ifndef BURN_BRIDGES
#define g_access_rel(a, b, c, d) g_access(a, b, c, d)
#endif
int g_attach(struct g_consumer *cp, struct g_provider *pp);
void g_destroy_consumer(struct g_consumer *cp);
void g_destroy_geom(struct g_geom *pp);

View File

@ -266,7 +266,7 @@ g_aes_access(struct g_provider *pp, int dr, int dw, int de)
/* ... and let go of it on last close */
if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1)
de--;
return (g_access_rel(cp, dr, dw, de));
return (g_access(cp, dr, dw, de));
}
static struct g_geom *
@ -288,7 +288,7 @@ g_aes_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
gp->spoiled = g_std_spoiled;
cp = g_new_consumer(gp);
g_attach(cp, pp);
error = g_access_rel(cp, 1, 0, 0);
error = g_access(cp, 1, 0, 0);
if (error) {
g_detach(cp);
g_destroy_consumer(cp);
@ -357,7 +357,7 @@ g_aes_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_topology_lock();
if (buf)
g_free(buf);
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (gp->softc != NULL)
return (gp);
g_detach(cp);

View File

@ -243,7 +243,7 @@ g_apple_taste(struct g_class *mp, struct g_provider *pp, int insist)
break;
} while(0);
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
return (NULL);

View File

@ -569,7 +569,7 @@ g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
} while (0);
/* Success or failure, we can close our provider now. */
error = g_access_rel(cp, -1, 0, 0);
error = g_access(cp, -1, 0, 0);
/* If we have configured any providers, return the new geom. */
if (gsp->nprovider > 0) {
@ -639,26 +639,26 @@ g_bsd_config(struct gctl_req *req, struct g_class *mp, char const *verb)
h0h0.label = label;
h0h0.error = -1;
/* XXX: Does this reference register with our selfdestruct code ? */
error = g_access_rel(cp, 1, 1, 1);
error = g_access(cp, 1, 1, 1);
if (error) {
gctl_error(req, "could not access consumer");
return;
}
g_bsd_callconfig(&h0h0, 0);
error = h0h0.error;
g_access_rel(cp, -1, -1, -1);
g_access(cp, -1, -1, -1);
} else if (!strcmp(verb, "write bootcode")) {
label = gctl_get_paraml(req, "bootcode", BBSIZE);
if (label == NULL)
return;
/* XXX: Does this reference register with our selfdestruct code ? */
error = g_access_rel(cp, 1, 1, 1);
error = g_access(cp, 1, 1, 1);
if (error) {
gctl_error(req, "could not access consumer");
return;
}
error = g_bsd_writelabel(gp, label);
g_access_rel(cp, -1, -1, -1);
g_access(cp, -1, -1, -1);
} else {
gctl_error(req, "Unknown verb parameter");
}

View File

@ -168,12 +168,12 @@ g_ccd_access(struct g_provider *pp, int dr, int dw, int de)
gp = pp->geom;
error = ENXIO;
LIST_FOREACH(cp1, &gp->consumer, consumer) {
error = g_access_rel(cp1, dr, dw, de);
error = g_access(cp1, dr, dw, de);
if (error) {
LIST_FOREACH(cp2, &gp->consumer, consumer) {
if (cp1 == cp2)
break;
g_access_rel(cp2, -dr, -dw, -de);
g_access(cp2, -dr, -dw, -de);
}
break;
}

View File

@ -213,7 +213,7 @@ g_dev_open(dev_t dev, int flags, int fmt, struct thread *td)
if (dev->si_devsw == NULL)
error = ENXIO; /* We were orphaned */
else
error = g_access_rel(cp, r, w, e);
error = g_access(cp, r, w, e);
g_topology_unlock();
g_waitidle();
if (!error)
@ -245,7 +245,7 @@ g_dev_close(dev_t dev, int flags, int fmt, struct thread *td)
if (dev->si_devsw == NULL)
error = ENXIO; /* We were orphaned */
else
error = g_access_rel(cp, r, w, e);
error = g_access(cp, r, w, e);
for (i = 0; i < 10 * hz;) {
if (cp->acr != 0 || cp->acw != 0)
break;
@ -434,7 +434,7 @@ g_dev_orphan(struct g_consumer *cp)
msleep(&dev, NULL, PRIBIO, "gdevorphan", hz / 10);
if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0)
g_access_rel(cp, -cp->acr, -cp->acw, -cp->ace);
g_access(cp, -cp->acr, -cp->acw, -cp->ace);
g_detach(cp);
g_destroy_consumer(cp);

View File

@ -90,13 +90,13 @@ g_fox_select_path(void *arg, int flag)
cp1 = LIST_NEXT(sc->opath, consumer);
error = g_access_rel(sc->opath, -sc->cr, -sc->cw, -(sc->ce + 1));
error = g_access(sc->opath, -sc->cr, -sc->cw, -(sc->ce + 1));
KASSERT(error == 0, ("Failed close of old path %d", error));
/*
* The attempt to reopen it with a exclusive count
*/
error = g_access_rel(sc->opath, 0, 0, 1);
error = g_access(sc->opath, 0, 0, 1);
if (error) {
/*
* Ok, ditch this consumer, we can't use it.
@ -130,7 +130,7 @@ g_fox_select_path(void *arg, int flag)
cp1 = LIST_FIRST(&gp->consumer);
printf("Open new path (%s) on fox (%s)\n",
cp1->provider->name, gp->name);
error = g_access_rel(cp1, sc->cr, sc->cw, sc->ce);
error = g_access(cp1, sc->cr, sc->cw, sc->ce);
if (error) {
/*
* If we failed, we take another trip through here
@ -179,7 +179,7 @@ g_fox_orphan(struct g_consumer *cp)
}
mtx_unlock(&sc->lock);
g_access_rel(cp, -cp->acr, -cp->acw, -cp->ace);
g_access(cp, -cp->acr, -cp->acw, -cp->ace);
error = cp->provider->error;
g_detach(cp);
g_destroy_consumer(cp);
@ -299,7 +299,7 @@ g_fox_access(struct g_provider *pp, int dr, int dw, int de)
*/
error = 0;
LIST_FOREACH(cp1, &gp->consumer, consumer) {
error = g_access_rel(cp1, 0, 0, 1);
error = g_access(cp1, 0, 0, 1);
if (error) {
printf("FOX: access(%s,0,0,1) = %d\n",
cp1->provider->name, error);
@ -309,7 +309,7 @@ g_fox_access(struct g_provider *pp, int dr, int dw, int de)
if (error) {
LIST_FOREACH(cp1, &gp->consumer, consumer) {
if (cp1->ace)
g_access_rel(cp1, 0, 0, -1);
g_access(cp1, 0, 0, -1);
}
return (error);
}
@ -319,7 +319,7 @@ g_fox_access(struct g_provider *pp, int dr, int dw, int de)
if (sc->path == NULL)
error = ENXIO;
else
error = g_access_rel(sc->path, dr, dw, de);
error = g_access(sc->path, dr, dw, de);
if (error == 0) {
sc->cr += dr;
sc->cw += dw;
@ -329,7 +329,7 @@ g_fox_access(struct g_provider *pp, int dr, int dw, int de)
* Last close, remove e-bit on all consumers
*/
LIST_FOREACH(cp1, &gp->consumer, consumer)
g_access_rel(cp1, 0, 0, -1);
g_access(cp1, 0, 0, -1);
}
}
return (error);
@ -360,7 +360,7 @@ g_fox_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
gp->access= g_fox_access;
cp = g_new_consumer(gp);
g_attach(cp, pp);
error = g_access_rel(cp, 1, 0, 0);
error = g_access(cp, 1, 0, 0);
if (error) {
g_free(sc);
g_detach(cp);
@ -401,7 +401,7 @@ g_fox_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_attach(cp2, pp);
pp2 = LIST_FIRST(&gp2->provider);
if (pp2->acr > 0 || pp2->acw > 0 || pp2->ace > 0) {
error = g_access_rel(cp2, 0, 0, 1);
error = g_access(cp2, 0, 0, 1);
if (error) {
/*
* This is bad, or more likely,
@ -433,7 +433,7 @@ printf("fox %s lock %p\n", gp->name, &sc->lock);
} while (0);
if (buf != NULL)
g_free(buf);
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (!LIST_EMPTY(&gp->provider))
return (gp);

View File

@ -211,7 +211,7 @@ g_gpt_taste(struct g_class *mp, struct g_provider *pp, int insist)
g_free(mbr);
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
return (NULL);

View File

@ -263,7 +263,7 @@ g_mbr_taste(struct g_class *mp, struct g_provider *pp, int insist)
break;
} while (0);
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
return (NULL);
@ -403,7 +403,7 @@ g_mbrext_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
break;
} while (0);
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
return (NULL);

View File

@ -73,7 +73,7 @@ g_mirror_orphan(struct g_consumer *cp)
g_topology_assert();
gp = cp->geom;
g_access_rel(cp, -cp->acr, -cp->acw, -cp->ace);
g_access(cp, -cp->acr, -cp->acw, -cp->ace);
error = cp->provider->error;
g_detach(cp);
g_destroy_consumer(cp);
@ -143,12 +143,12 @@ g_mirror_access(struct g_provider *pp, int dr, int dw, int de)
gp = pp->geom;
error = ENXIO;
LIST_FOREACH(cp1, &gp->consumer, consumer) {
error = g_access_rel(cp1, dr, dw, de);
error = g_access(cp1, dr, dw, de);
if (error) {
LIST_FOREACH(cp2, &gp->consumer, consumer) {
if (cp2 == cp1)
break;
g_access_rel(cp2, -dr, -dw, -de);
g_access(cp2, -dr, -dw, -de);
}
return (error);
}
@ -177,7 +177,7 @@ g_mirror_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
gp->access= g_mirror_access;
cp = g_new_consumer(gp);
g_attach(cp, pp);
error = g_access_rel(cp, 1, 0, 0);
error = g_access(cp, 1, 0, 0);
if (error) {
g_detach(cp);
g_destroy_consumer(cp);
@ -220,7 +220,7 @@ g_mirror_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_topology_lock();
if (buf != NULL)
g_free(buf);
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (gp->softc != NULL)
return (gp);
g_detach(cp);

View File

@ -273,7 +273,7 @@ g_pc98_taste(struct g_class *mp, struct g_provider *pp, int flags)
break;
} while (0);
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
return (NULL);

View File

@ -119,7 +119,7 @@ g_slice_access(struct g_provider *pp, int dr, int dw, int de)
/* ... and let go of it on last close */
if ((cp->acr + dr) == 0 && (cp->acw + dw) == 0 && (cp->ace + de) == 1)
de--;
error = g_access_rel(cp, dr, dw, de);
error = g_access(cp, dr, dw, de);
return (error);
}
@ -463,7 +463,7 @@ g_slice_new(struct g_class *mp, u_int slices, struct g_provider *pp, struct g_co
cp = g_new_consumer(gp);
error = g_attach(cp, pp);
if (error == 0)
error = g_access_rel(cp, 1, 0, 0);
error = g_access(cp, 1, 0, 0);
if (error) {
g_wither_geom(gp, ENXIO);
return (NULL);

View File

@ -558,33 +558,15 @@ g_detach(struct g_consumer *cp)
redo_rank(cp->geom);
}
/*
* g_access_abs()
*
* Access-check with absolute new values: Just fall through
* and use the relative version.
*/
int
g_access_abs(struct g_consumer *cp, int acr, int acw, int ace)
{
g_topology_assert();
return(g_access_rel(cp,
acr - cp->acr,
acw - cp->acw,
ace - cp->ace));
}
/*
* g_access_rel()
* g_access()
*
* Access-check with delta values. The question asked is "can provider
* "cp" change the access counters by the relative amounts dc[rwe] ?"
*/
int
g_access_rel(struct g_consumer *cp, int dcr, int dcw, int dce)
g_access(struct g_consumer *cp, int dcr, int dcw, int dce)
{
struct g_provider *pp;
int pr,pw,pe;
@ -592,7 +574,7 @@ g_access_rel(struct g_consumer *cp, int dcr, int dcw, int dce)
pp = cp->provider;
g_trace(G_T_ACCESS, "g_access_rel(%p(%s), %d, %d, %d)",
g_trace(G_T_ACCESS, "g_access(%p(%s), %d, %d, %d)",
cp, pp->name, dcr, dcw, dce);
g_topology_assert();

View File

@ -194,19 +194,19 @@ g_sunlabel_config(struct gctl_req *req, struct g_class *mp, const char *verb)
h0h0.label = label;
h0h0.error = -1;
/* XXX: Does this reference register with our selfdestruct code ? */
error = g_access_rel(cp, 1, 1, 1);
error = g_access(cp, 1, 1, 1);
if (error) {
gctl_error(req, "could not access consumer");
return;
}
g_sunlabel_callconfig(&h0h0, 0);
g_access_rel(cp, -1, -1, -1);
g_access(cp, -1, -1, -1);
} else if (!strcmp(verb, "write bootcode")) {
label = gctl_get_paraml(req, "bootcode", SUN_BOOTSIZE);
if (label == NULL)
return;
/* XXX: Does this reference register with our selfdestruct code ? */
error = g_access_rel(cp, 1, 1, 1);
error = g_access(cp, 1, 1, 1);
if (error) {
gctl_error(req, "could not access consumer");
return;
@ -218,7 +218,7 @@ g_sunlabel_config(struct gctl_req *req, struct g_class *mp, const char *verb)
gsp->slices[i].offset + SUN_SIZE, label + SUN_SIZE,
SUN_BOOTSIZE - SUN_SIZE);
}
g_access_rel(cp, -1, -1, -1);
g_access(cp, -1, -1, -1);
} else {
gctl_error(req, "Unknown verb parameter");
}
@ -261,7 +261,7 @@ g_sunlabel_taste(struct g_class *mp, struct g_provider *pp, int flags)
break;
} while (0);
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
return (NULL);

View File

@ -127,7 +127,7 @@ g_vol_ffs_taste(struct g_class *mp, struct g_provider *pp, int flags)
break;
}
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
g_access(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
return (NULL);

View File

@ -2449,7 +2449,7 @@ swapgeom_close_ev(void *arg, int flags)
struct g_consumer *cp;
cp = arg;
g_access_rel(cp, -1, -1, 0);
g_access(cp, -1, -1, 0);
g_detach(cp);
g_destroy_consumer(cp);
}
@ -2509,7 +2509,7 @@ swapongeom_ev(void *arg, int flags)
* savecore(8) wants to write to our swapdev so we cannot
* set an exclusive count :-(
*/
error = g_access_rel(cp, 1, 1, 0);
error = g_access(cp, 1, 1, 0);
if (error) {
g_detach(cp);
g_destroy_consumer(cp);