From: Miklos S. <mi...@sz...> - 2008-07-08 18:24:23
|
On Tue, 8 Jul 2008, Allen Pulsifer wrote: > This particular issue has probably come up before but I just want to make > sure I understand the answer. > > Two computers are simultaneously access a networked file. One is reading > the file and the other is writing it. > > Computer A does a getattr to retrieve the file size. The FS returns 1000 > bytes. A moment later, Computer B truncates the file to 500 bytes. > Computer A then does a read to retrieve bytes 0-999. The file however now > only contains 500 bytes. What should the FUSE-based file system return to > indicate that the returned data only contains 500 bytes, not 1000? It should return 500. What will happen after this depends on the version of the fuse kernel module: in 2.6.25 and earlier this caused the read to return 1000 and the last 500 bytes were zeroed out. 2.6.26 will return 500 in this case. > Or > should it return a negative error code? I don't think that would be useful. I've recently learned that a similar read vs. truncate race affects all linux filesystems, although the race window there is so small, nobody seems to bother about it. Miklos |