aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ips
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2004-02-18 21:36:53 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2004-02-18 21:36:53 +0000
commit0b7ed341e106c1583e873116529015d2ae042fd0 (patch)
tree16cf67c25fa19d01be97b31241d2c56e85a88674 /sys/dev/ips
parentf63503fcbb7a5b0e118435058a2d2c56f1083252 (diff)
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.
Notes
svn path=/head/; revision=125975
Diffstat (limited to 'sys/dev/ips')
-rw-r--r--sys/dev/ips/ips_disk.c31
-rw-r--r--sys/dev/ips/ips_disk.h2
2 files changed, 18 insertions, 15 deletions
diff --git a/sys/dev/ips/ips_disk.c b/sys/dev/ips/ips_disk.c
index cde0545f4f67..f20a8f8f40c8 100644
--- a/sys/dev/ips/ips_disk.c
+++ b/sys/dev/ips/ips_disk.c
@@ -122,25 +122,28 @@ static int ipsd_attach(device_t dev)
dsc->sc = device_get_softc(adapter);
dsc->unit = device_get_unit(dev);
dsc->disk_number = (uintptr_t) device_get_ivars(dev);
- dsc->ipsd_disk.d_drv1 = dsc;
- dsc->ipsd_disk.d_name = "ipsd";
- dsc->ipsd_disk.d_maxsize = IPS_MAX_IO_SIZE;
- dsc->ipsd_disk.d_open = ipsd_open;
- dsc->ipsd_disk.d_close = ipsd_close;
- dsc->ipsd_disk.d_strategy = ipsd_strategy;
+ dsc->ipsd_disk = disk_alloc();
+ dsc->ipsd_disk->d_drv1 = dsc;
+ dsc->ipsd_disk->d_name = "ipsd";
+ dsc->ipsd_disk->d_maxsize = IPS_MAX_IO_SIZE;
+ dsc->ipsd_disk->d_open = ipsd_open;
+ dsc->ipsd_disk->d_close = ipsd_close;
+ dsc->ipsd_disk->d_strategy = ipsd_strategy;
totalsectors = dsc->sc->drives[dsc->disk_number].sector_count;
if ((totalsectors > 0x400000) &&
((dsc->sc->adapter_info.miscflags & 0x8) == 0)) {
- dsc->ipsd_disk.d_fwheads = IPS_NORM_HEADS;
- dsc->ipsd_disk.d_fwsectors = IPS_NORM_SECTORS;
+ dsc->ipsd_disk->d_fwheads = IPS_NORM_HEADS;
+ dsc->ipsd_disk->d_fwsectors = IPS_NORM_SECTORS;
} else {
- dsc->ipsd_disk.d_fwheads = IPS_COMP_HEADS;
- dsc->ipsd_disk.d_fwsectors = IPS_COMP_SECTORS;
+ dsc->ipsd_disk->d_fwheads = IPS_COMP_HEADS;
+ dsc->ipsd_disk->d_fwsectors = IPS_COMP_SECTORS;
}
- dsc->ipsd_disk.d_sectorsize = IPS_BLKSIZE;
- dsc->ipsd_disk.d_mediasize = (off_t)totalsectors * IPS_BLKSIZE;
- disk_create(dsc->unit, &dsc->ipsd_disk, 0, NULL, NULL);
+ dsc->ipsd_disk->d_sectorsize = IPS_BLKSIZE;
+ dsc->ipsd_disk->d_mediasize = (off_t)totalsectors * IPS_BLKSIZE;
+ dsc->ipsd_disk->d_unit = dsc->unit;
+ dsc->ipsd_disk->d_flags = DISKFLAG_NEEDSGIANT;
+ disk_create(dsc->ipsd_disk, DISK_VERSION);
device_printf(dev, "Logical Drive (%dMB)\n",
dsc->sc->drives[dsc->disk_number].sector_count >> 11);
@@ -155,7 +158,7 @@ static int ipsd_detach(device_t dev)
dsc = (ipsdisk_softc_t *)device_get_softc(dev);
if(dsc->state & IPS_DEV_OPEN)
return (EBUSY);
- disk_destroy(&dsc->ipsd_disk);
+ disk_destroy(dsc->ipsd_disk);
return 0;
}
diff --git a/sys/dev/ips/ips_disk.h b/sys/dev/ips/ips_disk.h
index 9bc67260b661..0b0fe65d4030 100644
--- a/sys/dev/ips/ips_disk.h
+++ b/sys/dev/ips/ips_disk.h
@@ -61,6 +61,6 @@ typedef struct ipsdisk_softc {
int unit;
int disk_number;
u_int32_t state;
- struct disk ipsd_disk;
+ struct disk *ipsd_disk;
ips_softc_t *sc;
}ipsdisk_softc_t;