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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to