Filesystems – what file system operations need to be atomic?
Are unlink, fsync, and rename the only atoms by definition?
Edit: atom means that the operation is successful and effective or failed and invalid; The operation must not fail and have an impact
Obviously, if the kernel is confused, the program cannot handle the error of operation failure, but in this case, it must be considered that it does fail
Solution
I'm not sure that fsync (2) is atomic; If a file has 100 megabytes dirty in the buffer cache, it takes several seconds to write the data, and the kernel may crash during transmission to disk Perhaps the onboard DMA engine can only handle 4 megabytes of writes Perhaps without DMA support, the CPU must schedule each write through 512 byte blocks
What does "atom" mean?
MKDIR may be 'atomic', either a directory exists on the disk and is linked to the parent directory, or the directory data structure has not been linked to the parent directory, so it cannot be accessed – > does not exist
The same is true for mount (2): it is difficult to find mount (2) completed halfway. If it fails, the whole mount fails: whether the file system is mounted or not
Umount (2) is interesting. It can be done lazily, but once unloaded, it cannot be used for open (2) or create (2) calls
So, I think it boils down to, what does' atom 'mean?
These are the filesystems collected by programming house for you – what file system operations need to be atomic? I hope this article can help you solve file systems - what file system operations need to be atomic? Program development problems encountered.
If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.