diff --git a/include/ircd/fs/read.h b/include/ircd/fs/read.h index 31f9f76f9..fa9b82175 100644 --- a/include/ircd/fs/read.h +++ b/include/ircd/fs/read.h @@ -40,10 +40,8 @@ struct ircd::fs::read_opts /// Offset in the file to start the read from. off_t offset {0}; - /// Request priority. Higher value request will take priority over lower - /// value. Lowest value is zero. Negative value will receive a contextual - /// value internally (generally just zero). Default is -1. - int8_t priority {-1}; + /// Request priority. Lower value request will take priority over higher + int8_t priority {0}; /// Determines whether this operation is conducted via AIO. If not, a /// direct syscall is made. Using AIO will only block one ircd::ctx while diff --git a/include/ircd/fs/sync.h b/include/ircd/fs/sync.h index 556e6be9f..7106da410 100644 --- a/include/ircd/fs/sync.h +++ b/include/ircd/fs/sync.h @@ -39,8 +39,6 @@ struct ircd::fs::sync_opts /// this has no effect. bool aio {true}; - /// Request priority. This value is ignored by the kernel for the - /// operations provided by this interface. It is still provided for - /// consistency and may be used internally by IRCd in the future. - int8_t priority {-1}; + /// Request priority. This value is ignored for sync operations. + int8_t priority {0}; }; diff --git a/include/ircd/fs/write.h b/include/ircd/fs/write.h index 71ba3eed0..b80820251 100644 --- a/include/ircd/fs/write.h +++ b/include/ircd/fs/write.h @@ -59,10 +59,8 @@ struct ircd::fs::write_opts /// the host system later ignores the offset due to the file's openmode. off_t offset {0}; - /// Request priority. Higher value request will take priority over lower - /// value. Lowest value is zero. Negative value will receive a contextual - /// value internally (generally just zero). Default is -1. - int8_t priority {-1}; + /// Request priority. Lower value request will take priority over higher. + int8_t priority {0}; /// for allocate() bool keep_size {false}; diff --git a/ircd/aio.cc b/ircd/aio.cc index 9e07cdd39..d60455a04 100644 --- a/ircd/aio.cc +++ b/ircd/aio.cc @@ -658,14 +658,21 @@ catch(const std::exception &e) // internal util // +/// Translate an ircd::fs opts priority integer to an AIO priority integer. +/// The ircd::fs priority integer is like a nice value. The AIO value is +/// positive [0, MAX_REQPRIO]. This function takes an ircd::fs value and +/// shifts it to the AIO value. int ircd::fs::aio::reqprio(int input) { - // no use for negative values yet; make them zero. - input = std::max(input, 0); - - // value is reduced to system maximum. - input = std::min(input, int(ircd::info::aio_reqprio_max)); + static const auto median + { + int(MAX_REQPRIO / 2) + }; + input = std::max(input, 0 - median); + input = std::min(input, median); + input = MAX_REQPRIO - (input + median); + assert(input >= 0 && input <= int(MAX_REQPRIO)); return input; }