Support for atomic block I/O operations
Chris Mason's atomic I/O patch set aims to fix that situation. It allows a file to be opened with the O_ATOMIC and O_DIRECT flags (only direct I/O is supported) to request atomic semantics. Thereafter, every write() call will be executed atomically if the hardware supports it. This feature is, thus, quite easy to use from user space.
Within the kernel, there is a new function available to block drivers:
void blk_queue_set_atomic_write(struct request_queue *q,
unsigned int segments);
This function tells the block layer that the device behind the given request queue can perform atomic operations up to the given number of segments (separate ranges of blocks on the storage medium). Thereafter, I/O requests may arrive with the REQ_ATOMIC flag set to request atomic execution. The block layer will ensure that the maximum segment count is not exceeded.
One can imagine a number of uses for this functionality. A journaling filesystem could, for example, use it to write out the journal and the commit block together, knowing that said commit block will only be visible if everything else was successfully written. But, Chris says, the first target is MySQL:
The patch set (which does not add support to any block drivers) is
relatively small and simple, so it should have a relatively good chance of
being merged in the very near future.
| Index entries for this article | |
|---|---|
| Kernel | Atomic I/O operations |
| Kernel | Block layer/Atomic operations |
