summaryrefslogtreecommitdiffstats
path: root/sys/dev/mlx
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/mlx
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/mlx')
-rw-r--r--sys/dev/mlx/mlx_disk.c31
-rw-r--r--sys/dev/mlx/mlxvar.h2
2 files changed, 18 insertions, 15 deletions
diff --git a/sys/dev/mlx/mlx_disk.c b/sys/dev/mlx/mlx_disk.c
index bd86466..2ad0bc6 100644
--- a/sys/dev/mlx/mlx_disk.c
+++ b/sys/dev/mlx/mlx_disk.c
@@ -219,30 +219,33 @@ mlxd_attach(device_t dev)
sc->mlxd_drive->ms_size / ((1024 * 1024) / MLX_BLKSIZE),
sc->mlxd_drive->ms_size, sc->mlxd_drive->ms_raidlevel, state);
- sc->mlxd_disk.d_open = mlxd_open;
- sc->mlxd_disk.d_close = mlxd_close;
- sc->mlxd_disk.d_ioctl = mlxd_ioctl;
- sc->mlxd_disk.d_strategy = mlxd_strategy;
- sc->mlxd_disk.d_name = "mlxd";
- sc->mlxd_disk.d_drv1 = sc;
- sc->mlxd_disk.d_sectorsize = MLX_BLKSIZE;
- sc->mlxd_disk.d_mediasize = MLX_BLKSIZE * (off_t)sc->mlxd_drive->ms_size;
- sc->mlxd_disk.d_fwsectors = sc->mlxd_drive->ms_sectors;
- sc->mlxd_disk.d_fwheads = sc->mlxd_drive->ms_heads;
+ sc->mlxd_disk = disk_alloc();
+ sc->mlxd_disk->d_open = mlxd_open;
+ sc->mlxd_disk->d_close = mlxd_close;
+ sc->mlxd_disk->d_ioctl = mlxd_ioctl;
+ sc->mlxd_disk->d_strategy = mlxd_strategy;
+ sc->mlxd_disk->d_name = "mlxd";
+ sc->mlxd_disk->d_unit = sc->mlxd_unit;
+ sc->mlxd_disk->d_drv1 = sc;
+ sc->mlxd_disk->d_sectorsize = MLX_BLKSIZE;
+ sc->mlxd_disk->d_mediasize = MLX_BLKSIZE * (off_t)sc->mlxd_drive->ms_size;
+ sc->mlxd_disk->d_fwsectors = sc->mlxd_drive->ms_sectors;
+ sc->mlxd_disk->d_fwheads = sc->mlxd_drive->ms_heads;
+ sc->mlxd_disk->d_flags = DISKFLAG_NEEDSGIANT;
/*
* Set maximum I/O size to the lesser of the recommended maximum and the practical
* maximum except on v2 cards where the maximum is set to 8 pages.
*/
if (sc->mlxd_controller->mlx_iftype == MLX_IFTYPE_2)
- sc->mlxd_disk.d_maxsize = 8 * PAGE_SIZE;
+ sc->mlxd_disk->d_maxsize = 8 * PAGE_SIZE;
else {
s1 = sc->mlxd_controller->mlx_enq2->me_maxblk * MLX_BLKSIZE;
s2 = (sc->mlxd_controller->mlx_enq2->me_max_sg - 1) * PAGE_SIZE;
- sc->mlxd_disk.d_maxsize = imin(s1, s2);
+ sc->mlxd_disk->d_maxsize = imin(s1, s2);
}
- disk_create(sc->mlxd_unit, &sc->mlxd_disk, 0, NULL, NULL);
+ disk_create(sc->mlxd_disk, DISK_VERSION);
return (0);
}
@@ -254,7 +257,7 @@ mlxd_detach(device_t dev)
debug_called(1);
- disk_destroy(&sc->mlxd_disk);
+ disk_destroy(sc->mlxd_disk);
return(0);
}
diff --git a/sys/dev/mlx/mlxvar.h b/sys/dev/mlx/mlxvar.h
index 43cbcb1..e499569 100644
--- a/sys/dev/mlx/mlxvar.h
+++ b/sys/dev/mlx/mlxvar.h
@@ -228,7 +228,7 @@ struct mlxd_softc
device_t mlxd_dev;
struct mlx_softc *mlxd_controller;
struct mlx_sysdrive *mlxd_drive;
- struct disk mlxd_disk;
+ struct disk *mlxd_disk;
int mlxd_unit;
int mlxd_flags;
#define MLXD_OPEN (1<<0) /* drive is open (can't shut down) */
OpenPOWER on IntegriCloud