Subject: panic with nfs: locking against myself
To: None <tech-kern@netbsd.org>
From: Pavel Cahyna <pcah8322@artax.karlin.mff.cuni.cz>
List: tech-kern
Date: 03/18/2003 18:33:40
Hello,

I'm running 1.6_STABLE . When I was trying to compile a package with
pkgsrc and distfiles mounted over NFS, I did:

# mount -t nfs -o rw,-q,-i omega:/obj /net/obj
## this is used for distfiles only, actual objdirs are local.

# mount -t nfs -o rw,-q,-i omega:/usr/pkgsrc /usr/pkgsrc/

# su - build
$ cd /usr/pkgsrc/print/teTeX
$ make clean

at this moment the kernel crashes with 

panic: lockmgr: locking against myself

The link "work.k2-netbsd-i386" which it tries to remove  is actually
removed at the server.

The backtrace is as follows:

Script started on Tue Mar 18 20:52:09 2003
root@k2:/root/crash# gdb netbsd.gdb
GNU gdb 5.0nb1
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386--netbsdelf"...
(gdb) target kcore netbsd.2.core
panic: lockmgr: locking against myself
#0  0x1 in ?? ()
(gdb) bt
#0  0x1 in ?? ()
#1  0xc030dc33 in cpu_reboot (howto=256, bootstr=0x0)
    at /usr/src/sys/arch/i386/i386/machdep.c:2236
#2  0xc0220b43 in db_sync_cmd () at /usr/src/sys/ddb/db_command.c:722
#3  0xc0220748 in db_command (last_cmdp=0xc0444014, cmd_table=0xc03df9ec)
    at /usr/src/sys/ddb/db_command.c:456
#4  0xc0220347 in db_command_loop () at /usr/src/sys/ddb/db_command.c:246
#5  0xc0223e20 in db_trap (type=1, code=0) at /usr/src/sys/ddb/db_trap.c:92
#6  0xc030aa5c in kdb_trap (type=1, code=0, regs=0xc5e6a7c0)
    at /usr/src/sys/arch/i386/i386/db_interface.c:129
#7  0xc031682b in trap (frame={tf_gs = 16, tf_fs = 16, tf_es = -974782448, 
      tf_ds = 16, tf_edi = 256, tf_esi = -1069664640, tf_ebp = -974739456, 
      tf_ebx = -974739412, tf_edx = -1069650306, tf_ecx = 6400, tf_eax = 3565, 
      tf_trapno = 1, tf_err = 0, tf_eip = -1070552276, tf_cs = -1069678584, 
      tf_eflags = 514, tf_esp = -974739424, tf_ss = -1071368267, 
      tf_vm86_es = -976296492, tf_vm86_ds = 65538, tf_vm86_fs = -974058100, 
      tf_vm86_gs = -1066605012}) at /usr/src/sys/arch/i386/i386/trap.c:220
#8  0xc0100e81 in calltrap ()
#9  0xc02437b5 in panic (fmt=0xc03e3680 "lockmgr: locking against myself")
    at /usr/src/sys/kern/subr_prf.c:237
#10 0xc0234231 in lockmgr (lkp=0xc5cee5d4, flags=<error type>, 
    interlkp=0xc5cee568) at /usr/src/sys/kern/kern_lock.c:658
#11 0xc0268280 in genfs_lock (v=0xc5e6a8a4)
---Type <return> to continue, or q <return> to quit---
    at /usr/src/sys/miscfs/genfs/genfs_vnops.c:320
#12 0xc026732a in VOP_LOCK (vp=0xc5cee568, flags=65538)
    at /usr/src/sys/kern/vnode_if.c:1083
#13 0xc0266aed in vn_lock (vp=0xc5cee568, flags=65538)
    at /usr/src/sys/kern/vfs_vnops.c:622
#14 0xc02601f9 in vget (vp=0xc5cee568, flags=2)
    at /usr/src/sys/kern/vfs_subr.c:1156
#15 0xc01b0de6 in nfs_nget (mntp=0xc0703200, fhp=0xc5e6ac40, fhsize=28, 
    npp=0xc5e6a998) at /usr/src/sys/nfs/nfs_node.c:176
