mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 07:23:53 +01:00
ircd::fs: Use a nice-style value for request priority; default to zero.
This commit is contained in:
parent
2f5d175957
commit
e58a975750
4 changed files with 18 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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};
|
||||
};
|
||||
|
|
|
@ -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};
|
||||
|
|
17
ircd/aio.cc
17
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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue