Date: Wed, 30 Oct 2002 13:50:03 -0800 (PST) From: Dima Dorfman <dima@trit.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/44744: VN devices can hang system FreeBSD v4.5 Message-ID: <200210302150.g9ULo34j055161@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/44744; it has been noted by GNATS.
From: Dima Dorfman <dima@trit.org>
To: Peter Pentchev <roam@ringlet.net>
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 <roam@ringlet.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210302150.g9ULo34j055161>
