Add more debugging statements in vdev_geom.c

Log a debugging message whenever geom functions fail in vdev_geom_attach.
Printing these messages is controlled by vfs.zfs.debug

MFC after:	4 weeks
Sponsored by:	Spectra Logic Corp
This commit is contained in:
asomers 2016-04-14 23:14:41 +00:00
parent 4d9b1f8309
commit 0ee7b1f1ff

View File

@ -163,6 +163,7 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
{
struct g_geom *gp;
struct g_consumer *cp;
int error;
g_topology_assert();
@ -180,11 +181,17 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
gp->orphan = vdev_geom_orphan;
gp->attrchanged = vdev_geom_attrchanged;
cp = g_new_consumer(gp);
if (g_attach(cp, pp) != 0) {
error = g_attach(cp, pp);
if (error != 0) {
ZFS_LOG(1, "%s(%d): g_attach failed: %d\n", __func__,
__LINE__, error);
g_wither_geom(gp, ENXIO);
return (NULL);
}
if (g_access(cp, 1, 0, 1) != 0) {
error = g_access(cp, 1, 0, 1);
if (error != 0) {
ZFS_LOG(1, "%s(%d): g_access failed: %d\n", __func__,
__LINE__, error);
g_wither_geom(gp, ENXIO);
return (NULL);
}
@ -199,19 +206,29 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
}
if (cp == NULL) {
cp = g_new_consumer(gp);
if (g_attach(cp, pp) != 0) {
error = g_attach(cp, pp);
if (error != 0) {
ZFS_LOG(1, "%s(%d): g_attach failed: %d\n",
__func__, __LINE__, error);
g_destroy_consumer(cp);
return (NULL);
}
if (g_access(cp, 1, 0, 1) != 0) {
error = g_access(cp, 1, 0, 1);
if (error != 0) {
ZFS_LOG(1, "%s(%d): g_access failed: %d\n",
__func__, __LINE__, error);
g_detach(cp);
g_destroy_consumer(cp);
return (NULL);
}
ZFS_LOG(1, "Created consumer for %s.", pp->name);
} else {
if (g_access(cp, 1, 0, 1) != 0)
error = g_access(cp, 1, 0, 1);
if (error != 0) {
ZFS_LOG(1, "%s(%d): g_access failed: %d\n",
__func__, __LINE__, error);
return (NULL);
}
ZFS_LOG(1, "Used existing consumer for %s.", pp->name);
}
}