From 12146c454be5b9124e28503e574b74888131fe05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Schmidt?= Date: Sun, 2 Nov 2003 22:24:47 +0000 Subject: [PATCH] Fix burning of CD's that got broken by the GEOM'ification. GEOM was not designed to handle media that does not have a size. Blank CD's are of that type, so cheat and set the media size to -1. This allows burning to work, but makes GEOM issue outofrange reads that makes the ATAPI subsystem spew out a few warnings. GEOM should be tought about this. GEOM was not designed to handle changing the sectorsize between opens. Writing multitack CD's with both audio and data tracks needs to change sector size on the fly. We cheat here and stuff the current sectorsize into GEOM private internals. GEOM should grow some clean way for this. --- sys/dev/ata/atapi-cd.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index 88ea1cc90577..e5dcc9f71967 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -233,6 +233,7 @@ acd_init_lun(struct ata_device *atadev) cdp->device = atadev; cdp->lun = ata_get_lun(&acd_lun_map); cdp->block_size = 2048; + cdp->disk_size = -1; /* hack for GEOM SOS */ cdp->slot = -1; cdp->changer_info = NULL; return cdp; @@ -518,16 +519,11 @@ acd_geom_access(struct g_provider *pp, int dr, int dw, int de) acd_prevent_allow(cdp, 0); cdp->flags &= ~F_LOCKED; } - pp->mediasize = (off_t)cdp->disk_size * (off_t)cdp->block_size; - pp->sectorsize = cdp->block_size; - track = pp->index; - - if (track) { + if ((track = pp->index)) { pp->sectorsize = (cdp->toc.tab[track - 1].control & 4) ? 2048 : 2352; - pp->mediasize = - ntohl(cdp->toc.tab[track].addr.lba) - - ntohl(cdp->toc.tab[track - 1].addr.lba); + pp->mediasize = ntohl(cdp->toc.tab[track].addr.lba) - + ntohl(cdp->toc.tab[track - 1].addr.lba); } else { pp->sectorsize = cdp->block_size; @@ -950,6 +946,7 @@ acd_geom_ioctl(struct g_provider *pp, u_long cmd, void *addr, struct thread *td) case CDRIOCSETBLOCKSIZE: cdp->block_size = *(int *)addr; + pp->sectorsize = cdp->block_size; /* hack for GEOM SOS */ acd_set_ioparm(cdp); break; @@ -1013,7 +1010,6 @@ acd_geom_start(struct bio *bp) /* GEOM classes must do their own request limiting */ if (bp->bio_length <= cdp->iomax) { - mtx_lock(&cdp->queue_mtx); bp->bio_pblkno = bp->bio_offset / bp->bio_to->sectorsize; bioq_disksort(&cdp->queue, bp);