svn commit: r355894 - stable/12/sys/geom

Alexander Motin mav at FreeBSD.org
Thu Dec 19 01:32:16 UTC 2019


Author: mav
Date: Thu Dec 19 01:32:15 2019
New Revision: 355894
URL: https://svnweb.freebsd.org/changeset/base/355894

Log:
  MFC r355438: Block ioctls for dying GEOM_DEV instances.
  
  For normal I/Os consumer and provider statuses are checked by g_io_check().
  But ioctl calls often do not go through it, being dispatched directly. This
  change makes their semantics more alike, protecting lower levels.

Modified:
  stable/12/sys/geom/geom_dev.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/geom/geom_dev.c
==============================================================================
--- stable/12/sys/geom/geom_dev.c	Thu Dec 19 01:30:29 2019	(r355893)
+++ stable/12/sys/geom/geom_dev.c	Thu Dec 19 01:32:15 2019	(r355894)
@@ -489,12 +489,6 @@ g_dev_close(struct cdev *dev, int flags, int fmt, stru
 	return (error);
 }
 
-/*
- * XXX: Until we have unmessed the ioctl situation, there is a race against
- * XXX: a concurrent orphanization.  We cannot close it by holding topology
- * XXX: since that would prevent us from doing our job, and stalling events
- * XXX: will break (actually: stall) the BSD disklabel hacks.
- */
 static int
 g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct thread *td)
 {
@@ -506,6 +500,12 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data
 	cp = dev->si_drv2;
 	pp = cp->provider;
 
+	/* If consumer or provider is dying, don't disturb. */
+	if (cp->flags & G_CF_ORPHAN)
+		return (ENXIO);
+	if (pp->error)
+		return (pp->error);
+
 	error = 0;
 	KASSERT(cp->acr || cp->acw,
 	    ("Consumer with zero access count in g_dev_ioctl"));
@@ -628,8 +628,6 @@ g_dev_ioctl(struct cdev *dev, u_long cmd, caddr_t data
 		error = g_io_getattr("GEOM::ident", cp, &i, data);
 		break;
 	case DIOCGPROVIDERNAME:
-		if (pp == NULL)
-			return (ENOENT);
 		strlcpy(data, pp->name, i);
 		break;
 	case DIOCGSTRIPESIZE:


More information about the svn-src-all mailing list