#16 0xc01b3751 in nqnfs_callback (nmp=0xc0703400, mrep=0xc0702200, 
    md=0xc0702200, dpos=0xc07022b4 "\na1:XEP2LHKYQUTRXKPBCDDZ2D3JZ6FKXZVM")
    at /usr/src/sys/nfs/nfs_nqlease.c:981
#17 0xc01c8fbf in nfs_reply (myrep=0xc06d1f00)
    at /usr/src/sys/nfs/nfs_socket.c:791
#18 0xc01c95f2 in nfs_request (vp=0xc5cee568, mrest=0xc0617100, procnum=12, 
    procp=0xc5e661d4, cred=0xc0711380, mrp=0xc5e6adcc, mdp=0xc5e6add0, 
    dposp=0xc5e6add4) at /usr/src/sys/nfs/nfs_socket.c:1043
#19 0xc01dceed in nfs_removerpc (dvp=0xc5cee568, 
    name=0xc5cd2000 "work.k2-netbsd-i386", namelen=19, cred=0xc0711380, 
    proc=0xc5e661d4) at /usr/src/sys/nfs/nfs_vnops.c:1640
#20 0xc01dc8a6 in nfs_remove (v=0xc5e6aec0)
    at /usr/src/sys/nfs/nfs_vnops.c:1582
#21 0xc026707d in VOP_REMOVE (dvp=0xc5cee568, vp=0xc5d8d9a4, cnp=0xc5e6af1c)
---Type <return> to continue, or q <return> to quit---
    at /usr/src/sys/kern/vnode_if.c:727
#22 0xc026422b in sys_unlink (p=0xc5e661d4, v=0xc5e6af80, retval=0xc5e6af78)
    at /usr/src/sys/kern/vfs_syscalls.c:1608
#23 0xc0316383 in syscall_plain (frame={tf_gs = 31, tf_fs = 31, tf_es = 31, 
      tf_ds = 31, tf_edi = -1077945660, tf_esi = -1077945392, 
      tf_ebp = -1077945564, tf_ebx = -1077945257, tf_edx = 41469, 
      tf_ecx = -1077945297, tf_eax = 10, tf_trapno = 3, tf_err = 2, 
      tf_eip = 134665179, tf_cs = 23, tf_eflags = 663, tf_esp = -1077945704, 
      tf_ss = 31, tf_vm86_es = 0, tf_vm86_ds = 0, tf_vm86_fs = 0, 
      tf_vm86_gs = 0}) at /usr/src/sys/arch/i386/i386/syscall.c:140
#24 0xc0100f4e in syscall1 ()
can not access 0xbfbfdb24, invalid translation (invalid PDE)
can not access 0xbfbfdb24, invalid translation (invalid PDE)
Cannot access memory at address 0xbfbfdb24
(gdb) root@k2:/root/crash# 
Script done on Tue Mar 18 20:53:56 2003

I also got a similar panic when typing make in the same directory, but
this time, it was while making a symlink to the working directory:

#0  0x1 in ?? ()
#1  0xc030dbe3 in cpu_reboot ()
#2  0xc0220b43 in db_sync_cmd ()
#3  0xc0220748 in db_command ()
#4  0xc0220347 in db_command_loop ()
#5  0xc0223e20 in db_trap ()
#6  0xc030aa0c in kdb_trap ()
#7  0xc03167db in trap ()
#8  0xc0100e81 in calltrap ()
#9  0xc02437b5 in panic ()
#10 0xc0234231 in lockmgr ()
#11 0xc0268280 in genfs_lock ()
#12 0xc026732a in VOP_LOCK ()
#13 0xc0266aed in vn_lock ()
#14 0xc02601f9 in vget ()
#15 0xc01b0de6 in nfs_nget ()
#16 0xc01b3751 in nqnfs_callback ()
#17 0xc01c8fbf in nfs_reply ()
#18 0xc01c95f2 in nfs_request ()
#19 0xc01e013b in nfs_symlink ()
#20 0xc02671d2 in VOP_SYMLINK ()
#21 0xc026403d in sys_symlink ()
#22 0xc0316333 in syscall_plain ()
#23 0xc0100f4e in syscall1 ()

I have a crash dump and kernel with debugging symbols for the first
crash, so I can provide any other required information.

I have rev 1.151.2.1 of nfs_vnops.c which is the latest revision for the
1.6 branch.

Any ideas?
Thanks	Pavel