Create a new file that allocates all available memory (fallocate -l <large number> <myfile>). I tried 100000000 for a 16MB partition.
Try to append data to the file (echo abcd >> <myfile>)
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).
Steps to reproduce:
fallocate -l <large number> <myfile>
). I tried 100000000 for a 16MB partition.echo abcd >> <myfile>
)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
(forpmfs_get_xip_mem
) does not properly propagate errors[1]: The last sentence is the most relevant one(write(2)):