From a3fbbe344794f5a34315c031a6a8a9afa5b6f7c1 Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 6 Oct 2005 19:47:04 +0000 Subject: [PATCH] Make sure that the worker thread knows the type early enough to grab Giant for vnode backing. Found by: pho & tegge --- sys/dev/md/md.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 6c4019137390..ac617758c945 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -696,7 +696,7 @@ mdfind(int unit) } static struct md_s * -mdnew(int unit, int *errp) +mdnew(int unit, int *errp, enum md_types type) { struct md_s *sc, *sc2; int error, max = -1; @@ -713,6 +713,7 @@ mdnew(int unit, int *errp) if (unit == -1) unit = max + 1; sc = (struct md_s *)malloc(sizeof *sc, M_MD, M_WAITOK | M_ZERO); + sc->type = type; bioq_init(&sc->bio_queue); mtx_init(&sc->queue_mtx, "md bio queue", NULL, MTX_DEF); sc->unit = unit; @@ -1013,14 +1014,13 @@ xmdctlioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread return (EINVAL); } if (mdio->md_options & MD_AUTOUNIT) - sc = mdnew(-1, &error); + sc = mdnew(-1, &error, mdio->md_type); else - sc = mdnew(mdio->md_unit, &error); + sc = mdnew(mdio->md_unit, &error, mdio->md_type); if (sc == NULL) return (error); if (mdio->md_options & MD_AUTOUNIT) mdio->md_unit = sc->unit; - sc->type = mdio->md_type; sc->mediasize = mdio->md_mediasize; if (mdio->md_sectorsize == 0) sc->sectorsize = DEV_BSIZE; @@ -1110,10 +1110,9 @@ md_preloaded(u_char *image, size_t length) struct md_s *sc; int error; - sc = mdnew(-1, &error); + sc = mdnew(-1, &error, MD_PRELOAD); if (sc == NULL) return; - sc->type = MD_PRELOAD; sc->mediasize = length; sc->sectorsize = DEV_BSIZE; sc->pl_ptr = image;