From 4e8bfe148260702a6d750c239434e43a3a47a40c Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Wed, 9 Apr 2003 11:59:29 +0000 Subject: [PATCH] Add a couple of undocumented test options to MD(4) to aid in regression testting of GEOM. --- sbin/mdconfig/mdconfig.c | 12 ++++++++- sys/dev/md/md.c | 55 ++++++++++++++++++++++++---------------- sys/sys/mdioctl.h | 4 ++- 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c index 2f0049b6c755..0269fe943d4f 100644 --- a/sbin/mdconfig/mdconfig.c +++ b/sbin/mdconfig/mdconfig.c @@ -54,7 +54,7 @@ main(int argc, char **argv) int cmdline = 0; for (;;) { - ch = getopt(argc, argv, "ab:df:lo:s:S:t:u:"); + ch = getopt(argc, argv, "ab:df:lo:s:S:t:u:x:y:"); if (ch == -1) break; switch (ch) { @@ -163,6 +163,16 @@ main(int argc, char **argv) errx(1, "bad unit: %s", optarg); mdio.md_options &= ~MD_AUTOUNIT; break; + case 'x': + if (cmdline != 2) + usage(); + mdio.md_fwsectors = strtoul(optarg, &p, 0); + break; + case 'y': + if (cmdline != 2) + usage(); + mdio.md_fwheads = strtoul(optarg, &p, 0); + break; default: usage(); } diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 5b62659cadce..9e2bdf9c583f 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -147,6 +147,8 @@ struct md_s { unsigned nsect; unsigned opencount; unsigned secsize; + unsigned fwheads; + unsigned fwsectors; unsigned flags; char name[20]; struct proc *procp; @@ -366,11 +368,6 @@ g_md_start(struct bio *bp) sc = bp->bio_to->geom->softc; - switch(bp->bio_cmd) { - case BIO_GETATTR: - g_io_deliver(bp, EOPNOTSUPP); - return; - } bp->bio_blkno = bp->bio_offset >> DEV_BSHIFT; bp->bio_pblkno = bp->bio_offset / sc->secsize; bp->bio_bcount = bp->bio_length; @@ -586,23 +583,33 @@ md_kthread(void *arg) continue; } mtx_unlock(&sc->queue_mtx); - - switch (sc->type) { - case MD_MALLOC: - error = mdstart_malloc(sc, bp); - break; - case MD_PRELOAD: - error = mdstart_preload(sc, bp); - break; - case MD_VNODE: - error = mdstart_vnode(sc, bp); - break; - case MD_SWAP: - error = mdstart_swap(sc, bp); - break; - default: - panic("Impossible md(type)"); - break; + if (bp->bio_cmd == BIO_GETATTR) { + if (sc->fwsectors && sc->fwheads && + (g_handleattr_int(bp, "GEOM::fwsectors", + sc->fwsectors) || + g_handleattr_int(bp, "GEOM::fwheads", + sc->fwheads))) + error = -1; + else + error = EOPNOTSUPP; + } else { + switch (sc->type) { + case MD_MALLOC: + error = mdstart_malloc(sc, bp); + break; + case MD_PRELOAD: + error = mdstart_preload(sc, bp); + break; + case MD_VNODE: + error = mdstart_vnode(sc, bp); + break; + case MD_SWAP: + error = mdstart_swap(sc, bp); + break; + default: + panic("Impossible md(type)"); + break; + } } if (error != -1) { @@ -752,6 +759,10 @@ mdcreate_malloc(struct md_ioctl *mdio) sc->secsize = mdio->md_secsize; else sc->secsize = DEV_BSIZE; + if (mdio->md_fwsectors != 0) + sc->fwsectors = mdio->md_fwsectors; + if (mdio->md_fwheads != 0) + sc->fwheads = mdio->md_fwheads; sc->nsect = mdio->md_size; sc->nsect /= (sc->secsize / DEV_BSIZE); sc->flags = mdio->md_options & (MD_COMPRESS | MD_FORCE); diff --git a/sys/sys/mdioctl.h b/sys/sys/mdioctl.h index 89b95221f89c..3ba206b6aa9a 100644 --- a/sys/sys/mdioctl.h +++ b/sys/sys/mdioctl.h @@ -53,7 +53,7 @@ enum md_types {MD_MALLOC, MD_PRELOAD, MD_VNODE, MD_SWAP}; * Ioctl definitions for memory disk pseudo-device. */ -#define MDNPAD 99 +#define MDNPAD 97 struct md_ioctl { unsigned md_version; /* Structure layout version */ unsigned md_unit; /* unit number */ @@ -63,6 +63,8 @@ struct md_ioctl { unsigned md_options; /* options */ u_int64_t md_base; /* base address */ int md_secsize; /* sectorsize */ + int md_fwheads; /* firmware heads */ + int md_fwsectors; /* firmware sectors */ int md_pad[MDNPAD]; /* padding for future ideas */ };