Add aliasing concept to geom.
Add an alias name list to geoms. Use them in geom_dev to create aliases. Previously, geom_dev would create an device node for the name of the geom. Now, additional nodes are created pointing back to the primary node with make_dev_alias_p. Aliases must be in place on the geom before any tasting occurs. Differential Revision: https://reviews.freebsd.org/D11873
This commit is contained in:
parent
6c6118b390
commit
c624eb2598
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=322196
@ -120,6 +120,15 @@ struct g_class {
|
||||
LIST_HEAD(,g_geom) geom;
|
||||
};
|
||||
|
||||
/*
|
||||
* The g_geom_alias is a list node for aliases for the geom name
|
||||
* for device node creation.
|
||||
*/
|
||||
struct g_geom_alias {
|
||||
LIST_ENTRY(g_geom_alias) ga_next;
|
||||
const char *ga_alias;
|
||||
};
|
||||
|
||||
#define G_VERSION_00 0x19950323
|
||||
#define G_VERSION_01 0x20041207 /* add fflag to g_ioctl_t */
|
||||
#define G_VERSION G_VERSION_01
|
||||
@ -150,6 +159,7 @@ struct g_geom {
|
||||
unsigned flags;
|
||||
#define G_GEOM_WITHER 1
|
||||
#define G_GEOM_VOLATILE_BIO 2
|
||||
LIST_HEAD(,g_geom_alias) aliases;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -269,6 +279,7 @@ void g_destroy_provider(struct g_provider *pp);
|
||||
void g_detach(struct g_consumer *cp);
|
||||
void g_error_provider(struct g_provider *pp, int error);
|
||||
struct g_provider *g_provider_by_name(char const *arg);
|
||||
void g_geom_add_alias(struct g_geom *gp, const char *alias);
|
||||
int g_getattr__(const char *attr, struct g_consumer *cp, void *var, int len);
|
||||
#define g_getattr(a, c, v) g_getattr__((a), (c), (v), sizeof *(v))
|
||||
int g_handleattr(struct bio *bp, const char *attribute, const void *val,
|
||||
|
@ -315,10 +315,11 @@ static struct g_geom *
|
||||
g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
|
||||
{
|
||||
struct g_geom *gp;
|
||||
struct g_geom_alias *gap;
|
||||
struct g_consumer *cp;
|
||||
struct g_dev_softc *sc;
|
||||
int error;
|
||||
struct cdev *dev;
|
||||
struct cdev *dev, *adev;
|
||||
char buf[SPECNAMELEN + 6];
|
||||
|
||||
g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name);
|
||||
@ -357,6 +358,23 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
|
||||
g_dev_attrchanged(cp, "GEOM::physpath");
|
||||
snprintf(buf, sizeof(buf), "cdev=%s", gp->name);
|
||||
devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK);
|
||||
/*
|
||||
* Now add all the aliases for this drive
|
||||
*/
|
||||
LIST_FOREACH(gap, &pp->geom->aliases, ga_next) {
|
||||
error = make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &adev, dev,
|
||||
"%s", gap->ga_alias);
|
||||
if (error) {
|
||||
printf("%s: make_dev_alias_p() failed (name=%s, error=%d)\n",
|
||||
__func__, gap->ga_alias, error);
|
||||
continue;
|
||||
}
|
||||
adev->si_flags |= SI_UNMAPPED;
|
||||
adev->si_iosize_max = dev->si_iosize_max;
|
||||
adev->si_drv2 = dev->si_drv2;
|
||||
snprintf(buf, sizeof(buf), "cdev=%s", gap->ga_alias);
|
||||
devctl_notify_f("GEOM", "DEV", "CREATE", buf, M_WAITOK);
|
||||
}
|
||||
|
||||
return (gp);
|
||||
}
|
||||
|
@ -234,6 +234,7 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct g_provider *pp, struct g_
|
||||
{
|
||||
struct g_consumer *cp2;
|
||||
struct g_provider *pp2;
|
||||
struct g_geom_alias *gap;
|
||||
|
||||
sbuf_printf(sb, " <geom id=\"%p\">\n", gp);
|
||||
sbuf_printf(sb, " <class ref=\"%p\"/>\n", gp->class);
|
||||
@ -259,6 +260,11 @@ g_conf_geom(struct sbuf *sb, struct g_geom *gp, struct g_provider *pp, struct g_
|
||||
continue;
|
||||
g_conf_provider(sb, pp2);
|
||||
}
|
||||
LIST_FOREACH(gap, &gp->aliases, ga_next) {
|
||||
sbuf_printf(sb, " <alias>\n");
|
||||
g_conf_printf_escaped(sb, "%s", gap->ga_alias);
|
||||
sbuf_printf(sb, " </alias>\n");
|
||||
}
|
||||
sbuf_printf(sb, " </geom>\n");
|
||||
}
|
||||
|
||||
|
@ -347,6 +347,7 @@ g_new_geomf(struct g_class *mp, const char *fmt, ...)
|
||||
gp->rank = 1;
|
||||
LIST_INIT(&gp->consumer);
|
||||
LIST_INIT(&gp->provider);
|
||||
LIST_INIT(&gp->aliases);
|
||||
LIST_INSERT_HEAD(&mp->geom, gp, geom);
|
||||
TAILQ_INSERT_HEAD(&geoms, gp, geoms);
|
||||
strcpy(gp->name, sbuf_data(sb));
|
||||
@ -367,6 +368,7 @@ g_new_geomf(struct g_class *mp, const char *fmt, ...)
|
||||
void
|
||||
g_destroy_geom(struct g_geom *gp)
|
||||
{
|
||||
struct g_geom_alias *gap, *gaptmp;
|
||||
|
||||
g_topology_assert();
|
||||
G_VALID_GEOM(gp);
|
||||
@ -380,6 +382,8 @@ g_destroy_geom(struct g_geom *gp)
|
||||
g_cancel_event(gp);
|
||||
LIST_REMOVE(gp, geom);
|
||||
TAILQ_REMOVE(&geoms, gp, geoms);
|
||||
LIST_FOREACH_SAFE(gap, &gp->aliases, ga_next, gaptmp)
|
||||
g_free(gap);
|
||||
g_free(gp->name);
|
||||
g_free(gp);
|
||||
}
|
||||
@ -1212,6 +1216,18 @@ g_compare_names(const char *namea, const char *nameb)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
g_geom_add_alias(struct g_geom *gp, const char *alias)
|
||||
{
|
||||
struct g_geom_alias *gap;
|
||||
|
||||
gap = (struct g_geom_alias *)g_malloc(
|
||||
sizeof(struct g_geom_alias) + strlen(alias) + 1, M_WAITOK);
|
||||
strcpy((char *)(gap + 1), alias);
|
||||
gap->ga_alias = (const char *)(gap + 1);
|
||||
LIST_INSERT_HEAD(&gp->aliases, gap, ga_next);
|
||||
}
|
||||
|
||||
#if defined(DIAGNOSTIC) || defined(DDB)
|
||||
/*
|
||||
* This function walks the mesh and returns a non-zero integer if it
|
||||
|
Loading…
Reference in New Issue
Block a user