Subject: Re: coda kernel panics: ok for l to be NULL?
To: Greg Troxel <gdt@ir.bbn.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: tech-kern
Date: 03/10/2006 16:49:13
--5mCyUwZo2JvN/JJP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Mar 09, 2006 at 12:45:23PM -0500, Greg Troxel wrote:
> I am running relatively recent current with extra KASSERTs in
> coda_venus.  The variable l is passwd in as struct lwp, and used as follo=
ws:
>=20
> int
> venus_close(void *mdp, CodaFid *fid, int flag,
> 	struct ucred *cred, struct lwp *l)
> {
>     int cflag;
>     DECL_NO_OUT(coda_close);		/* sets Isize & Osize */
>     ALLOC_NO_OUT(coda_close);		/* sets inp & outp */
>=20
>     KASSERT(l !=3D NULL);
>     INIT_IN(&inp->ih, CODA_CLOSE, cred, l->l_proc);
>     inp->Fid =3D *fid;
>     CNV_OFLAG(cflag, flag);
>     inp->flags =3D cflag;
>=20
>     error =3D coda_call(mdp, Isize, &Osize, (char *)inp);
>=20
>     CODA_FREE(inp, coda_close_size);
>     return error;
> }
>=20
> INIT_IN's use of l (as 4th arg p) is
>=20
> 	  (in)->pid =3D p ? p->p_pid : -1; \
>           (in)->pgid =3D p ? p->p_pgid : -1; \
>=20
>=20
> which resulted in:
>=20
> NetBSD/i386 (inexact.ir.bbn.com) (console)
>=20
> login: panic: kernel diagnostic assertion "l !=3D NULL" failed: file "/n0=
/gdt/NetBSD-current/src/sys/coda/coda_venus.c", line 247
> Stopped in pid 3663.1 (ktr 0xc0b10380) at       netbsd:cpu_Debugger+0x4: =
       p
> opl     %ebp
> db> bt
> cpu_Debugger(c042776e,cab0be08,0,0,cab0be1c) at netbsd:cpu_Debugger+0x4
> panic(c045f2c0,c0416262,c0425c7d,c043ff40,f7) at netbsd:panic+0x12c
> __assert(c0416262,c043ff40,f7,c0425c7d,0) at netbsd:__assert+0x2e
> venus_close(c04ae440,c0bb0308,2,ca220f18,0) at netbsd:venus_close+0x173
> coda_close(cab0be94,0,cab0bebc,c035b038,c040ae60) at netbsd:coda_close+0x=
cc
> VOP_CLOSE(cb149160,2,ca220f18,0,ca236708) at netbsd:VOP_CLOSE+0x36
> vn_close(cb149160,2,ca220f18,0,cb3c5968) at netbsd:vn_close+0x45
> vn_closefile(ca236708,0,c0b7b3f0,0,cb3c58f8) at netbsd:vn_closefile+0x29
> closef(ca236708,0,c04225f9,0,c0b103d0) at netbsd:closef+0x127
> ktrace_thread(c0b10380,563000,c056d000,0,c010017c) at netbsd:ktrace_threa=
d+0x106
>=20
>=20
> So, is it legitimate for vnode ops to happen without a struct lwp *?

Yes, it is. A number of places in the code call closef() with a NULL proc.=
=20
Not sure why, but they do.

> If so, I should just do
>=20
> l ? l->l_proc : NULL
>=20
> for the calls, wrapping it in a CODA_MAYBE_PROC ifdef to follow the
> style :-)
>=20
> Also, I find that pwd does not work inside coda, but haven't tracked
> that down - "ktrace pwd" while in coda reliably panics the system.

I think the "l ? " bit will work right.

Take care,

Bill

--5mCyUwZo2JvN/JJP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQFEEh6JWz+3JHUci9cRAhMPAJ9y3IW3geeFK3iikCuH5C9v1phcJwCgkRvu
2IiFif7DBeKIPjXvAEY5m7A=
=sdGS
-----END PGP SIGNATURE-----

--5mCyUwZo2JvN/JJP--