pub enum FlushCoverage {
CoversPrecedingOperations,
Unordered,
}Expand description
Whether a flush covers the operations queued before it (M12.1, D-23 in
DESIGN-NOTES.md).
This is a required argument on Batch::flush and
Batch::flush_raw rather than a field of PushOptions, because there
is no defensible default. An unflagged flush does not cover preceding
writes: it is an ordinary operation competing with them, and it frequently
wins. A default would make the obvious spelling – push the writes, then
push a flush – a silent data-loss bug rather than a missing feature, so
the decision is taken at the call site instead (D-25).
It is an enum rather than a bool for the same reason: flush(&file, true) does not say what the true decides, and this is not a parameter
anyone should have to look up.
Variants§
CoversPrecedingOperations
Wait for every operation already outstanding on the ring, then flush.
This is what makes preceding writes durable when the flush’s completion is observed, and it is what a caller closing an epoch wants.
It sets IOSQE_FLAGS_DRAIN_PRECEDING_OPS, which is a ring-wide
barrier rather than a per-file one (D-24, measured): operations pushed
after it are held until it completes even when they target unrelated
files, and its reach is every operation outstanding on the ring, not
only the ones in this batch. The whole ring stalls for the flush’s
duration. That cost is real, and it is the only reason the other
variant exists.
Unordered
Queue the flush with no barrier: it may start, and complete, while writes pushed before it are still in flight.
Almost never what a caller wants. Its completion proves nothing about any preceding write, so using it to close an epoch loses data that the caller believes is committed – invisibly, until power is lost.
Two uses are legitimate. One is host sequencing: the caller has already observed the completions of every write in the epoch before pushing this, so the ordering is established outside the ring and the barrier would only add a stall. The other is a flush that is not being used for durability at all.
Trait Implementations§
Source§impl Clone for FlushCoverage
impl Clone for FlushCoverage
Source§fn clone(&self) -> FlushCoverage
fn clone(&self) -> FlushCoverage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more