To the best of my knowledge, when a process writes to a file it starts a system call. Among the required information, it expects a pointer to a buffer in the user space, filled with the data to write.

Consider a scenario where there is a process that spawns two threads. One thread executes a system call to write 10MB. The other thread performs invalid memory access that triggers a segmentation fault, while the Operating System is serving the IO request. What happens to the write request in this scenario? In particular, I have the guarantee that either the write operation does not happen or it is completed before the deallocation of the process memory? Do the answers change if the io request is just a 64-bit integer?


Currently, operations on a filesystem are un-interruptible - except for network filesystems.

See TASK_KILLABLE [LWN.net, 2008].

For traditional block-based filesystems, you might predict your guarantee will be met. I don't believe TASK_KILLABLE has been adopted widely outside of network filesystems. However I would not want to assume this will always be the case, without a good reason.

If there is a possibility the application could be run on a network filesystem, it is hard to say there are strong guarantees. (And in general, e.g note NFS3 does not follow all the expectations for a POSIX filesystem).

Storage technology is still evolving. E.g. if you assumed that filesystems will work a certain way based on looking at the architecture of the Linux block layer, you might be surprised in future when your application is run on a filesystem based on byte-addressable memory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.