4 ms·
Slightly related: if a drive runs with a properly journaled, fully checksummed filesystem, for example zfs or btrfs - does the write-through mode guarantee that
by viraptor 5y ago
Slightly related: if a drive runs with a properly journaled, fully checksummed filesystem, for example zfs or btrfs - does the write-through mode guarantee that you can only lose new data and not corrupt the old?
- viraptor 5y agoFound it kind of answered in the side thread: https://mobile.twitter.com/marcan42/status/1494227803327598598 https://mobile.twitter.com/marcan42/status/14942278033275985... In short - no, you'll still see corruption.
- floatboth 5y agoNo, you won't see corruption on ZFS. Cutting power to the drive is always safe, you can slice a SATA cable with a guillotine if you want, you'll always see a consistent state of the filesystem. ZFS transactions are entirely atomic. ZFS (and btrfs) is not "journaled", it's copy-on-write.
- viraptor 5y agoYou won't see corruption of the filesystem itself, but you'll see data corruption as described in the thread. If the writes are delayed, the write ordering can get messed up. + Zfs has ZIL, which is basically journal equivalent.
- ryao 5y agoJournals are used to protect filesystem metadata. The ZIL is used only to protect data. You will not see any data corruption on ZFS as long as the underlying hardware implements REQ_PREFLUSH correctly and the software uses proper POSIX semantics. If no filesystem corruption is happening, then the stuff under ZFS is doing its job correctly and your problem is in userspace. Following a crash, ZFS returns to a past good state. Any completed synchronous writes or writes protected by a completed fsync will be there. Any of those that did not complete can be expected to be lost (unless it was moments away from returning to userspace) and any non-synchronous IO that occurred in the last several seconds is allowed to disappear. By default, non-sync IO is flushed to permanent storage every 5 seconds. A past good state is not something that I would call corruption and software is expected to be able to resume from the past under POSIX.
- ryao 5y agoFilesystem corruption on ZFS would indicate that REQ_PREFLUSH is not being implemented correctly by either the hardware or the device driver.
- ryao 5y agoZFS is not journaled. CoW eliminates the need for anything like a journal with the exception of synchronous IO, where an intent log is used that can be replayed after a power loss event. In any case, ZFS should be fine as long as REQ_PREFLUSH is working properly. You can read a little about that here: https://github.com/openzfs/zfs/blob/453c63e9b74cea42d45e0bd30c0771f98a7ce60d/include/os/linux/kernel/linux/blkdev_compat.h#L385 https://github.com/openzfs/zfs/blob/453c63e9b74cea42d45e0bd3... https://elixir.bootlin.com/linux/v4.18/source/include/linux/blk_types.h#L322 https://elixir.bootlin.com/linux/v4.18/source/include/linux/...