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/twe | |
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/twe')
-rw-r--r-- | sys/dev/twe/twe_freebsd.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/sys/dev/twe/twe_freebsd.c b/sys/dev/twe/twe_freebsd.c index 34e4954..6f3f02b 100644 --- a/sys/dev/twe/twe_freebsd.c +++ b/sys/dev/twe/twe_freebsd.c @@ -640,7 +640,7 @@ struct twed_softc device_t twed_dev; struct twe_softc *twed_controller; /* parent device softc */ struct twe_drive *twed_drive; /* drive data in parent softc */ - struct disk twed_disk; /* generic disk handle */ + struct disk *twed_disk; /* generic disk handle */ }; /* @@ -805,19 +805,24 @@ twed_attach(device_t dev) /* attach a generic disk device to ourselves */ - sc->twed_disk.d_open = twed_open; - sc->twed_disk.d_strategy = twed_strategy; - sc->twed_disk.d_dump = (dumper_t *)twed_dump; - sc->twed_disk.d_name = "twed"; - sc->twed_disk.d_drv1 = sc; - sc->twed_disk.d_maxsize = (TWE_MAX_SGL_LENGTH - 1) * PAGE_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_drive->td_sys_unit = device_get_unit(dev); - disk_create(sc->twed_drive->td_sys_unit, &sc->twed_disk, 0, NULL, NULL); + sc->twed_disk = disk_alloc(); + sc->twed_disk->d_open = twed_open; + sc->twed_disk->d_strategy = twed_strategy; + sc->twed_disk->d_dump = (dumper_t *)twed_dump; + sc->twed_disk->d_name = "twed"; + sc->twed_disk->d_drv1 = sc; + sc->twed_disk->d_maxsize = (TWE_MAX_SGL_LENGTH - 1) * PAGE_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_disk->d_unit = sc->twed_drive->td_sys_unit; + sc->twed_disk->d_flags = DISKFLAG_NEEDSGIANT; + + disk_create(sc->twed_disk, DISK_VERSION); + #ifdef FREEBSD_4 disks_registered++; #endif @@ -837,10 +842,10 @@ twed_detach(device_t dev) debug_called(4); - if (sc->twed_disk.d_flags & DISKFLAG_OPEN) + if (sc->twed_disk->d_flags & DISKFLAG_OPEN) return(EBUSY); - disk_destroy(&sc->twed_disk); + disk_destroy(sc->twed_disk); #ifdef FREEBSD_4 if (--disks_registered == 0) |