Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug in __pmfs_xip_file_write #13

Open
paulwedeck opened this issue Oct 11, 2023 · 0 comments · May be fixed by #14
Open

Possible bug in __pmfs_xip_file_write #13

paulwedeck opened this issue Oct 11, 2023 · 0 comments · May be fixed by #14

Comments

@paulwedeck
Copy link

Steps to reproduce:

  • 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).

@paulwedeck paulwedeck linked a pull request Oct 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant