Back out all the stuff that didn't belong in the last commit.

This commit is contained in:
Poul-Henning Kamp 2003-05-02 06:42:59 +00:00
parent be8930b3ec
commit c4da4e46b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114511
8 changed files with 27 additions and 45 deletions

View File

@ -251,9 +251,11 @@ g_aes_orphan(struct g_consumer *cp)
gp = cp->geom;
sc = gp->softc;
g_wither_geom(gp, cp->provider->error);
gp->flags |= G_GEOM_WITHER;
error = cp->provider->error;
LIST_FOREACH(pp, &gp->provider, provider)
g_orphan_provider(pp, error);
bzero(sc, sizeof(struct g_aes_softc)); /* destroy evidence */
g_free(sc);
return;
}
@ -321,11 +323,9 @@ g_aes_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
strlen(aes_magic_test))) {
sc->keying = KEY_TEST;
} else {
g_free(buf);
g_free(sc);
break;
}
g_free(buf);
gp->softc = sc;
gp->access = g_aes_access;
sc->sectorsize = sectorsize;

View File

@ -509,15 +509,11 @@ static int
g_ctl_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
{
int error;
u_long l1, l2;
switch(cmd) {
case GEOM_CTL:
DROP_GIANT();
l1 = M_GEOM[0].ks_memuse;
error = g_ctl_ioctl_ctl(dev, cmd, data, fflag, td);
l2 = M_GEOM[0].ks_memuse;
printf("%ld %ld -> %ld\n", l1, l2, l2 - l1);
PICKUP_GIANT();
break;
default:

View File

@ -244,7 +244,6 @@ g_dev_close(dev_t dev, int flags, int fmt, struct thread *td)
return (error);
}
MALLOC_DEFINE(M_GEOMGIO, "GEOMGIO", "Geom data structures");
/*
* XXX: Until we have unmessed the ioctl situation, there is a race against
* XXX: a concurrent orphanization. We cannot close it by holding topology
@ -273,6 +272,7 @@ g_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
("Consumer with zero access count in g_dev_ioctl"));
DROP_GIANT();
gio = NULL;
i = IOCPARM_LEN(cmd);
switch (cmd) {
case DIOCGSECTORSIZE:
@ -314,7 +314,7 @@ g_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
break;
default:
gio = malloc(sizeof *gio, M_GEOMGIO, M_WAITOK | M_ZERO);
gio = g_malloc(sizeof *gio, M_WAITOK | M_ZERO);
gio->cmd = cmd;
gio->data = data;
gio->fflag = fflag;
@ -354,7 +354,7 @@ g_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
error = ENOTTY;
}
if (gio != NULL)
free(gio, M_GEOMGIO);
g_free(gio);
return (error);
}

View File

@ -105,8 +105,6 @@ g_gpt_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
}
}
MALLOC_DEFINE(M_GEOMGPT, "GEOMGPT", "Geom data structures");
static struct g_geom *
g_gpt_taste(struct g_class *mp, struct g_provider *pp, int insist)
{
@ -190,10 +188,7 @@ g_gpt_taste(struct g_class *mp, struct g_provider *pp, int insist)
ent = (void*)(buf + i * hdr->hdr_entsz);
if (!memcmp(&ent->ent_type, &unused, sizeof(unused)))
continue;
/*
* XXX: memory leak, this is never freed.
*/
gs->part[i] = malloc(hdr->hdr_entsz, M_GEOMGPT, M_WAITOK);
gs->part[i] = g_malloc(hdr->hdr_entsz, M_WAITOK);
if (gs->part[i] == NULL)
break;
bcopy(ent, gs->part[i], hdr->hdr_entsz);
@ -219,7 +214,7 @@ g_gpt_taste(struct g_class *mp, struct g_provider *pp, int insist)
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
g_std_spoiled(cp);
return (NULL);
}
return (gp);

View File

