aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2003-05-02 06:36:14 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2003-05-02 06:36:14 +0000
commite65ab0f83f84e205c339b85421539b507c43b978 (patch)
treef30ff1854b1e718bcb5d94f16dcee4c13b5afe1a
parent4f806d2428f2f1f8692f61976b935a1429e6fecc (diff)
downloadsrc-e65ab0f83f84e205c339b85421539b507c43b978.tar.gz
src-e65ab0f83f84e205c339b85421539b507c43b978.zip
Use g_slice_spoiled() rather than g_std_spoiled().
Remember to free the buffer we got from g_read_data().
Notes
Notes: svn path=/head/; revision=114508
-rw-r--r--sys/geom/geom_aes.c8
-rw-r--r--sys/geom/geom_apple.c3
-rw-r--r--sys/geom/geom_ctl.c4
-rw-r--r--sys/geom/geom_dev.c6
-rw-r--r--sys/geom/geom_gpt.c9
-rw-r--r--sys/geom/geom_io.c8
-rw-r--r--sys/geom/geom_mbr.c8
-rw-r--r--sys/geom/geom_subr.c21
-rw-r--r--sys/geom/geom_vol_ffs.c8
9 files changed, 47 insertions, 28 deletions
diff --git a/sys/geom/geom_aes.c b/sys/geom/geom_aes.c
index 95055dd4d77b..074562435bf7 100644
--- a/sys/geom/geom_aes.c
+++ b/sys/geom/geom_aes.c
@@ -251,11 +251,9 @@ g_aes_orphan(struct g_consumer *cp)
gp = cp->geom;
sc = gp->softc;
- gp->flags |= G_GEOM_WITHER;
- error = cp->provider->error;
- LIST_FOREACH(pp, &gp->provider, provider)
- g_orphan_provider(pp, error);
+ g_wither_geom(gp, cp->provider->error);
bzero(sc, sizeof(struct g_aes_softc)); /* destroy evidence */
+ g_free(sc);
return;
}
@@ -323,9 +321,11 @@ 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_apple.c b/sys/geom/geom_apple.c
index 503a52082a8f..24bd909b98ab 100644
--- a/sys/geom/geom_apple.c
+++ b/sys/geom/geom_apple.c
@@ -246,12 +246,13 @@ g_apple_taste(struct g_class *mp, struct g_provider *pp, int insist)
"%ss%d", gp->name, i + 1);
g_topology_unlock();
}
+ g_free(buf);
break;
} while(0);
g_topology_lock();
g_access_rel(cp, -1, 0, 0);
if (LIST_EMPTY(&gp->provider)) {
- g_std_spoiled(cp);
+ g_slice_spoiled(cp);
return (NULL);
}
return (gp);
diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c
index 92ef4615d712..88ab37e9819c 100644
--- a/sys/geom/geom_ctl.c
+++ b/sys/geom/geom_ctl.c
@@ -509,11 +509,15 @@ 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 b090d753b56e..9b25871f2b5c 100644
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -244,6 +244,7 @@ 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
@@ -272,7 +273,6 @@ 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 = g_malloc(sizeof *gio, M_WAITOK | M_ZERO);
+ gio = malloc(sizeof *gio, M_GEOMGIO, 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)
- g_free(gio);
+ free(gio, M_GEOMGIO);
return (error);
}
diff --git a/sys/geom/geom_gpt.c b/sys/geom/geom_gpt.c
index 0783ecb5d541..b747d58bd75d 100644
--- a/sys/geom/geom_gpt.c
+++ b/sys/geom/geom_gpt.c
@@ -105,6 +105,8 @@ 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)
{
@@ -188,7 +190,10 @@ 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;
- gs->part[i] = g_malloc(hdr->hdr_entsz, M_WAITOK);
+ /*
+ * XXX: memory leak, this is never freed.
+ */
+ gs->part[i] = malloc(hdr->hdr_entsz, M_GEOMGPT, M_WAITOK);
if (gs->part[i] == NULL)
break;
bcopy(ent, gs->part[i], hdr->hdr_entsz);
@@ -214,7 +219,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_std_spoiled(cp);
+ g_slice_spoiled(cp);
return (NULL);
}
return (gp);
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index e325ecd98d3a..12d75f8afa09 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -109,6 +109,8 @@ 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)
{
@@ -118,7 +120,7 @@ g_new_bio(void)
bp = g_bioq_first(&g_bio_idle);
g_bioq_unlock(&g_bio_idle);
if (bp == NULL)
- bp = g_malloc(sizeof *bp, M_NOWAIT | M_ZERO);
+ bp = malloc(sizeof *bp, M_GEOMBIO, M_NOWAIT | M_ZERO);
/* g_trace(G_T_BIO, "g_new_bio() = %p", bp); */
return (bp);
}
@@ -127,9 +129,13 @@ 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 362e54089c8f..c0232a7ebb50 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_std_spoiled(cp);
+ g_slice_spoiled(cp);
return (NULL);
}
return (gp);
@@ -398,8 +398,10 @@ 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)
+ if (buf[0x1fe] != 0x55 && buf[0x1ff] != 0xaa) {
+ g_free(buf);
break;
+ }
for (i = 0; i < NDOSPART; i++)
dos_partition_dec(
buf + DOSPARTOFF +
@@ -440,7 +442,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_std_spoiled(cp);
+ g_slice_spoiled(cp);
return (NULL);
}
return (gp);
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index d45dd2b6deb5..ce2d876e44e8 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -237,7 +237,9 @@ 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)
@@ -254,7 +256,12 @@ g_new_provider_event(void *arg, int flag)
i = 0;
if (!i)
continue;
- mp->taste(mp, pp, 0);
+ 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);
g_topology_assert();
}
}
@@ -595,20 +602,10 @@ 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_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;
+ g_wither_geom(cp->geom, ENXIO);
}
/*
diff --git a/sys/geom/geom_vol_ffs.c b/sys/geom/geom_vol_ffs.c
index a01af4dc7af5..7fedfc195c88 100644
--- a/sys/geom/geom_vol_ffs.c
+++ b/sys/geom/geom_vol_ffs.c
@@ -89,8 +89,12 @@ 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 || error != 0)
+ if (fs == NULL)
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 !=
@@ -128,7 +132,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_std_spoiled(cp);
+ g_slice_spoiled(cp);
return (NULL);
}
return (gp);