utsaslab / WineFS

WineFS (SOSP 21): a huge-page aware file system for persistent memory
34 stars 2 forks source link

Possible bug in __pmfs_xip_file_write #13

Open paulwedeck opened 1 year ago

paulwedeck commented 1 year ago

Steps to reproduce:

The second command does not terminate. The reason is that the write syscall always returns 0 if the allocation fails. However, it should return an error if two successive writes fails[1]. Many programs like echo (probably a shell builtin but details) will infinitely retry this operation. This bug is not dangerous but mostly annoying and should be fixed in my opinion.

I think the underlying issue is that pmfs_find_and_alloc_blocks and __pmfs_xip_file_write (for pmfs_get_xip_mem) does not properly propagate errors

[1]: The last sentence is the most relevant one(write(2)):

Note that a successful write() may transfer fewer than count bytes. Such partial writes can occur for various reasons; for example, because there was insufficient space on the disk device to write all of the requested bytes, or because a blocked write() to a socket, pipe, or similar was interrupted by a signal handler after it had transferred some, but before it had transferred all of the requested bytes. In the event of a partial write, the caller can make another write() call to transfer the remaining bytes. The subsequent call will either transfer further bytes or may result in an error (e.g., if the disk is now full).