Question: How to reliably write to a file in ZFS #11692
Replies: 2 comments 1 reply
-
Suggested readinghttps://openzfs.github.io/openzfs-docs/man/8/fsck.zfs.8.html
#7912 – Feature: Ability to repair defective on-disk data https://openzfs.github.io/openzfs-docs/man/8/zdb.8.html options In practice (with FreeBSD), I never needed either of those approaches to transactions. ZFS fundamentals: transaction groups | Delphix (2012-12-11) |
Beta Was this translation helpful? Give feedback.
-
I'm gonna answer my own question in case someone is looking for it. I couldn't find official doc, I just read the code & relied on some user / expert testimony as well as current zfs code.
Basically yes if the drives don't lie about writes. The file system shouldn't corrupt itself normally, except in case of a bug. If the file system does get corrupted, such as in the case of hardware failure, it will get detected, as even the file sytem metadata is checksummed. This is different from classical file systems that are expected to corrupt themselves, thus why fsck is required to be run periodically on such systems. As for the data, basically the file system will be restored to the last commited transaction group.
I couldn't find good documentation on this, but the way I'm doing it currently is basically to
Couldn't find anything on this. However, see the previous paragraph about the
Nope. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm trying to find some documentation concerning behavior not specified by POSIX. I found lots of conflicting information online and nothing official. Specifically I would like to know what is the minimum set of syscalls required to write to a file atomically using ZFS, and I don't care about my code not being portable to another file system. By atomicity, I mean that in the event of a crash, either the file system detects and removes the write that couldn't be completely written to disk, or that a user space application has the ability to detect and remove the corrupted file.
For some context, since POSIX is dogshit, you need to go through multiple hoops just to be able to persist your file correctly in the event of a crash. This blog post explains this in more details. But even if you do everything correctly, you still run in the issue of most classical file systems potentially corrupting themselves on power failure (even XFS AFAIK).
I would like to know:
Beta Was this translation helpful? Give feedback.
All reactions