diff options
author | phk <phk@FreeBSD.org> | 2004-02-18 21:36:53 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-02-18 21:36:53 +0000 |
commit | 49c92e5706ab055d53ea35d401f4310fc07ff74a (patch) | |
tree | 16cf67c25fa19d01be97b31241d2c56e85a88674 /sys/dev/ida | |
parent | 7ca155be2a4009e2ad701b61538e8376c49a7403 (diff) | |
download | FreeBSD-src-49c92e5706ab055d53ea35d401f4310fc07ff74a.zip FreeBSD-src-49c92e5706ab055d53ea35d401f4310fc07ff74a.tar.gz |
Change the disk(9) API in order to make device removal more robust.
Previously the "struct disk" were owned by the device driver and this
gave us problems when the device disappared and the users of that device
were not immediately disappearing.
Now the struct disk is allocate with a new call, disk_alloc() and owned
by geom_disk and just abandonned by the device driver when disk_create()
is called.
Unfortunately, this results in a ton of "s/\./->/" changes to device
drivers.
Since I'm doing the sweep anyway, a couple of other API improvements
have been carried out at the same time:
The Giant awareness flag has been flipped from DISKFLAG_NOGIANT to
DISKFLAG_NEEDSGIANT
A version number have been added to disk_create() so that we can detect,
report and ignore binary drivers with old ABI in the future.
Manual page update to follow shortly.
Diffstat (limited to 'sys/dev/ida')
-rw-r--r-- | sys/dev/ida/ida_disk.c | 25 | ||||
-rw-r--r-- | sys/dev/ida/idavar.h | 2 |
2 files changed, 15 insertions, 12 deletions
diff --git a/sys/dev/ida/ida_disk.c b/sys/dev/ida/ida_disk.c index f554bac..31769e7 100644 --- a/sys/dev/ida/ida_disk.c +++ b/sys/dev/ida/ida_disk.c @@ -203,16 +203,19 @@ idad_attach(device_t dev) drv->secperunit / ((1024 * 1024) / drv->secsize), drv->secperunit, drv->secsize); - drv->disk.d_strategy = idad_strategy; - drv->disk.d_name = "idad"; - drv->disk.d_dump = idad_dump; - 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; - drv->disk.d_drv1 = drv; - drv->disk.d_maxsize = DFLTPHYS; /* XXX guess? */ - disk_create(drv->unit, &drv->disk, 0, NULL, NULL); + drv->disk = disk_alloc(); + drv->disk->d_strategy = idad_strategy; + drv->disk->d_name = "idad"; + drv->disk->d_dump = idad_dump; + 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; + drv->disk->d_drv1 = drv; + drv->disk->d_maxsize = DFLTPHYS; /* XXX guess? */ + drv->disk->d_unit = drv->unit; + drv->disk->d_flags = DISKFLAG_NEEDSGIANT; + disk_create(drv->disk, DISK_VERSION); return (0); } @@ -223,6 +226,6 @@ idad_detach(device_t dev) struct idad_softc *drv; drv = (struct idad_softc *)device_get_softc(dev); - disk_destroy(&drv->disk); + disk_destroy(drv->disk); return (0); } diff --git a/sys/dev/ida/idavar.h b/sys/dev/ida/idavar.h index 9898b23..78993cb 100644 --- a/sys/dev/ida/idavar.h +++ b/sys/dev/ida/idavar.h @@ -170,7 +170,7 @@ struct ida_softc { struct idad_softc { device_t dev; struct ida_softc *controller; - struct disk disk; + struct disk *disk; int drive; /* per controller */ int unit; /* global */ int cylinders; |