summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-10-25 12:28:28 +0000
committerphk <phk@FreeBSD.org>2004-10-25 12:28:28 +0000
commitfc5bad60e31b8b7d21725afcdfab9248e186e63e (patch)
treebdfa3c5ec43e03279b38b02fdb188d630496b697
parent064b8877b84ec93ec3a85a6146366249ecb3e94e (diff)
downloadFreeBSD-src-fc5bad60e31b8b7d21725afcdfab9248e186e63e.zip
FreeBSD-src-fc5bad60e31b8b7d21725afcdfab9248e186e63e.tar.gz
Use unit number allocation functions for GEOM minor numbers.
-rw-r--r--sys/geom/geom_dev.c21
-rw-r--r--sys/geom/geom_int.h8
2 files changed, 18 insertions, 11 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c
index 4b92df3..fdf9732 100644
--- a/sys/geom/geom_dev.c
+++ b/sys/geom/geom_dev.c
@@ -67,20 +67,31 @@ static struct cdevsw g_dev_cdevsw = {
.d_ioctl = g_dev_ioctl,
.d_strategy = g_dev_strategy,
.d_name = "g_dev",
- .d_maj = GEOM_MAJOR,
.d_flags = D_DISK | D_TRACKCLOSE,
};
static g_taste_t g_dev_taste;
static g_orphan_t g_dev_orphan;
+static g_init_t g_dev_init;
static struct g_class g_dev_class = {
.name = "DEV",
.version = G_VERSION,
.taste = g_dev_taste,
.orphan = g_dev_orphan,
+ .init = g_dev_init,
};
+static struct unrhdr *unithdr; /* Locked by topology */
+
+static void
+g_dev_init(struct g_class *mp)
+{
+
+ /* XXX: should have a #define MAX_UNIT_MINOR */
+ unithdr = new_unrhdr(0, 0xffffff);
+}
+
void
g_dev_print(void)
{
@@ -115,9 +126,9 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
{
struct g_geom *gp;
struct g_consumer *cp;
- static int unit = GEOM_MINOR_PROVIDERS;
int error;
struct cdev *dev;
+ u_int unit;
g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name);
g_topology_assert();
@@ -133,9 +144,10 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
* XXX: I'm not 100% sure we can call make_dev(9) without Giant
* yet. Once we can, we don't need to drop topology here either.
*/
+ unit = alloc_unr(unithdr);
g_topology_unlock();
mtx_lock(&Giant);
- dev = make_dev(&g_dev_cdevsw, unit2minor(unit++),
+ dev = make_dev(&g_dev_cdevsw, unit2minor(unit),
UID_ROOT, GID_OPERATOR, 0640, gp->name);
if (pp->flags & G_PF_CANDELETE)
dev->si_flags |= SI_CANDELETE;
@@ -389,6 +401,7 @@ g_dev_orphan(struct g_consumer *cp)
{
struct g_geom *gp;
struct cdev *dev;
+ u_int unit;
g_topology_assert();
gp = cp->geom;
@@ -400,7 +413,9 @@ g_dev_orphan(struct g_consumer *cp)
set_dumper(NULL);
/* Destroy the struct cdev *so we get no more requests */
+ unit = dev2unit(dev);
destroy_dev(dev);
+ free_unr(unithdr, unit);
/* Wait for the cows to come home */
while (cp->nstart != cp->nend)
diff --git a/sys/geom/geom_int.h b/sys/geom/geom_int.h
index 39b3f10..cb69df3 100644
--- a/sys/geom/geom_int.h
+++ b/sys/geom/geom_int.h
@@ -51,14 +51,6 @@ extern int g_debugflags;
#define G_F_DISKIOCTL 64
#define G_F_CTLDUMP 128
-/*
- * We actually have a number of drivers sharing the same major number
- * so we coordinate the major/minor usage here
- */
-#define GEOM_MAJOR 4
-#define GEOM_MINOR_STATS 0
-#define GEOM_MINOR_PROVIDERS 10
-
/* geom_dump.c */
void g_confxml(void *, int flag);
void g_conf_specific(struct sbuf *sb, struct g_class *mp, struct g_geom *gp, struct g_provider *pp, struct g_consumer *cp);
OpenPOWER on IntegriCloud