From effc34c86fcf2740b3f64b1cd27b0b6c7b8f3574 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 17 Mar 2019 18:41:45 -0700 Subject: [PATCH] ircd::fs::aio: Add struct aio_ring from the kernel ABI. --- ircd/fs_aio.cc | 8 ++++++++ ircd/fs_aio.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/ircd/fs_aio.cc b/ircd/fs_aio.cc index 4acd2249e..ab869bcf6 100644 --- a/ircd/fs_aio.cc +++ b/ircd/fs_aio.cc @@ -412,6 +412,14 @@ try } { syscall(this->max_events(), &idp); + + const aio_ring *const ring + { + reinterpret_cast(idp) + }; + + assert(ring->magic == aio_ring::MAGIC); + log::debug { "Established AIO(%p) context (fd:%d max_events:%zu max_submit:%zu)", diff --git a/ircd/fs_aio.h b/ircd/fs_aio.h index 0c3b13fc8..17465260d 100644 --- a/ircd/fs_aio.h +++ b/ircd/fs_aio.h @@ -23,6 +23,22 @@ namespace ircd::fs::aio void fsync(const fd &, const sync_opts &); } +struct aio_ring +{ + static constexpr uint MAGIC {0xa10a10a1}; + + uint id; // kernel internal index number + uint nr; // number of io_events + uint head; + uint tail; + uint magic; + uint compat_features; + uint incompat_features; + uint header_length; // size of aio_ring + struct io_event io_events[0]; +}; +// 128 bytes + ring size + /// AIO context instance from the system. Right now this is a singleton with /// an extern instance pointer at fs::aio::context maintained by fs::aio::init. struct ircd::fs::aio::system