os: Reintroduce atomic write support
authorJohn Garry <john.g.garry@oracle.com>
Mon, 16 Sep 2024 16:53:40 +0000 (16:53 +0000)
committerJens Axboe <axboe@kernel.dk>
Mon, 16 Sep 2024 18:15:15 +0000 (12:15 -0600)
commit40f1fc11d4fc6dbbd3c0eb5852e24126dad5fd4e
tree4b3def73ea8c48280315054069b98a1609695bc2
parent5ba34480dc222db47d7813009eb95a7543790dd3
os: Reintroduce atomic write support

Previously O_ATOMIC support was added in commit d01612f3ae25 ("Add support
for O_ATOMIC"). But support was removed in commit a25ba6c64fe1 ("Get rid of
O_ATOMIC"), as support was never added in the Linux kernel.

Linux kernel 6.11 will add support for RWF_ATOMIC, which can be supported
for various ioengines. See latest man pages for details.

The plumbing was left in place for thread option oatomic, so that will be
reused.

Add a flag to say whether an engine supports atomic writes, and reject
when oatomic is set for an engine which does not support atomic writes.

This is a change in behaviour, as since commit a25ba6c64fe1 ("Get rid of
O_ATOMIC"), this oatomic has been ignored. However, it is better to tell
the user that their ioengine of choice does not support atomic writes.

Today RWF_ATOMIC is only supported for direct-IO. In future it may be
supported for buffered IO. As such, do not auto-set odirect=1 when
oatomic==1.

Signed-off-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20240916165347.2226763-3-john.g.garry@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
init.c
ioengines.h
options.c
os/os-linux.h