diff options
author | phk <phk@FreeBSD.org> | 2002-09-20 19:36:05 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-09-20 19:36:05 +0000 |
commit | 57a346a21312d7f99ca28aee15ab6091be10cbd7 (patch) | |
tree | 47b5afae3623c1371d19a0478c850d8e6a08d07b /sys/dev/ata | |
parent | 2fb7a39c0fdc17568c3b60cf37e5f3c2d6dff5e4 (diff) | |
download | FreeBSD-src-57a346a21312d7f99ca28aee15ab6091be10cbd7.zip FreeBSD-src-57a346a21312d7f99ca28aee15ab6091be10cbd7.tar.gz |
(This commit touches about 15 disk device drivers in a very consistent
and predictable way, and I apologize if I have gotten it wrong anywhere,
getting prior review on a patch like this is not feasible, considering
the number of people involved and hardware availability etc.)
If struct disklabel is the messenger: kill the messenger.
Inside struct disk we had a struct disklabel which disk drivers used to
communicate certain metrics to the disklayer above (GEOM or the disk
mini-layer). This commit changes this communication to use four
explicit fields instead.
Amongst the benefits is that the fields do not get overwritten by
wrong or bogus on-disk disklabels.
Once that is clear, <sys/disk.h> which is included in the drivers
no longer need to pull <sys/disklabel.h> and <sys/diskslice.h> in,
the few places that needs them, have gotten explicit #includes for
them.
The disklabel inside struct disk is now only for internal use in
the disk mini-layer, so instead of embedding it, we malloc it as
we need it.
This concludes (modulus any mistakes) the series of disklabel related
commits.
I belive it all amounts to a NOP for all the rest of you :-)
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/dev/ata')
-rw-r--r-- | sys/dev/ata/ata-disk.c | 12 | ||||
-rw-r--r-- | sys/dev/ata/ata-raid.c | 13 | ||||
-rw-r--r-- | sys/dev/ata/atapi-fd.c | 14 |
3 files changed, 14 insertions, 25 deletions
diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index b4a8656..f8bae5e 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -208,14 +208,10 @@ ad_attach(struct ata_device *atadev) dev->si_iosize_max = adp->max_iosize; adp->dev = dev; - /* construct the disklabel */ - bzero(&adp->disk.d_label, sizeof(struct disklabel)); - adp->disk.d_label.d_secsize = DEV_BSIZE; - adp->disk.d_label.d_nsectors = adp->sectors; - adp->disk.d_label.d_ntracks = adp->heads; - adp->disk.d_label.d_ncylinders = adp->total_secs/(adp->heads*adp->sectors); - adp->disk.d_label.d_secpercyl = adp->sectors * adp->heads; - adp->disk.d_label.d_secperunit = adp->total_secs; + adp->disk.d_sectorsize = DEV_BSIZE; + adp->disk.d_mediasize = DEV_BSIZE * (off_t)adp->total_secs; + adp->disk.d_fwsectors = adp->sectors; + adp->disk.d_fwheads = adp->heads; atadev->driver = adp; atadev->flags = 0; diff --git a/sys/dev/ata/ata-raid.c b/sys/dev/ata/ata-raid.c index b209c1d..ec920e0 100644 --- a/sys/dev/ata/ata-raid.c +++ b/sys/dev/ata/ata-raid.c @@ -470,16 +470,11 @@ static int aropen(dev_t dev, int flags, int fmt, struct thread *td) { struct ar_softc *rdp = dev->si_drv1; - struct disklabel *dl; - dl = &rdp->disk.d_label; - bzero(dl, sizeof *dl); - dl->d_secsize = DEV_BSIZE; - dl->d_nsectors = rdp->sectors; - dl->d_ntracks = rdp->heads; - dl->d_ncylinders = rdp->cylinders; - dl->d_secpercyl = rdp->sectors * rdp->heads; - dl->d_secperunit = rdp->total_sectors; + rdp->disk.d_sectorsize = DEV_BSIZE; + rdp->disk.d_mediasize = (off_t)rdp->total_sectors * DEV_BSIZE; + rdp->disk.d_fwsectors = rdp->sectors; + rdp->disk.d_fwheads = rdp->heads; return 0; } diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index a8a53ab..e5f887a 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -224,7 +224,6 @@ static int afdopen(dev_t dev, int flags, int fmt, struct thread *td) { struct afd_softc *fdp = dev->si_drv1; - struct disklabel *label = &fdp->disk.d_label; atapi_test_ready(fdp->device); @@ -236,13 +235,12 @@ afdopen(dev_t dev, int flags, int fmt, struct thread *td) fdp->device->flags &= ~ATA_D_MEDIA_CHANGED; - bzero(label, sizeof *label); - label->d_secsize = fdp->cap.sector_size; - label->d_nsectors = fdp->cap.sectors; - label->d_ntracks = fdp->cap.heads; - label->d_ncylinders = fdp->cap.cylinders; - label->d_secpercyl = fdp->cap.sectors * fdp->cap.heads; - label->d_secperunit = label->d_secpercyl * fdp->cap.cylinders; + fdp->disk.d_sectorsize = fdp->cap.sector_size; + fdp->disk.d_mediasize = (off_t)fdp->cap.sector_size * fdp->cap.sectors * + fdp->cap.heads * fdp->cap.cylinders; + fdp->disk.d_fwsectors = fdp->cap.sectors; + fdp->disk.d_fwheads = fdp->cap.heads; + return 0; } |