From owner-svn-src-stable-12@freebsd.org Thu Dec 19 01:32:16 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 22A211CE135; Thu, 19 Dec 2019 01:32:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47dZ9r06CRz42GZ; Thu, 19 Dec 2019 01:32:16 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F32A87225; Thu, 19 Dec 2019 01:32:15 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBJ1WFZx042832; Thu, 19 Dec 2019 01:32:15 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBJ1WFLW042831; Thu, 19 Dec 2019 01:32:15 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201912190132.xBJ1WFLW042831@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 19 Dec 2019 01:32:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r355894 - stable/12/sys/geom X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/geom X-SVN-Commit-Revision: 355894 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Dec 2019 01:32:16 -0000 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: