WebAssembly / WebAssembly/WASI

Remove `O_RSYNC`, `O_SYNC`, and/or `O_DSYNC`?

Open
#748 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P-filesystem S-inactive
Dominant language
Rust
Stars
5.8k
Forks
333
Avg merge
2d 13h
Merged PRs (30d)
3

Description

These flags are all about providing data integrity guarantees, however to my knowledge, no one has yet investigated the degree to which these guarantees could be made in a portable manner. This suggests that perhaps we should remove them, until we have an idea of what we're actually able to guarantee.

Here are some notes from my survey of documentation I could find:

Very few OS's claim to support O_RSYNC. Some claim to support O_SYNC and many claim to support O_DSYNC or something that sounds equivalent to it, like FILE_FLAG_WRITE_THROUGH on Windows. So if we're going to support them portably, it's important to have a way to implement them without OS support if needed. That raises some questions:

  • Is doing an fsync after every write sufficient to implement O_SYNC if a host OS doesn't support O_SYNC? In theory it's not identical because there is a window between when a write has returned and other processes are observing the newly written data, but it's not written to persistent storage yet, so an abrupt power failure may undo changes that had temporarily looked like they had been written. Does that mean we can't implement O_SYNC this way?

  • Is doing an fdatasync after every data write sufficient to implement O_DSYNC? In theory it has the same problem as O_SYNC.

  • If doing an fsync (for O_SYNC|O_RSYNC) or fdatasync (for O_DSYNC|O_RSYNC) before every read or data read sufficient to implement O_RSYNC? Does an fsync or fdatasync on one file descriptor flush data written through an independent separately-opened file descriptor?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the issue's survey of O_RSYNC, O_SYNC, and O_DSYNC support across operating systems, then examine the questions about fsync and fdatasync. Determine whether these flags can be specified portably or should be removed; done means reaching a documented decision about their guarantees and scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.