summaryrefslogtreecommitdiffstats
path: root/sys/dev/amr
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-02-18 21:36:53 +0000
committerphk <phk@FreeBSD.org>2004-02-18 21:36:53 +0000
commit49c92e5706ab055d53ea35d401f4310fc07ff74a (patch)
tree16cf67c25fa19d01be97b31241d2c56e85a88674 /sys/dev/amr
parent7ca155be2a4009e2ad701b61538e8376c49a7403 (diff)
downloadFreeBSD-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/amr')
-rw-r--r--sys/dev/amr/amr_disk.c29
-rw-r--r--sys/dev/amr/amrvar.h2
2 files changed, 17 insertions, 14 deletions
diff --git a/sys/dev/amr/amr_disk.c b/sys/dev/amr/amr_disk.c
index 42d09a2..a93e1ed 100644
--- a/sys/dev/amr/amr_disk.c
+++ b/sys/dev/amr/amr_disk.c
@@ -134,10 +134,10 @@ amrd_open(struct disk *dp)
label->d_secpercyl = sc->amrd_drive->al_sectors * sc->amrd_drive->al_heads;
label->d_secperunit = sc->amrd_drive->al_size;
#else
- sc->amrd_disk.d_sectorsize = AMR_BLKSIZE;
- sc->amrd_disk.d_mediasize = (off_t)sc->amrd_drive->al_size * AMR_BLKSIZE;
- sc->amrd_disk.d_fwsectors = sc->amrd_drive->al_sectors;
- sc->amrd_disk.d_fwheads = sc->amrd_drive->al_heads;
+ sc->amrd_disk->d_sectorsize = AMR_BLKSIZE;
+ sc->amrd_disk->d_mediasize = (off_t)sc->amrd_drive->al_size * AMR_BLKSIZE;
+ sc->amrd_disk->d_fwsectors = sc->amrd_drive->al_sectors;
+ sc->amrd_disk->d_fwheads = sc->amrd_drive->al_heads;
#endif
return (0);
@@ -247,13 +247,16 @@ amrd_attach(device_t dev)
sc->amrd_drive->al_size, sc->amrd_drive->al_properties & AMR_DRV_RAID_MASK,
amr_describe_code(amr_table_drvstate, AMR_DRV_CURSTATE(sc->amrd_drive->al_state)));
- sc->amrd_disk.d_drv1 = sc;
- sc->amrd_disk.d_maxsize = (AMR_NSEG - 1) * PAGE_SIZE;
- sc->amrd_disk.d_open = amrd_open;
- sc->amrd_disk.d_strategy = amrd_strategy;
- sc->amrd_disk.d_name = "amrd";
- sc->amrd_disk.d_dump = (dumper_t *)amrd_dump;
- disk_create(sc->amrd_unit, &sc->amrd_disk, 0, NULL, NULL);
+ sc->amrd_disk = disk_alloc();
+ sc->amrd_disk->d_drv1 = sc;
+ sc->amrd_disk->d_maxsize = (AMR_NSEG - 1) * PAGE_SIZE;
+ sc->amrd_disk->d_open = amrd_open;
+ sc->amrd_disk->d_strategy = amrd_strategy;
+ sc->amrd_disk->d_name = "amrd";
+ sc->amrd_disk->d_dump = (dumper_t *)amrd_dump;
+ sc->amrd_disk->d_unit = sc->amrd_unit;
+ sc->amrd_disk->d_flags = DISKFLAG_NEEDSGIANT;
+ disk_create(sc->amrd_disk, DISK_VERSION);
#ifdef FREEBSD_4
disks_registered++;
#endif
@@ -268,14 +271,14 @@ amrd_detach(device_t dev)
debug_called(1);
- if (sc->amrd_disk.d_flags & DISKFLAG_OPEN)
+ if (sc->amrd_disk->d_flags & DISKFLAG_OPEN)
return(EBUSY);
#ifdef FREEBSD_4
if (--disks_registered == 0)
cdevsw_remove(&amrddisk_cdevsw);
#else
- disk_destroy(&sc->amrd_disk);
+ disk_destroy(sc->amrd_disk);
#endif
return(0);
}
diff --git a/sys/dev/amr/amrvar.h b/sys/dev/amr/amrvar.h
index 1191954..2378c97 100644
--- a/sys/dev/amr/amrvar.h
+++ b/sys/dev/amr/amrvar.h
@@ -253,7 +253,7 @@ struct amrd_softc
device_t amrd_dev;
struct amr_softc *amrd_controller;
struct amr_logdrive *amrd_drive;
- struct disk amrd_disk;
+ struct disk *amrd_disk;
int amrd_unit;
};
OpenPOWER on IntegriCloud