[Bug 57696] [nfs] NFS client readdir terminates prematurely if renaming files

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed May 23 22:22:19 UTC 2018


--- Comment #14 from Rick Macklem <rmacklem at FreeBSD.org> ---
Still a problem and will affect NFSv4 as well.
The short version is that NFS is not a POSIX compliant file
The only way to reliably read a directory and remove its contents
is to repeatedly read the first entry in the directory (cookie offset 0)
and unlink() that entry until the directory is empty.
(If you modify bonnie++ to do this, it will work correctly over NFS.)
For other cases like rename, there is no fix.

What I believe other clients do to work around the problem is have
opendir() read the entire directory and then the readdir()s return
entries from that and never do getdirentries(2). This gives you
the entire directory in the form it had before the remove/rename...
(I have posted suggesting doing this for FreeBSD, but I've never had
 the collective say "yes, you should do this", so I haven't done it.)
It's actually pretty easy to do, since the code in libc already does
this for for "union" mounts, so changing to do this for NFS mounts
would be easy to code.
The problem with doing this is the libc opendir() is going to use a
lot of address space for large directories and might break in the extreme
I suggested an upper limit on directory size for the above but, again,
since no one said this was a good idea, I didn't pursue it.
(Sorry, it has been a while and I don't remember which email list
 I posted the "should I do this?" to.)

You are receiving this mail because:
You are the assignee for the bug.

More information about the freebsd-bugs mailing list