@ -109,8 +109,6 @@ g_bioq_enqueue_tail(struct bio *bp, struct g_bioq *rq)
g_bioq_unlock(rq);
}
MALLOC_DEFINE(M_GEOMBIO, "GEOM bio", "Geom bio");
struct bio *
g_new_bio(void)
{
@ -120,7 +118,7 @@ g_new_bio(void)
bp = g_bioq_first(&g_bio_idle);
g_bioq_unlock(&g_bio_idle);
if (bp == NULL)
bp = malloc(sizeof *bp, M_GEOMBIO, M_NOWAIT | M_ZERO);
bp = g_malloc(sizeof *bp, M_NOWAIT | M_ZERO);
/* g_trace(G_T_BIO, "g_new_bio() = %p", bp); */
return (bp);
}
@ -129,13 +127,9 @@ void
g_destroy_bio(struct bio *bp)
{
#if 0
/* g_trace(G_T_BIO, "g_destroy_bio(%p)", bp); */
bzero(bp, sizeof *bp);
g_bioq_enqueue_tail(bp, &g_bio_idle);
#else
free(bp, M_GEOMBIO);
#endif
}
struct bio *

View File

@ -300,7 +300,7 @@ g_mbr_taste(struct g_class *mp, struct g_provider *pp, int insist)
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
g_std_spoiled(cp);
return (NULL);
}
return (gp);
@ -398,10 +398,8 @@ g_mbrext_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
buf = g_read_data(cp, off, sectorsize, &error);
if (buf == NULL || error != 0)
break;
if (buf[0x1fe] != 0x55 && buf[0x1ff] != 0xaa) {
g_free(buf);
if (buf[0x1fe] != 0x55 && buf[0x1ff] != 0xaa)
break;
}
for (i = 0; i < NDOSPART; i++)
dos_partition_dec(
buf + DOSPARTOFF +
@ -442,7 +440,7 @@ g_mbrext_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
g_std_spoiled(cp);
return (NULL);
}
return (gp);

View File

@ -237,9 +237,7 @@ g_new_provider_event(void *arg, int flag)
struct g_class *mp;
struct g_provider *pp;
struct g_consumer *cp;
struct g_geom *gp;
int i;
u_long l1, l2;
g_topology_assert();
if (flag == EV_CANCEL)
@ -256,12 +254,7 @@ g_new_provider_event(void *arg, int flag)
i = 0;
if (!i)
continue;
l1 = M_GEOM[0].ks_memuse;
gp = mp->taste(mp, pp, 0);
l2 = M_GEOM[0].ks_memuse;
if (l1 != l2)
printf("%s %p %lu %lu -> %lu\n",
mp->name, gp, l1, l2, l2 - l1);
mp->taste(mp, pp, 0);
g_topology_assert();
}
}
@ -602,10 +595,20 @@ g_std_done(struct bio *bp)
void
g_std_spoiled(struct g_consumer *cp)
{
struct g_geom *gp;
struct g_provider *pp;
g_trace(G_T_TOPOLOGY, "g_std_spoiled(%p)", cp);
g_topology_assert();
g_wither_geom(cp->geom, ENXIO);
g_detach(cp);
gp = cp->geom;
LIST_FOREACH(pp, &gp->provider, provider)
g_orphan_provider(pp, ENXIO);
g_destroy_consumer(cp);
if (LIST_EMPTY(&gp->provider) && LIST_EMPTY(&gp->consumer))
g_destroy_geom(gp);
else
gp->flags |= G_GEOM_WITHER;
}
/*

View File

@ -89,12 +89,8 @@ g_vol_ffs_taste(struct g_class *mp, struct g_provider *pp, int flags)
for (sb=0; (superblock = superblocks[sb]) != -1; sb++) {
fs = (struct fs *) g_read_data(cp, superblock,
SBLOCKSIZE, &error);
if (fs == NULL)
if (fs == NULL || error != 0)
continue;
if (error != 0) {
g_free(fs);
continue;
}
/* Check for magic and make sure things are the right size */
if (fs->fs_magic == FS_UFS1_MAGIC) {
if (fs->fs_old_size * fs->fs_fsize !=
@ -132,7 +128,7 @@ g_vol_ffs_taste(struct g_class *mp, struct g_provider *pp, int flags)
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
g_slice_spoiled(cp);
g_std_spoiled(cp);
return (NULL);
}
return (gp);