aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/aac
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/aac
parentf63503fcbb7a5b0e118435058a2d2c56f1083252 (diff)
downloadsrc-0b7ed341e106c1583e873116529015d2ae042fd0.tar.gz
src-0b7ed341e106c1583e873116529015d2ae042fd0.zip
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
Notes: svn path=/head/; revision=125975
Diffstat (limited to 'sys/dev/aac')
-rw-r--r--sys/dev/aac/aac.c2
-rw-r--r--sys/dev/aac/aac_disk.c28
-rw-r--r--sys/dev/aac/aacvar.h2
3 files changed, 17 insertions, 15 deletions
diff --git a/sys/dev/aac/aac.c b/sys/dev/aac/aac.c
index 2fec4cf846ec..57017bbc2cd5 100644
--- a/sys/dev/aac/aac.c
+++ b/sys/dev/aac/aac.c
@@ -2875,7 +2875,7 @@ aac_query_disk(struct aac_softc *sc, caddr_t uptr)
query_disk.Lun = 0;
query_disk.UnMapped = 0;
sprintf(&query_disk.diskDeviceName[0], "%s%d",
- disk->ad_disk.d_name, disk->ad_disk.d_unit);
+ disk->ad_disk->d_name, disk->ad_disk->d_unit);
}
AAC_LOCK_RELEASE(&sc->aac_container_lock);
diff --git a/sys/dev/aac/aac_disk.c b/sys/dev/aac/aac_disk.c
index 382b64494861..2231a0e0d7c6 100644
--- a/sys/dev/aac/aac_disk.c
+++ b/sys/dev/aac/aac_disk.c
@@ -357,18 +357,20 @@ aac_disk_attach(device_t dev)
/* attach a generic disk device to ourselves */
sc->unit = device_get_unit(dev);
- sc->ad_disk.d_drv1 = sc;
- sc->ad_disk.d_name = "aacd";
- sc->ad_disk.d_maxsize = aac_iosize_max;
- sc->ad_disk.d_open = aac_disk_open;
- sc->ad_disk.d_close = aac_disk_close;
- sc->ad_disk.d_strategy = aac_disk_strategy;
- sc->ad_disk.d_dump = aac_disk_dump;
- sc->ad_disk.d_sectorsize = AAC_BLOCK_SIZE;
- sc->ad_disk.d_mediasize = (off_t)sc->ad_size * AAC_BLOCK_SIZE;
- sc->ad_disk.d_fwsectors = sc->ad_sectors;
- sc->ad_disk.d_fwheads = sc->ad_heads;
- disk_create(sc->unit, &sc->ad_disk, DISKFLAG_NOGIANT, NULL, NULL);
+ sc->ad_disk = disk_alloc();
+ sc->ad_disk->d_drv1 = sc;
+ sc->ad_disk->d_name = "aacd";
+ sc->ad_disk->d_maxsize = aac_iosize_max;
+ sc->ad_disk->d_open = aac_disk_open;
+ sc->ad_disk->d_close = aac_disk_close;
+ sc->ad_disk->d_strategy = aac_disk_strategy;
+ sc->ad_disk->d_dump = aac_disk_dump;
+ sc->ad_disk->d_sectorsize = AAC_BLOCK_SIZE;
+ sc->ad_disk->d_mediasize = (off_t)sc->ad_size * AAC_BLOCK_SIZE;
+ sc->ad_disk->d_fwsectors = sc->ad_sectors;
+ sc->ad_disk->d_fwheads = sc->ad_heads;
+ sc->ad_disk->d_unit = sc->unit;
+ disk_create(sc->ad_disk, DISK_VERSION);
return (0);
}
@@ -388,7 +390,7 @@ aac_disk_detach(device_t dev)
if (sc->ad_flags & AAC_DISK_OPEN)
return(EBUSY);
- disk_destroy(&sc->ad_disk);
+ disk_destroy(sc->ad_disk);
return(0);
}
diff --git a/sys/dev/aac/aacvar.h b/sys/dev/aac/aacvar.h
index f2ee0f3b1b44..a4b30c396746 100644
--- a/sys/dev/aac/aacvar.h
+++ b/sys/dev/aac/aacvar.h
@@ -125,7 +125,7 @@ struct aac_disk
device_t ad_dev;
struct aac_softc *ad_controller;
struct aac_container *ad_container;
- struct disk ad_disk;
+ struct disk *ad_disk;
int ad_flags;
#define AAC_DISK_OPEN (1<<0)
int ad_cylinders;