Subject: Re: nfs crash
To: Patrick Welche <prlw1@newn.cam.ac.uk>
From: Matt Fredette <fredette@theory.lcs.mit.edu>
List: current-users
Date: 02/07/2002 19:29:17
> kernel: page fault trap, code=0
> Stopped in pid 28575 (postgres) at nfs_request+0x1d1: movl 0xc(%ecx),%edx
> db> t
> nfs_request+0x1d1
> nfs_writerpc+0xb8e
> nfs_doio+0x957
> nfs_strategy+0x98
> VOP_STRATEGY+0x34
> genfs_gop_write+0x3da
> genfs_putpages+0xa77
> VOP_PUTPAGES+0x59
> nfs_flush+0x31
> nfs_fsync+0x35
> VOP_FSYNC+0x65
> nfs_sync+0xac
> sys_sync+0x8e
> syscall_plain+0xd5

When working on the hp700 port, I would see a stack trace pretty
similar to this in a panic I'd get while trying to halt the machine.
Poking around it looked to me like credentials weren't getting 
passed through to everywhere they're needed; this patch to nfs_flush() 
in nfs/nfs_vnops.c made my problem go away.

I am completely not an expert on the NFS or filesystem code, and I 
still haven't 100% ruled out compiler bugs as the source of my problem.
Hopefully someone in the know can tell me if I really fixed a bug 
or not. :)

[snip]
Index: nfs_vnops.c
===================================================================
RCS file: /cvsroot/syssrc/sys/nfs/nfs_vnops.c,v
retrieving revision 1.148
diff -u -r1.148 nfs_vnops.c
--- nfs_vnops.c	2001/12/15 00:32:49	1.148
+++ nfs_vnops.c	2002/02/08 00:17:15
@@ -2883,6 +2883,18 @@
 	UVMHIST_FUNC("nfs_flush"); UVMHIST_CALLED(ubchist);
 
 	simple_lock(&vp->v_interlock);
+
+	/*
+	 * update the cached write creds for this node.
+	 */
+	if (cred != NOCRED) {
+		if (np->n_wcred) {
+			crfree(np->n_wcred);
+		}
+		np->n_wcred = cred;
+		crhold(cred);
+	}
+
 	error = VOP_PUTPAGES(vp, 0, 0, flushflags);
 	if (np->n_flag & NWRITEERR) {
 		error = np->n_error;
[snip]

-- 
Matt Fredette