Re: [PATCH] zerocopy NFS updated

David S. Miller
2002-04-11T06:55:38Z

From: Hirokazu Takahashi <taka@valinux.co.jp>
Date: Thu, 11 Apr 2002 15:46:51 +0900 (JST)

Please consider a knfsd sends data of File A by useing sendmsg().
1. The knfsd copies the data of File A into sk_buff.
2. File A may be truncated after step.1
3. NFS clients receives the packets of File A which is already truncated.

Next please consider the knfsd sends data of File A by useing sendpage().
1. The knfsd grabs pages of File A. (page_cache_get)
2. File A may be truncated after step.1
3. The knfsd send the pages.
4. NFS clients receives the packets of File A which is already truncated.

Is there any differences between them ?
This behavior is invisible to NFS Clients, I think.

Consider truncate() to 1 byte left in that page. To handle mmap()'s
of this file the kernel will memset() rest of the page to zero.

Now, in the sendfile() case the NFS client sees some page filled
mostly of zeros instead of file contents.

In sendmsg() knfd case, client sees something reasonable. He will
see something that was actually in the file at some point in time.
The sendfile() case sees pure garbage, contents that never were in
the file at any point in time.

We could make knfsd take the write semaphore on the inode until client
is known to get the packet but that is the kind of overhead we'd like
to avoid.