diff options
author | phk <phk@FreeBSD.org> | 2003-05-02 06:42:59 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-05-02 06:42:59 +0000 |
commit | 055cf65eb1d06904d69d4b58914213644ad8cb0d (patch) | |
tree | bb8126af9ed3864ba67d3f80bced0b3ac8d831ee /sys/geom | |
parent | 9bb7fb74d1c16b096bf1753ef0429c85eb933304 (diff) | |
download | FreeBSD-src-055cf65eb1d06904d69d4b58914213644ad8cb0d.zip FreeBSD-src-055cf65eb1d06904d69d4b58914213644ad8cb0d.tar.gz |
Back out all the stuff that didn't belong in the last commit.
Diffstat (limited to 'sys/geom')
-rw-r--r-- | sys/geom/geom_aes.c | 8 | ||||
-rw-r--r-- | sys/geom/geom_ctl.c | 4 | ||||
-rw-r--r-- | sys/geom/geom_dev.c | 6 | ||||
-rw-r--r-- | sys/geom/geom_gpt.c | 9 | ||||
-rw-r--r-- | sys/geom/geom_io.c | 8 | ||||
-rw-r--r-- | sys/geom/geom_mbr.c | 8 | ||||
-rw-r--r-- | sys/geom/geom_subr.c | 21 | ||||
-rw-r--r-- | sys/geom/geom_vol_ffs.c | 8 |
8 files changed, 27 insertions, 45 deletions
diff --git a/sys/geom/geom_aes.c b/sys/geom/geom_aes.c index 0745624..95055dd 100644 --- a/sys/geom/geom_aes.c +++ b/sys/geom/geom_aes.c @@ -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; diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index 88ab37e..92ef461 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -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: diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index 9b25871..b090d75 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -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); } diff --git a/sys/geom/geom_gpt.c b/sys/geom/geom_gpt.c index b747d58..0783ecb 100644 --- a/sys/geom/geom_gpt.c +++ b/sys/geom/geom_gpt.c @@ -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); diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index 12d75f8..e325ecd 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -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 * diff --git a/sys/geom/geom_mbr.c b/sys/geom/geom_mbr.c index c0232a7..362e540 100644 --- a/sys/geom/geom_mbr.c +++ b/sys/geom/geom_mbr.c @@ -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); diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c index ce2d876..d45dd2b 100644 --- a/sys/geom/geom_subr.c +++ b/sys/geom/geom_subr.c @@ -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; } /* diff --git a/sys/geom/geom_vol_ffs.c b/sys/geom/geom_vol_ffs.c index 7fedfc1..a01af4d 100644 --- a/sys/geom/geom_vol_ffs.c +++ b/sys/geom/geom_vol_ffs.c @@ -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); |