summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_disk.c
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/kern/subr_disk.c
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/kern/subr_disk.c')
-rw-r--r--sys/kern/subr_disk.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 388ea79..6408250 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -18,6 +18,8 @@
#include <sys/bio.h>
#include <sys/conf.h>
#include <sys/disk.h>
+#include <sys/diskslice.h>
+#include <sys/disklabel.h>
#ifndef GEOM
#include <sys/kernel.h>
#include <sys/sysctl.h>
@@ -175,6 +177,7 @@ disk_create(int unit, struct disk *dp, int flags, struct cdevsw *cdevsw, struct
}
bzero(dp, sizeof(*dp));
+ dp->d_label = malloc(sizeof *dp->d_label, M_DEVBUF, M_WAITOK|M_ZERO);
if (proto->d_open != diskopen) {
*proto = *cdevsw;
@@ -232,6 +235,7 @@ void
disk_destroy(dev_t dev)
{
LIST_REMOVE(dev->si_disk, d_list);
+ free(dev->si_disk->d_label, M_DEVBUF);
bzero(dev->si_disk, sizeof(*dev->si_disk));
dev->si_disk = NULL;
destroy_dev(dev);
@@ -305,6 +309,8 @@ diskopen(dev_t dev, int oflags, int devtype, struct thread *td)
if (!pdev->si_iosize_max)
pdev->si_iosize_max = dev->si_iosize_max;
error = dp->d_devsw->d_open(pdev, oflags, devtype, td);
+ dp->d_label->d_secsize = dp->d_sectorsize;
+ dp->d_label->d_secperunit = dp->d_mediasize / dp->d_sectorsize;
}
/* Inherit properties from the whole/raw dev_t */
@@ -313,7 +319,7 @@ diskopen(dev_t dev, int oflags, int devtype, struct thread *td)
if (error)
goto out;
- error = dsopen(dev, devtype, dp->d_dsflags, &dp->d_slice, &dp->d_label);
+ error = dsopen(dev, devtype, dp->d_dsflags, &dp->d_slice, dp->d_label);
if (!dsisopen(dp->d_slice))
dp->d_devsw->d_close(pdev, oflags, devtype, td);
OpenPOWER on IntegriCloud