Revert r361838

Reported by:	delphij
This commit is contained in:
Conrad Meyer 2020-06-06 14:19:16 +00:00
parent f2dbbab767
commit a9ca503b52
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361870
2 changed files with 8 additions and 55 deletions

View File

@ -336,20 +336,9 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
struct cdev *dev, *adev;
char buf[SPECNAMELEN + 6];
struct make_dev_args args;
bool retaste;
g_trace(G_T_TOPOLOGY, "dev_taste(%s,%s)", mp->name, pp->name);
g_topology_assert();
/* Only one geom_dev per provider. */
LIST_FOREACH(cp, &pp->consumers, consumers) {
if (cp->geom->class != mp || (cp->flags & G_CF_SPOILED))
continue;
gp = cp->geom;
sc = cp->private;
dev = sc->sc_dev;
retaste = true;
goto aliases;
}
gp = g_new_geomf(mp, "%s", pp->name);
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
mtx_init(&sc->sc_mtx, "g_dev", NULL, MTX_DEF);
@ -391,8 +380,6 @@ 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);
retaste = false;
aliases:
/*
* Now add all the aliases for this drive
*/
@ -400,16 +387,8 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused)
error = make_dev_alias_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK, &adev, dev,
"%s", gap->ga_alias);
if (error) {
/*
* With aliases added after initial taste, we don't
* know which aliases are new in this retaste, so we
* try to create all of them. EEXIST is expected and
* silently ignored or else this becomes really spammy.
*/
if (error != EEXIST || !retaste)
printf("%s: make_dev_alias_p() failed (name=%s,"
" error=%d)\n", __func__, gap->ga_alias,
error);
printf("%s: make_dev_alias_p() failed (name=%s, error=%d)\n",
__func__, gap->ga_alias, error);
continue;
}
snprintf(buf, sizeof(buf), "cdev=%s", gap->ga_alias);

View File

@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <geom/geom.h>
#include <geom/geom_dbg.h>
#include <geom/geom_int.h>
#include <geom/geom_slice.h>
#include <geom/label/g_label.h>
@ -345,16 +344,18 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
{
struct g_label_metadata md;
struct g_consumer *cp;
struct g_class *clsp;
struct g_geom *gp;
int i;
bool changed;
g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name);
g_topology_assert();
G_LABEL_DEBUG(2, "Tasting %s.", pp->name);
/* Skip providers that are already open for writing. */
if (pp->acw > 0)
return (NULL);
if (strcmp(pp->geom->class->name, mp->name) == 0)
return (NULL);
@ -390,16 +391,9 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
if (md.md_provsize != pp->mediasize)
break;
/* Skip providers that are already open for writing. */
if (pp->acw > 0) {
g_access(cp, -1, 0, 0);
goto end;
}
g_label_create(NULL, mp, pp, md.md_label, G_LABEL_DIR,
pp->mediasize - pp->sectorsize);
} while (0);
changed = false;
for (i = 0; g_labels[i] != NULL; i++) {
char label[128];
@ -411,28 +405,8 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
g_topology_lock();
if (label[0] == '\0')
continue;
if (!g_label_is_name_ok(label)) {
G_LABEL_DEBUG(0,
"%s contains suspicious label, skipping.",
pp->name);
G_LABEL_DEBUG(1, "%s suspicious label is: %s",
pp->name, label);
continue;
}
g_provider_add_alias(pp, "%s/%s", g_labels[i]->ld_dir, label);
changed = true;
}
/*
* Force devfs interface to retaste the provider, to catch the new
* alias(es).
*/
if (changed) {
LIST_FOREACH(clsp, &g_classes, class) {
if (strcmp(clsp->name, "DEV") != 0)
continue;
clsp->taste(clsp, pp, 0);
break;
}
g_label_create(NULL, mp, pp, label, g_labels[i]->ld_dir,
pp->mediasize);
}
g_access(cp, -1, 0, 0);
end: