Re: NFS directory listing hang on write.

From: Trond Myklebust
Date: Tue Dec 02 2008 - 19:22:18 EST


On Tue, 2008-12-02 at 16:05 -0800, Russell Miller wrote:
> Hi, all. We're having some NFS problems here that I don't understand.
>
> The arguments are standard. wsize=32768,rsize=32768,tcp. Nothing
> else out of the ordinary. Test case is easy too:
>
> mount a filesystem.
> cd into the directory.
> create a 1G file and background the creation, so 1G is being written
> into the directory.
> Then, try to ls the directory.
>
> The ls will hang, sometimes for a few seconds, sometimes for the
> entire length of the write. This happens on every NFS server I've
> tried, including an acopia, bluearc, onstor, and a generic linux box
> running on the other end.

That is known and expected behaviour. It is not a bug.

The reason is that your 'ls' is also trying to stat() the file, and so
the client has to flush out all those writes in order to ensure that the
mtime/ctime are posixly correct.
By this, I mean that POSIX requires the filesystem to update the
mtime/ctime every time you issue a write() call. In the case of NFS,
this update is actually done when the client sends the WRITE rpc call to
to the server. IOW: in order to ensure that your mtime/ctime doesn't
change after you've issued the stat() call, we actually need to flush
out those backgrounded writes and wait for them to complete.

Cheers
Trond

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/