From owner-freebsd-bugs Wed Oct 30 13:50: 7 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 43D1E37B406 for ; Wed, 30 Oct 2002 13:50:04 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9DF0043E75 for ; Wed, 30 Oct 2002 13:50:03 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g9ULo3x3055162 for ; Wed, 30 Oct 2002 13:50:03 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g9ULo34j055161; Wed, 30 Oct 2002 13:50:03 -0800 (PST) Date: Wed, 30 Oct 2002 13:50:03 -0800 (PST) Message-Id: <200210302150.g9ULo34j055161@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Dima Dorfman Subject: Re: kern/44744: VN devices can hang system FreeBSD v4.5 Reply-To: Dima Dorfman Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/44744; it has been noted by GNATS. From: Dima Dorfman To: Peter Pentchev Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: kern/44744: VN devices can hang system FreeBSD v4.5 Date: Wed, 30 Oct 2002 21:49:13 +0000 Peter Pentchev wrote: > For the record, this - or a very similar - problem is still present in > 4.7-STABLE. When a vn device is mounted, there is nothing to stop > anyone from running 'vnconfig -u' - the device is happily torn down, and > any further access to the still-mounted filesystem returns ENXIO, as it > well should. > > Would there be a way to detect that a filesystem is mounted on the > device and stop the 'un-configuring' process? Should be pretty easy. I think something like the attached (untested, since I don't have a -stable machine I can use to test it) patch should do it. Note that the patch prevents "detach", not "unconfigure", and I'm not sure what the difference is. Index: vn.c =================================================================== RCS file: /ref/cvsf/src/sys/dev/vn/Attic/vn.c,v retrieving revision 1.105.2.4 diff -u -r1.105.2.4 vn.c --- vn.c 18 Nov 2001 07:11:00 -0000 1.105.2.4 +++ vn.c 30 Oct 2002 21:44:51 -0000 @@ -130,6 +130,7 @@ struct vn_softc { int sc_unit; int sc_flags; /* flags */ + int sc_opencount; int sc_size; /* size of vn, sc_secsize scale */ int sc_secsize; /* sector size */ struct diskslices *sc_slices; @@ -168,6 +169,7 @@ IFOPT(vn, VN_LABELS) if (vn->sc_slices != NULL) dsclose(dev, mode, vn->sc_slices); + --vn->sc_opencount; return (0); } @@ -267,6 +269,7 @@ return (ENXIO); } } + ++vn->sc_opencount; return(0); } @@ -480,11 +483,11 @@ case VNIOCDETACH: if ((vn->sc_flags & VNF_INITED) == 0) return(ENXIO); + if (vn->sc_opencount != 0) + return(EBUSY); /* * XXX handle i/o in progress. Return EBUSY, or wait, or * flush the i/o. - * XXX handle multiple opens of the device. Return EBUSY, - * or revoke the fd's. * How are these problems handled for removable and failing * hardware devices? (Hint: They are not) */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message