Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Dec 2019 03:46:38 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355438 - head/sys/geom
Message-ID:  <201912060346.xB63kcgM089118@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Dec  6 03:46:38 2019
New Revision: 355438
URL: https://svnweb.freebsd.org/changeset/base/355438

Log:
  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.
  
  MFC after:	2 weeks

Modified:
  head/sys/geom/geom_dev.c

Modified: head/sys/geom/geom_dev.c
==============================================================================
--- head/sys/geom/geom_dev.c	Fri Dec  6 03:18:37 2019	(r355437)
+++ head/sys/geom/geom_dev.c	Fri Dec  6 03:46:38 2019	(r355438)
@@ -497,12 +497,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)
 {
@@ -517,6 +511,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"));
@@ -676,8 +676,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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912060346.xB63kcgM089118>