Skip to contentSkip to conversation

HELP! vfs_readv() issue

DISCUSSION Xin Zhao 4 participants 5 messages May 15, 2006 – May 18, 2006 VFS

lore
Share & tools
lore

Xin Zhao

author
#0 lore raw

I am writing a file system, but vfs_read() sometimes return 0. What could cause this problem?

Please help!

Xin

#1 lore raw
Quoted 2 lines · Xin Zhao

I am writing a file system, but vfs_read() sometimes return 0. What could cause this problem?

EOF?

author
#2 lore raw

Thank you for your care. What I am trying to do is to rewrite NFS in the virtual machine environment so that network communication can be replaced with inter-VM communication.

But after I remove the original rpc stuff, I ran into some strange problem, including this one. Interesting thing is that I noticed that even with standard NFS implementation, it is still possible that nfsd_read() return resp->count to be 0. At this time, eof is also equal to 1. This seems to be right since NFSD already reach the end of the file. But question is since 0 byte is read this time, NFS should detect EOF in previous read. Why need one more read?

Xin

Quoted 7 lines · Chris Wedgwood
Quoted 2 lines · Xin Zhao

I am writing a file system, but vfs_read() sometimes return 0. What could cause this problem?

EOF?

#3 lore raw
Quoted 12 lines · Xin Zhao

Thank you for your care. What I am trying to do is to rewrite NFS in the virtual machine environment so that network communication can be replaced with inter-VM communication.

But after I remove the original rpc stuff, I ran into some strange problem, including this one. Interesting thing is that I noticed that even with standard NFS implementation, it is still possible that nfsd_read() return resp->count to be 0. At this time, eof is also equal to 1. This seems to be right since NFSD already reach the end of the file. But question is since 0 byte is read this time, NFS should detect EOF in previous read. Why need one more read?

Quoted 1 line

Xin

How are you reading the file? Some programs (I believe 'cat' is one of them) will read a file until 0 is returned. Try writing a small C program to read a file until EOF and see if the behavior changes.

Avishay Traeger
http://www.fsl.cs.sunysb.edu/~avishay/

#4 lore raw
Quoted 14 lines · Avishay Traeger
Quoted 12 lines · Xin Zhao

Thank you for your care. What I am trying to do is to rewrite NFS in the virtual machine environment so that network communication can be replaced with inter-VM communication.

But after I remove the original rpc stuff, I ran into some strange problem, including this one. Interesting thing is that I noticed that even with standard NFS implementation, it is still possible that nfsd_read() return resp->count to be 0. At this time, eof is also equal to 1. This seems to be right since NFSD already reach the end of the file. But question is since 0 byte is read this time, NFS should detect EOF in previous read. Why need one more read?

Quoted 6 lines
Quoted 1 line

Xin

How are you reading the file? Some programs (I believe 'cat' is one of them) will read a file until 0 is returned. Try writing a small C program to read a file until EOF and see if the behavior changes.

Returning 0 from read() is only situation when you can be sure you are at the end of file. If you get short read(), it may be short due to EOF, but it may be short also because some error was hit - EIO and EFAULT are two which can occur almost always. And only next read will either return that error (or some other error, or success if error condition disappeared meanwhile), or zero if it is really EOF.
Petr