read() on dirs - grep

Gennady Proskurin gprspb at mail.ru
Mon Aug 9 22:35:21 UTC 2010


I see misbehaviour of new bsd grep in freebsd on tmpfs when grepping dirs.
For example (on tmpfs /tmp):

mkdir /tmp/qwe
grep something /tmp/qwe
(grep hangs)

When doing the same thing on ordinary filesystem (tried zfs and ufs), all works
correct (grep exits immediately).
I think this is easilly reproducible, but if you want me to submit additional
info on fill a PR, please tell.

I'm not sure though, what is the root of error: tmpfs or grep.
But grep at least should catch a error.

kdumps follows:

on TMPFS:

 11651 grep     CALL  stat(0x5072e0,0x7fffffffe3e0)
 11651 grep     NAMI  "/tmp/qwe"
 11651 grep     STRU  struct stat {dev=67174145, ino=12, mode=drwxr-xr-x , nlink=2, uid=1001, gid=0, rdev=4294967295, atime=1281378090, stime=1281378090, ctime=1281378090, birthtime=1281378090, size=0, blksize=4096, blocks=0, flags=0x0 }
 11651 grep     RET   stat 0
 11651 grep     CALL  fstat(0x3,0x7fffffffe2b0)
 11651 grep     STRU  struct stat {dev=67174145, ino=12, mode=drwxr-xr-x , nlink=2, uid=1001, gid=0, rdev=4294967295, atime=1281378090, stime=1281378090, ctime=1281378090, birthtime=1281378090, size=0, blksize=4096, blocks=0, flags=0x0 }
 11651 grep     RET   fstat 0
 11651 grep     CALL  read(0x3,0x800c97000,0x1000)
 11651 grep     RET   read -1 errno 21 Is a directory
 11651 grep     CALL  read(0x3,0x800c97000,0x1000)
 11651 grep     RET   read -1 errno 21 Is a directory
 11651 grep     CALL  read(0x3,0x800c97000,0x1000)
 11651 grep     RET   read -1 errno 21 Is a directory
...
(infinitely repeating this)


on ZFS:

 11644 grep     CALL  stat(0x5072e0,0x7fffffffe3d0)
 11644 grep     NAMI  "/var/tmp/qqq"
 11644 grep     STRU  struct stat {dev=1533790729, ino=28792, mode=drwxr-xr-x , nlink=2, uid=1001, gid=0, rdev=0, atime=1281379360.263012178, stime=1281379360.263012178, ctime=1281379360.263012178, birthtime=1281379360.263012178, size=2, blksize=131072, blocks=1, flags=0x0 }
 11644 grep     RET   stat 0
 11644 grep     CALL  fstat(0x3,0x7fffffffe2a0)
 11644 grep     STRU  struct stat {dev=1533790729, ino=28792, mode=drwxr-xr-x , nlink=2, uid=1001, gid=0, rdev=0, atime=1281379360.263012178, stime=1281379360.263012178, ctime=1281379360.263012178, birthtime=1281379360.263012178, size=2, blksize=131072, blocks=1, flags=0x0 }
 11644 grep     RET   fstat 0
 11644 grep     CALL  read(0x3,0x800c96000,0x20000)
 11644 grep     GIO   fd 3 read 2 bytes
       0x0000 0300                           |..|

 11644 grep     RET   read 2
 11644 grep     CALL  read(0x3,0x800c96000,0x20000)
 11644 grep     GIO   fd 3 read 0 bytes
       ""
 11644 grep     RET   read 0
 11644 grep     CALL  close(0x3)
 11644 grep     RET   close 0


on UFS:

 11887 grep     CALL  stat(0x7fffffffea19,0x7fffffffe5d0)
 11887 grep     NAMI  "/ufs_dir"
 11887 grep     STRU  struct stat {dev=75, ino=95002, mode=drwxr-xr-x , nlink=2, uid=0, gid=0, rdev=378445, atime=1281381614, stime=1281381575, ctime=1281381575, birthtime=-1, size=512, blksize=16384, blocks=4, flags=0x0 }
 11887 grep     RET   stat 0
 11887 grep     CALL  open(0x7fffffffea19,O_RDONLY,<unused>0x1b6)
 11887 grep     NAMI  "/ufs_dir"
 11887 grep     RET   open 3
 11887 grep     CALL  stat(0x5072e0,0x7fffffffe3e0)
 11887 grep     NAMI  "/ufs_dir"
 11887 grep     STRU  struct stat {dev=75, ino=95002, mode=drwxr-xr-x , nlink=2, uid=0, gid=0, rdev=378445, atime=1281381614, stime=1281381575, ctime=1281381575, birthtime=-1, size=512, blksize=16384, blocks=4, flags=0x0 }
 11887 grep     RET   stat 0
 11887 grep     CALL  fstat(0x3,0x7fffffffe2b0)
 11887 grep     STRU  struct stat {dev=75, ino=95002, mode=drwxr-xr-x , nlink=2, uid=0, gid=0, rdev=378445, atime=1281381614, stime=1281381575, ctime=1281381575, birthtime=-1, size=512, blksize=16384, blocks=4, flags=0x0 }
 11887 grep     RET   fstat 0
 11887 grep     CALL  read(0x3,0x800c9a000,0x4000)
 11887 grep     GIO   fd 3 read 512 bytes
       0x0000 1a73 0100 0c00 0401 2e00 0000 0200 0000 f401 0402 2e2e 0000 0000 0000 0000  |.s............................|
       0x001e 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x003c 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x005a 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x0078 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x0096 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x00b4 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x00d2 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x00f0 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x010e 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x012c 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x014a 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x0168 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x0186 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x01a4 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x01c2 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x01e0 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000  |..............................|
       0x01fe 0000                                                                        |..|

 11887 grep     RET   read 512/0x200
 11887 grep     CALL  read(0x3,0x800c9a000,0x4000)
 11887 grep     GIO   fd 3 read 0 bytes
       ""
 11887 grep     RET   read 0
 11887 grep     CALL  close(0x3)
 11887 grep     RET   close 0



More information about the freebsd-current mailing list