-
Notifications
You must be signed in to change notification settings - Fork 45
Option to disable fsync #17
Comments
Probably should be done through subclassing, but this is not cleanly possible at the moment. |
I have the same usecase recently. After disable |
@mozillazg removing the fsync for the file breaks atomicity, which is the point of this library. I think you removed this one, right? We can add an option to remove the fsync for the directory though. |
@untitaker Yes, you are right, I removed that(both for file and directory). Does
http://pubs.opengroup.org/onlinepubs/009695399/functions/write.html I'll test just remove the |
@mozillazg The |
@untitaker Thanks for your reply. On ext4, when
https://www.kernel.org/doc/Documentation/filesystems/ext4.txt |
I didn't know that but I don't think a (non-root) application has control over
this anyway, so we can't rely on it.
…On Tue, Jun 26, 2018 at 07:33:36PM -0700, Huang Huang wrote:
@untitaker Thanks for your reply.
On ext4, when `auto_da_alloc` is enabled(default on) it looks like removing the fsync for file is safe too:
```
auto_da_alloc(*) Many broken applications don't use fsync() when
noauto_da_alloc replacing existing files via patterns such as
fd = open("foo.new")/write(fd,..)/close(fd)/
rename("foo.new", "foo"), or worse yet,
fd = open("foo", O_TRUNC)/write(fd,..)/close(fd).
If auto_da_alloc is enabled, ext4 will detect
the replace-via-rename and replace-via-truncate
patterns and force that any delayed allocation
blocks are allocated such that at the next
journal commit, in the default data=ordered
mode, the data blocks of the new file are forced
to disk before the rename() operation is
committed. This provides roughly the same level
of guarantees as ext3, and avoids the
"zero-length" problem that can happen when a
system crashes before the delayed allocation
blocks are forced to disk.
```
https://www.kernel.org/doc/Documentation/filesystems/ext4.txt
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#17 (comment)
|
The But it seems like doing the extra fsync-dir (only for Unix) is a bit out of scope for the library in the first place? |
I would like to preserve the current default behavior. I am happy with having an option. |
@untitaker |
I have a use-case for both ways:
|
I need both options as well for https://github.com/pirate/ArchiveBox to be able to support network storage drive that don't implement FSYNC, while still retaining FSYNC on drives that do support it. |
Does this proposal make sense to y'all? untitaker/rust-atomicwrites#45 I believe we could allow one to opt out of directory fsync, but the file fsync needs to stay |
Dunno about others but for ArchiveBox I need to be able to disable file fsync more than directory fsync. |
I've written my own fork of rust-atomicwrites for another application, with an added enum to toggle directory fsync: https://github.com/nyanpasu64/handlr/blob/atomic-save/src/common/atomic_save.rs. Note that I haven't used python-atomicwrites in a real-world application. I feel my chosen API is fairly uncontroversial on Linux (aside from picking a more informative name for the enum cases, and the API break on Rust, which can be mitigated with a default argument in Python). But I don't know how to make it behave on Windows, where directory fsync isn't an option provided by the OS.
I haven't explored other options aside from an added parameter. EDIT: Maybe |
Unsure if anybody needs this. I might need this because in one usecase I'm writing a lot of files (to different filenames), and only need a guarantee that a SIGKILL won't leave a partially written file (at the target location, tmpfiles are irrelevant).
Also this might be a problem with SSDs, as mentioned in #6
The text was updated successfully, but these errors were encountered: