Date: Wed, 24 Oct 2001 15:12:52 -0500 From: Jonathan Lemon <jlemon@flugsvamp.com> To: current@freebsd.org Cc: Jonathan Lemon <jlemon@flugsvamp.com>, Jun Kuriyama <kuriyama@imgsrc.co.jp>, David Wolfskill <david@catwhisker.org> Subject: Re: panic: vrele: missed vn_close Message-ID: <20011024151252.F75389@prism.flugsvamp.com> In-Reply-To: <200110241859.f9OIxqs97073@apollo.backplane.com> References: <200110230121.f9N1LTa24181@freefall.freebsd.org> <7mg089l1bn.wl@waterblue.imgsrc.co.jp> <200110241838.f9OIcCR96868@apollo.backplane.com> <20011024135503.C75389@prism.flugsvamp.com> <200110241859.f9OIxqs97073@apollo.backplane.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Oct 24, 2001 at 11:59:52AM -0700, Matthew Dillon wrote:
>
> :
> :Hmm. The way the revamped console code works is this:
> :
> : cn_devopen() calls vn_open() to open the device. If this is not a
> :VCHR device, then it is closed. Otherwise, the vnode is stashed in
> :cnd->cnd_vp.
> :
> : When the device is closed though cnclose(), it walks through a list
> :of console devices, and if cnd_vp != NULL, calls vn_close() for that
> :vnode, and then NULLs out cnd_vp. (drops the reference.)
> :
> : My understanding is that vn_open/vn_close will track the count of
> :outstanding references to the vnode, so this should be safe to do.
> :--
> :Jonathan
>
> The panic is due to v_writecount not being properly adjusted. If a
> vnode is opened with FWRITE in vn_open(), then it must be closed with
> VWRITE in vn_close() or v_writecount will not be properly adjusted and cause
> the panic in question to occur later in vrele().
>
> I suspect that this is the problem with the devfs/console code.
Ugh. Probably. The console code tries to remember what flag was
used from the open, but doesn't use that flag during close.
Here's an (untested) patch - essentially it forces the FWRITE flag
always on, to avoid this problem. Possibly the right thing to do
is to used a fixed set of flags to open the console, and completely
ignore the user's specified mode.
--
Jonathan
Index: tty_cons.c
===================================================================
RCS file: /ncvs/src/sys/kern/tty_cons.c,v
retrieving revision 1.93
diff -u -r1.93 tty_cons.c
--- tty_cons.c 2001/10/23 20:25:50 1.93
+++ tty_cons.c 2001/10/24 19:36:25
@@ -365,7 +365,7 @@
{
struct cn_device *cnd;
- openflag = flag;
+ openflag = flag | FWRITE; /* XXX */
cn_is_open = 1; /* console is logically open */
if (cn_mute)
return (0);
@@ -382,7 +382,7 @@
STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) {
if (cnd->cnd_vp == NULL)
continue;
- vn_close(cnd->cnd_vp, mode, td->td_proc->p_ucred, td);
+ vn_close(cnd->cnd_vp, openflag, td->td_proc->p_ucred, td);
cnd->cnd_vp = NULL;
}
cn_is_open = 0;
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011024151252.F75389>
