Subject: kern/2560: NFS loose '..' on large directories
To: None <gnats-bugs@NetBSD.ORG>
From: Manuel Bouyer <bouyer@lix.polytechnique.fr>
List: netbsd-bugs
Date: 06/20/1996 11:37:57
>Number:         2560
>Category:       kern
>Synopsis:       NFS loose '..' on large directories
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 20 06:05:00 1996
>Last-Modified:
>Originator:     bouyer@lix.polytechnique.fr (Manuel Bouyer)
>Organization:

LIX, Ecole Polytechnique, Palaiseau (France).

>Release:        1.2_ALPHA kernel of yesterday, userland of 1996 06 01
>Environment:

NFS server: NetBSD/pmax on a decstation 5000/200
NSF client: NetBSD/sparc on a ELC.
Both runs a kernel compiled from yesterday's sources.

>Description:
	On directories with a lot of file nfs mounted, NFS seems to randomly
        mangle the '..' entries, in a way such that .. and . are the same, i.e.
        cd .. does'nt change directory (is equivalent to 'cd .'), getcwd and
        and pwd fail. When a directory is entered in this state, it stays until
        the filesystem is unmouted and remounted, or the directory block
        get out of the buffer cache.
>How-To-Repeat:
 My /usr/src is nfs mounted on the sparc from the pmax (with :
 antioche:/usr/src /usr/src nfs rw,-i,-b)
 a 'make clean' in a build libc (i.e. with is about 1800 .o, .po and .so)
 will always end up in:
    getcwd() failed
    *** Error code 2
    Stop.
 
 a 'make -j3' in libc can also end with the same error.
 Then pwd returns:
  cezanne:/usr/src/src_current/lib/libc> pwd
  pwd: File name too long

 after a 'cd ..', ls shows us that we are still in libc. Same thing for
 cd ../../../../../../../../../../../../../../.. (My absolute path should
 be '/usr/src/src_current/lib/libc', so after the previous 'cd' I should
 be in /).

 A ktrace on pwd shows that it loops on '..' entries :

  5316 ktrace   RET   ktrace 0
  5316 ktrace   CALL  __sysctl(0xf7fff148,0x2,0xf2f8,0xf7fff144,0,0)
  5316 ktrace   RET   __sysctl 0
  5316 ktrace   CALL  break(0xf338)
  5316 ktrace   RET   break 0
  5316 ktrace   CALL  break(0xfffc)
  5316 ktrace   RET   break 0
  5316 ktrace   CALL  break(0x10ffc)
  5316 ktrace   RET   break 0
  5316 ktrace   CALL  execve(0xf7fff290,0xf7fff768,0xf7fff770)
  5316 ktrace   NAMI  "/usr/local/bin/pwd"
  5316 ktrace   RET   execve -1 errno 2 No such file or directory
  5316 ktrace   CALL  execve(0xf7fff290,0xf7fff768,0xf7fff770)
  5316 ktrace   NAMI  "/bin/pwd"
  5316 pwd      EMUL  "netbsd"
  5316 pwd      RET   execve 0
  5316 pwd      CALL  __sysctl(0xf7fff560,0x2,0x11478,0xf7fff55c,0,0)
  5316 pwd      RET   __sysctl 0
  5316 pwd      CALL  break(0x114b4)
  5316 pwd      RET   break 0
  5316 pwd      CALL  break(0x11ffc)
  5316 pwd      RET   break 0
  5316 pwd      CALL  break(0x12ffc)
  5316 pwd      RET   break 0
  5316 pwd      CALL  stat(0x30c0,0xf7fff650)
  5316 pwd      NAMI  "/"
  5316 pwd      RET   stat 0
  5316 pwd      CALL  lstat(0x12400,0xf7fff650)
  5316 pwd      NAMI  "."
  5316 pwd      RET   lstat 0
  5316 pwd      CALL  open(0x12400,0x4,0xf85f6900)
  5316 pwd      NAMI  ".."
  5316 pwd      RET   open 3
  5316 pwd      CALL  fstat(0x3,0xf7fff508)
  5316 pwd      RET   fstat 0
  5316 pwd      CALL  fcntl(0x3,0x2,0x1)
  5316 pwd      RET   fcntl 0
  5316 pwd      CALL  break(0x13ffc)
  5316 pwd      RET   break 0
  5316 pwd      CALL  fstatfs(0x3,0xf7fff408)
  5316 pwd      RET   fstatfs 0
  5316 pwd      CALL  break(0x15ffc)
  5316 pwd      RET   break 0
  5316 pwd      CALL  break(0x16ffc)
  5316 pwd      RET   break 0
  5316 pwd      CALL  fstat(0x3,0xf7fff650)
  5316 pwd      RET   fstat 0
  5316 pwd      CALL  getdirentries(0x3,0x14000,0x1000,0x13014)
  5316 pwd      RET   getdirentries 4096/0x1000
  5316 pwd      CALL  lseek(0x3,0,0,0,0,0)
  5316 pwd      RET   lseek 0
  5316 pwd      CALL  close(0x3)
  5316 pwd      RET   close 0
  5316 pwd      CALL  lstat(0x12400,0xf7fff650)
  5316 pwd      NAMI  "../"
  5316 pwd      RET   lstat 0
  5316 pwd      CALL  open(0x12400,0x4,0)
  5316 pwd      NAMI  "../.."
  5316 pwd      RET   open 3
  5316 pwd      CALL  fstat(0x3,0xf7fff508)
  5316 pwd      RET   fstat 0
  5316 pwd      CALL  fcntl(0x3,0x2,0x1)
  5316 pwd      RET   fcntl 0
  5316 pwd      CALL  fstatfs(0x3,0xf7fff408)
  5316 pwd      RET   fstatfs 0
  5316 pwd      CALL  fstat(0x3,0xf7fff650)
  5316 pwd      RET   fstat 0
  5316 pwd      CALL  getdirentries(0x3,0x14000,0x1000,0x13014)
  5316 pwd      RET   getdirentries 4096/0x1000
  5316 pwd      CALL  lseek(0x3,0,0,0,0,0)
  5316 pwd      RET   lseek 0
  5316 pwd      CALL  close(0x3)
  5316 pwd      RET   close 0
  5316 pwd      CALL  lstat(0x12400,0xf7fff650)
  5316 pwd      NAMI  "../../"
  5316 pwd      RET   lstat 0
  5316 pwd      CALL  open(0x12400,0x4,0)
  5316 pwd      NAMI  "../../.."
  5316 pwd      RET   open 3
  5316 pwd      CALL  fstat(0x3,0xf7fff508)
  5316 pwd      RET   fstat 0
  5316 pwd      CALL  fcntl(0x3,0x2,0x1)
  5316 pwd      RET   fcntl 0
  5316 pwd      CALL  fstatfs(0x3,0xf7fff408)
  5316 pwd      RET   fstatfs 0
  5316 pwd      CALL  fstat(0x3,0xf7fff650)
  5316 pwd      RET   fstat 0
  5316 pwd      CALL  getdirentries(0x3,0x14000,0x1000,0x13014)
  5316 pwd      RET   getdirentries 4096/0x1000
  5316 pwd      CALL  lseek(0x3,0,0,0,0,0)
  5316 pwd      RET   lseek 0
  5316 pwd      CALL  close(0x3)
   [.......]
  5316 pwd      RET   open 3
  5316 pwd      CALL  fstat(0x3,0xf7fff508)
  5316 pwd      RET   fstat 0
  5316 pwd      CALL  fcntl(0x3,0x2,0x1)
  5316 pwd      RET   fcntl 0
  5316 pwd      CALL  fstatfs(0x3,0xf7fff408)
  5316 pwd      RET   fstatfs 0
  5316 pwd      CALL  fstat(0x3,0xf7fff650)
  5316 pwd      RET   fstat 0
  5316 pwd      CALL  getdirentries(0x3,0x14000,0x1000,0x13014)
  5316 pwd      RET   getdirentries 4096/0x1000
  5316 pwd      CALL  lseek(0x3,0,0,0,0,0)
  5316 pwd      RET   lseek 0
  5316 pwd      CALL  close(0x3)
  5316 pwd      RET   close 0
  5316 pwd      CALL  lstat(0x17000,0xf7fff650)
  5316 pwd      NAMI  "../../../../../../../../../../../../../../../../../../../
../../../../../../../../../../../../../../../../../../../../../../../../../../..
/../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../../../../../../../../../../../../../../
../../../../../../../../../../../../../../../../../../../../../../../../../../..
/../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../../../../../../../../../../../../../../
../../../../../../../../../../../../../../../../../../../../../../../../../../..
/../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../../../../../../../../../../../../../../
../../../../../../../../../../../../../../../../../../../../../../../../../../..
/../../../../../../../../../../../../../../../../../../../../../../../../../../.
./../../../../../../../../../../../../../../../../../../../../../../../../../../
../../"
  5316 pwd      RET   lstat 0
  5316 pwd      CALL  open(0x17000,0x4,0)
  5316 pwd      RET   open -1 errno 63 File name too long
  5316 pwd      CALL  write(0x2,0xf7ffede8,0x5)
  5316 pwd      GIO   fd 2 wrote 5 bytes
  [ And then the systems calls related to nls and friend, and pwd exits ]

  I can send a complete ktrace.out if this can help.

>Fix:
	Unknown, sorry. A workaroud is to unmount/mount the filesystem
        when this appens. I had to do this 3 or 4 times to compile libc.
>Audit-Trail:
>Unformatted: