summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-09-20 19:36:05 +0000
committerphk <phk@FreeBSD.org>2002-09-20 19:36:05 +0000
commit57a346a21312d7f99ca28aee15ab6091be10cbd7 (patch)
tree47b5afae3623c1371d19a0478c850d8e6a08d07b /sys/dev
parent2fb7a39c0fdc17568c3b60cf37e5f3c2d6dff5e4 (diff)
downloadFreeBSD-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')
-rw-r--r--sys/dev/aac/aac_disk.c15
-rw-r--r--sys/dev/amr/amr_disk.c14
-rw-r--r--sys/dev/ata/ata-disk.c12
-rw-r--r--sys/dev/ata/ata-raid.c13
-rw-r--r--sys/dev/ata/atapi-fd.c14
-rw-r--r--sys/dev/ccd/ccd.c1
-rw-r--r--sys/dev/ida/ida_disk.c14
-rw-r--r--sys/dev/md/md.c15
-rw-r--r--sys/dev/mlx/mlx_disk.c14
-rw-r--r--sys/dev/ofw/ofw_disk.c18
-rw-r--r--sys/dev/pst/pst-raid.c13
-rw-r--r--sys/dev/twe/twe_freebsd.c16
12 files changed, 49 insertions, 110 deletions
diff --git a/sys/dev/aac/aac_disk.c b/sys/dev/aac/aac_disk.c
index 91ceee0..68692aa 100644
--- a/sys/dev/aac/aac_disk.c
+++ b/sys/dev/aac/aac_disk.c
@@ -130,7 +130,6 @@ static int
aac_disk_open(dev_t dev, int flags, int fmt, d_thread_t *td)
{
struct aac_disk *sc;
- struct disklabel *label;
debug_called(4);
@@ -143,16 +142,10 @@ aac_disk_open(dev_t dev, int flags, int fmt, d_thread_t *td)
if (sc->ad_controller->aac_state & AAC_STATE_SUSPEND)
return(ENXIO);
- /* build synthetic label */
- label = &sc->ad_disk.d_label;
- bzero(label, sizeof(*label));
- label->d_type = DTYPE_ESDI;
- label->d_secsize = AAC_BLOCK_SIZE;
- label->d_nsectors = sc->ad_sectors;
- label->d_ntracks = sc->ad_heads;
- label->d_ncylinders = sc->ad_cylinders;
- label->d_secpercyl = sc->ad_sectors * sc->ad_heads;
- label->d_secperunit = sc->ad_size;
+ sc->ad_disk.d_sectorsize = AAC_BLOCK_SIZE;
+ sc->ad_disk.d_mediasize = (off_t)sc->ad_size * AAC_BLOCK_SIZE;
+ sc->ad_disk.d_fwsectors = sc->ad_sectors;
+ sc->ad_disk.d_fwheads = sc->ad_heads;
sc->ad_flags |= AAC_DISK_OPEN;
return (0);
diff --git a/sys/dev/amr/amr_disk.c b/sys/dev/amr/amr_disk.c
index 38784d3..e486e87 100644
--- a/sys/dev/amr/amr_disk.c
+++ b/sys/dev/amr/amr_disk.c
@@ -103,7 +103,6 @@ static int
amrd_open(dev_t dev, int flags, int fmt, struct thread *td)
{
struct amrd_softc *sc = (struct amrd_softc *)dev->si_drv1;
- struct disklabel *label;
debug_called(1);
@@ -114,15 +113,10 @@ amrd_open(dev_t dev, int flags, int fmt, struct thread *td)
if (sc->amrd_controller->amr_state & AMR_STATE_SHUTDOWN)
return(ENXIO);
- label = &sc->amrd_disk.d_label;
- bzero(label, sizeof(*label));
- label->d_type = DTYPE_SCSI;
- label->d_secsize = AMR_BLKSIZE;
- label->d_nsectors = sc->amrd_drive->al_sectors;
- label->d_ntracks = sc->amrd_drive->al_heads;
- label->d_ncylinders = sc->amrd_drive->al_cylinders;
- label->d_secpercyl = sc->amrd_drive->al_sectors * sc->amrd_drive->al_heads;
- label->d_secperunit = sc->amrd_drive->al_size;
+ sc->amrd_disk.d_sectorsize = AMR_BLKSIZE;
+ sc->amrd_disk.d_mediasize = (off_t)sc->amrd_drive->al_size * AMR_BLKSIZE;
+ sc->amrd_disk.d_fwsectors = sc->amrd_drive->al_sectors;
+ sc->amrd_disk.d_fwheads = sc->amrd_drive->al_heads;
sc->amrd_flags |= AMRD_OPEN;
return (0);
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;
}
diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c
index b4387d9..d8e01be 100644
--- a/sys/dev/ccd/ccd.c
+++ b/sys/dev/ccd/ccd.c
@@ -100,6 +100,7 @@
#include <sys/stdint.h>
#include <sys/sysctl.h>
#include <sys/disk.h>
+#include <sys/disklabel.h>
#include <sys/devicestat.h>
#include <sys/fcntl.h>
#include <sys/vnode.h>
diff --git a/sys/dev/ida/ida_disk.c b/sys/dev/ida/ida_disk.c
index 256b5aa..33f87c5 100644
--- a/sys/dev/ida/ida_disk.c
+++ b/sys/dev/ida/ida_disk.c
@@ -111,21 +111,15 @@ static int
idad_open(dev_t dev, int flags, int fmt, struct thread *td)
{
struct idad_softc *drv;
- struct disklabel *label;
drv = idad_getsoftc(dev);
if (drv == NULL)
return (ENXIO);
- label = &drv->disk.d_label;
- bzero(label, sizeof(*label));
- label->d_type = DTYPE_SCSI;
- label->d_secsize = drv->secsize;
- label->d_nsectors = drv->sectors;
- label->d_ntracks = drv->heads;
- label->d_ncylinders = drv->cylinders;
- label->d_secpercyl = drv->sectors * drv->heads;
- label->d_secperunit = drv->secperunit;
+ drv->disk.d_sectorsize = drv->secsize;
+ drv->disk.d_mediasize = (off_t)drv->secperunit * drv->secsize;
+ drv->disk.d_fwsectors = drv->sectors;
+ drv->disk.d_fwheads = drv->heads;
return (0);
}
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 7640604..032c5fe 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -360,7 +360,6 @@ static int
mdopen(dev_t dev, int flag, int fmt, struct thread *td)
{
struct md_s *sc;
- struct disklabel *dl;
if (md_debug)
printf("mdopen(%s %x %x %p)\n",
@@ -368,14 +367,10 @@ mdopen(dev_t dev, int flag, int fmt, struct thread *td)
sc = dev->si_drv1;
- dl = &sc->disk.d_label;
- bzero(dl, sizeof(*dl));
- dl->d_secsize = sc->secsize;
- dl->d_nsectors = sc->nsect > 63 ? 63 : sc->nsect;
- dl->d_ntracks = 1;
- dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks;
- dl->d_secperunit = sc->nsect;
- dl->d_ncylinders = dl->d_secperunit / dl->d_secpercyl;
+ sc->disk.d_sectorsize = sc->secsize;
+ sc->disk.d_mediasize = (off_t)sc->nsect * sc->secsize;
+ sc->disk.d_fwsectors = 0;
+ sc->disk.d_fwheads = 0;
sc->opencount++;
return (0);
}
@@ -646,7 +641,7 @@ mdnew(int unit)
}
if (unit == -1)
unit = max + 1;
- if (unit > DKMAXUNIT)
+ if (unit > 255)
return (NULL);
sc = (struct md_s *)malloc(sizeof *sc, M_MD, M_WAITOK | M_ZERO);
sc->unit = unit;
diff --git a/sys/dev/mlx/mlx_disk.c b/sys/dev/mlx/mlx_disk.c
index 49005b1..a5ff92d 100644
--- a/sys/dev/mlx/mlx_disk.c
+++ b/sys/dev/mlx/mlx_disk.c
@@ -98,7 +98,6 @@ static int
mlxd_open(dev_t dev, int flags, int fmt, struct thread *td)
{
struct mlxd_softc *sc = (struct mlxd_softc *)dev->si_drv1;
- struct disklabel *label;
debug_called(1);
@@ -109,15 +108,10 @@ mlxd_open(dev_t dev, int flags, int fmt, struct thread *td)
if (sc->mlxd_controller->mlx_state & MLX_STATE_SHUTDOWN)
return(ENXIO);
- label = &sc->mlxd_disk.d_label;
- bzero(label, sizeof(*label));
- label->d_type = DTYPE_SCSI;
- label->d_secsize = MLX_BLKSIZE;
- label->d_nsectors = sc->mlxd_drive->ms_sectors;
- label->d_ntracks = sc->mlxd_drive->ms_heads;
- label->d_ncylinders = sc->mlxd_drive->ms_cylinders;
- label->d_secpercyl = sc->mlxd_drive->ms_sectors * sc->mlxd_drive->ms_heads;
- label->d_secperunit = sc->mlxd_drive->ms_size;
+ sc->mlxd_disk.d_sectorsize = MLX_BLKSIZE;
+ sc->mlxd_disk.d_mediasize = MLX_BLKSIZE * (off_t)sc->mlxd_drive->ms_size;
+ sc->mlxd_disk.d_fwsectors = sc->mlxd_drive->ms_sectors;
+ sc->mlxd_disk.d_fwheads = sc->mlxd_drive->ms_heads;
sc->mlxd_flags |= MLXD_OPEN;
return (0);
diff --git a/sys/dev/ofw/ofw_disk.c b/sys/dev/ofw/ofw_disk.c
index 878e8e8..8262e0f 100644
--- a/sys/dev/ofw/ofw_disk.c
+++ b/sys/dev/ofw/ofw_disk.c
@@ -114,24 +114,16 @@ static int
ofwd_open(dev_t dev, int flags, int fmt, struct thread *td)
{
struct ofwd_softc *sc;
- struct disklabel *label;
sc = (struct ofwd_softc *)dev->si_drv1;
if (sc == NULL)
return (ENXIO);
- /*
- * Build synthetic label.
- */
- label = &sc->ofwd_disk.d_label;
- bzero(label, sizeof(*label));
- label->d_type = DTYPE_ESDI;
- label->d_secsize = OFWD_BLOCKSIZE;
- label->d_nsectors = 33554432;
- label->d_ntracks = 1;
- label->d_ncylinders = 1024;
- label->d_secpercyl = 32768;
- label->d_secperunit = 33554432;
+ sc->ofwd_disk.d_sectorsize = OFWD_BLOCKSIZE;
+ sc->ofwd_disk.d_mediasize = (off_t)33554432 * OFWD_BLOCKSIZE;
+ /* XXX: probably don't need the next two */
+ sc->ofwd_disk.d_fwsectors = 33554432;
+ sc->ofwd_disk.d_fwheads = 1
sc->ofwd_flags |= OFWD_OPEN;
return (0);
diff --git a/sys/dev/pst/pst-raid.c b/sys/dev/pst/pst-raid.c
index 2382576..db120b0 100644
--- a/sys/dev/pst/pst-raid.c
+++ b/sys/dev/pst/pst-raid.c
@@ -172,15 +172,10 @@ pst_attach(device_t dev)
psc->device->si_drv1 = psc;
psc->device->si_iosize_max = 64 * 1024; /*I2O_SGL_MAX_SEGS * PAGE_SIZE;*/
- bzero(&psc->disk.d_label, sizeof(struct disklabel));
- psc->disk.d_label.d_secsize = psc->info->block_size;
- psc->disk.d_label.d_nsectors = 63;
- psc->disk.d_label.d_ntracks = 255;
- psc->disk.d_label.d_ncylinders =
- (psc->info->capacity / psc->info->block_size) / (255 * 63);
- psc->disk.d_label.d_secpercyl = 255 * 63;
- psc->disk.d_label.d_secperunit =
- psc->info->capacity / psc->info->block_size;
+ psc->disk.d_sectorsize = psc->info->block_size;
+ psc->disk.d_mediasize = psc->info->capacity;
+ psc->disk.d_fssectors = 63;
+ psc->disk.d_fsheads = 255;
devstat_add_entry(&psc->stats, "pst", lun, psc->info->block_size,
DEVSTAT_NO_ORDERED_TAGS,
diff --git a/sys/dev/twe/twe_freebsd.c b/sys/dev/twe/twe_freebsd.c
index df194a4..5187c25 100644
--- a/sys/dev/twe/twe_freebsd.c
+++ b/sys/dev/twe/twe_freebsd.c
@@ -549,7 +549,6 @@ struct twed_softc
struct twe_drive *twed_drive; /* drive data in parent softc */
struct disk twed_disk; /* generic disk handle */
struct devstat twed_stats; /* accounting */
- struct disklabel twed_label; /* synthetic label */
int twed_flags;
#define TWED_OPEN (1<<0) /* drive is open (can't shut down) */
};
@@ -622,7 +621,6 @@ static int
twed_open(dev_t dev, int flags, int fmt, d_thread_t *td)
{
struct twed_softc *sc = (struct twed_softc *)dev->si_drv1;
- struct disklabel *label;
debug_called(4);
@@ -633,16 +631,10 @@ twed_open(dev_t dev, int flags, int fmt, d_thread_t *td)
if (sc->twed_controller->twe_state & TWE_STATE_SHUTDOWN)
return(ENXIO);
- /* build synthetic label */
- label = &sc->twed_disk.d_label;
- bzero(label, sizeof(*label));
- label->d_type = DTYPE_ESDI;
- label->d_secsize = TWE_BLOCK_SIZE;
- label->d_nsectors = sc->twed_drive->td_sectors;
- label->d_ntracks = sc->twed_drive->td_heads;
- label->d_ncylinders = sc->twed_drive->td_cylinders;
- label->d_secpercyl = sc->twed_drive->td_sectors * sc->twed_drive->td_heads;
- label->d_secperunit = sc->twed_drive->td_size;
+ sc->twed_disk.d_sectorsize = TWE_BLOCK_SIZE;
+ sc->twed_disk.d_mediasize = TWE_BLOCK_SIZE * (off_t)sc->twed_drive->td_size;
+ sc->twed_disk.d_fwsectors = sc->twed_drive->td_sectors;
+ sc->twed_disk.d_fwheads = sc->twed_drive->td_heads;
sc->twed_flags |= TWED_OPEN;
return (0);
OpenPOWER on IntegriCloud