diff --git a/include/ircd/fs/aio.h b/include/ircd/fs/aio.h index 8fa232655..27ad13859 100644 --- a/include/ircd/fs/aio.h +++ b/include/ircd/fs/aio.h @@ -25,8 +25,11 @@ namespace ircd::fs::aio struct kernel; struct request; - extern kernel *context; extern struct stats stats; + extern kernel *context; + + extern const bool available_fsync; + extern const bool available_fdsync; } /// Statistics structure. diff --git a/include/ircd/fs/fsync.h b/include/ircd/fs/fsync.h index 70d64f786..1dc5feaf2 100644 --- a/include/ircd/fs/fsync.h +++ b/include/ircd/fs/fsync.h @@ -28,7 +28,7 @@ struct ircd::fs::fsync_opts /// direct syscall is made. Using AIO will only block one ircd::ctx while /// a direct syscall will block the thread (all contexts). If AIO is not /// available or enabled setting this has no effect. - bool use_aio {true}; + bool async {true}; /// Request priority. This value is ignored by the kernel for the /// operations provided by this interface. It is still provided for diff --git a/ircd/db.cc b/ircd/db.cc index 2040ec9b7..f82b4891c 100644 --- a/ircd/db.cc +++ b/ircd/db.cc @@ -4458,9 +4458,7 @@ noexcept try }; #endif - //TODO: AIO fdsync() throwing -EINVAL. fs::fsync_opts opts; - opts.use_aio = false; fs::fdsync(fd, opts); return Status::OK(); } @@ -4507,9 +4505,7 @@ noexcept try }; #endif - //TODO: AIO fdsync() throwing -EINVAL. fs::fsync_opts opts; - opts.use_aio = false; fs::fdsync(fd, opts); return Status::OK(); } @@ -4554,9 +4550,7 @@ noexcept try }; #endif - //TODO: AIO fdsync() throwing -EINVAL. fs::fsync_opts opts; - opts.use_aio = false; fs::fsync(fd, opts); return Status::OK(); } @@ -6630,9 +6624,7 @@ noexcept try }; #endif - //TODO: AIO fdsync() throwing -EINVAL. fs::fsync_opts opts; - opts.use_aio = false; fs::fsync(fd, opts); return Status::OK(); } @@ -6679,9 +6671,7 @@ noexcept try }; #endif - //TODO: AIO fdsync() throwing -EINVAL. fs::fsync_opts opts; - opts.use_aio = false; fs::fdsync(fd, opts); return Status::OK(); } @@ -6728,9 +6718,7 @@ noexcept try }; #endif - //TODO: AIO fdsync() throwing -EINVAL. fs::fsync_opts opts; - opts.use_aio = false; fs::fdsync(fd, opts); return Status::OK(); } diff --git a/ircd/fs.cc b/ircd/fs.cc index 02b35df5b..936d5daf5 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -406,7 +406,7 @@ ircd::fs::fsync(const fd &fd, try { #ifdef IRCD_USE_AIO - if(likely(aio::context) && opts.use_aio) + if(aio::context && opts.async && aio::available_fsync) return aio::fsync(fd, opts); #endif @@ -434,7 +434,7 @@ ircd::fs::fdsync(const fd &fd, try { #ifdef IRCD_USE_AIO - if(likely(aio::context) && opts.use_aio) + if(aio::context && opts.async && aio::available_fdsync) return aio::fdsync(fd, opts); #endif @@ -893,15 +893,29 @@ catch(const std::exception &e) // fs/aio.h // -/// Non-null when aio is available for use -decltype(ircd::fs::aio::context) -ircd::fs::aio::context -{}; - /// Global stats structure decltype(ircd::fs::aio::stats) -ircd::fs::aio::stats -{}; +ircd::fs::aio::stats; + +/// Non-null when aio is available for use +decltype(ircd::fs::aio::context) +ircd::fs::aio::context; + +/// True if IOCB_CMD_FSYNC is supported by AIO. If this is false then +/// fs::fsync_opts::async=true flag is ignored. +decltype(ircd::fs::aio::available_fsync) +ircd::fs::aio::available_fsync +{ + false //TODO: Detect kernel support +}; + +/// True if IOCB_CMD_FDSYNC is supported by AIO. If this is false then +/// fs::fsync_opts::async=true flag is ignored. +decltype(ircd::fs::aio::available_fdsync) +ircd::fs::aio::available_fdsync +{ + false //TODO: Detect kernel support +}; // // init