Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block: add support for barriers #330

Open
g2p opened this issue Mar 7, 2019 · 2 comments
Open

block: add support for barriers #330

g2p opened this issue Mar 7, 2019 · 2 comments

Comments

@g2p
Copy link

g2p commented Mar 7, 2019

This is to allow mandating ordering constraints on writes to block devices.

Some block devices behave sequentially by default, others don't.
A barrier mandates that write calls done before the barrier will land before any write calls done after the barrier call.
That is to say, even after an unclean shutdown, data that was written after the barrier will either fail to have persisted or will be able to reference the entirety of the data that was written before the barrier.

A durable barrier adds the guarantee that write calls done before the barrier will be as durable as the device can make them (this may involve cache flushing) once the barrier call has returned.
That is to say, after an unclean shutdown, data that was written after the barrier will either have persisted or the device will report errors.

Here's how the signature of the Mirage interface would look like:

  val barrier: ?durable:bool -> t -> (unit, write_error) result io
  (** [barrier device] will make sure that all writes done prior to the barrier
      call will hit [device] before the writes that are done after the barrier
      io has completed.
      No guarantee is made for writes made during the barrier io.
      If ~durable:true is passed, all writes prior to the barrier
      will be as durable as the device can make them, which may be slower.
      If ~durable is false or omitted, the implementation may still
      rely on slower, durable primitives if these are the only ones
      available. *)
@mato
Copy link
Member

mato commented Mar 7, 2019

Yes. You probably want to look at #325 first though.

@g2p
Copy link
Author

g2p commented Mar 11, 2019

It looks like it can only be implemented on spt ant hvt (with fdatasync, so more costly than a basic barrier).
Virtio has support too (as an optional feature), but I don't know of a backing implementation that implements it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants