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/contrib/dev/fla/fla.c | |
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/contrib/dev/fla/fla.c')
-rw-r--r-- | sys/contrib/dev/fla/fla.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/sys/contrib/dev/fla/fla.c b/sys/contrib/dev/fla/fla.c index 789db78..845befc 100644 --- a/sys/contrib/dev/fla/fla.c +++ b/sys/contrib/dev/fla/fla.c @@ -78,7 +78,7 @@ static struct fla_s { unsigned nsect; struct doc2k_stat ds; struct bio_queue_head bio_queue; - struct disk disk; + struct disk *disk; dev_t dev; } softc[8]; @@ -99,10 +99,10 @@ flaopen(struct disk *dp) } error = doc2k_size(sc->unit, &spu, &ncyl, &nt, &ns); - sc->disk.d_sectorsize = DEV_BSIZE; - sc->disk.d_mediasize = (off_t)spu * DEV_BSIZE; - sc->disk.d_fwsectors = ns; - sc->disk.d_fwheads = nt; + sc->disk->d_sectorsize = DEV_BSIZE; + sc->disk->d_mediasize = (off_t)spu * DEV_BSIZE; + sc->disk->d_fwsectors = ns; + sc->disk->d_fwheads = nt; return (0); } @@ -255,14 +255,17 @@ flaattach (device_t dev) bioq_init(&sc->bio_queue); - sc->disk.d_open = flaopen; - sc->disk.d_close = flaclose; - sc->disk.d_strategy = flastrategy; - sc->disk.d_drv1 = sc; - sc->disk.d_name = "fla"; - sc->disk.d_maxsize = MAXPHYS; + sc->disk = disk_alloc(); + sc->disk->d_open = flaopen; + sc->disk->d_close = flaclose; + sc->disk->d_strategy = flastrategy; + sc->disk->d_drv1 = sc; + sc->disk->d_name = "fla"; + sc->disk->d_maxsize = MAXPHYS; sc->unit = unit; - disk_create(unit, &sc->disk, DISKFLAG_CANDELETE, NULL, NULL); + sc->disk->d_unit = unit; + sc->disk->d_flags = DISKFLAG_CANDELETE | DISKFLAG_NEEDSGIANT; + disk_create(sc->disk, DISK_VERSION); return (0); } |