mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +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.
|
/// Offset in the file to start the read from.
|
||||||
off_t offset {0};
|
off_t offset {0};
|
||||||
|
|
||||||
/// Request priority. Higher value request will take priority over lower
|
/// Request priority. Lower value request will take priority over higher
|
||||||
/// value. Lowest value is zero. Negative value will receive a contextual
|
int8_t priority {0};
|
||||||
/// value internally (generally just zero). Default is -1.
|
|
||||||
int8_t priority {-1};
|
|
||||||
|
|
||||||
/// Determines whether this operation is conducted via AIO. If not, a
|
/// Determines whether this operation is conducted via AIO. If not, a
|
||||||
/// direct syscall is made. Using AIO will only block one ircd::ctx while
|
/// 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.
|
/// this has no effect.
|
||||||
bool aio {true};
|
bool aio {true};
|
||||||
|
|
||||||
/// Request priority. This value is ignored by the kernel for the
|
/// Request priority. This value is ignored for sync operations.
|
||||||
/// operations provided by this interface. It is still provided for
|
int8_t priority {0};
|
||||||
/// consistency and may be used internally by IRCd in the future.
|
|
||||||
int8_t priority {-1};
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,10 +59,8 @@ struct ircd::fs::write_opts
|
||||||
/// the host system later ignores the offset due to the file's openmode.
|
/// the host system later ignores the offset due to the file's openmode.
|
||||||
off_t offset {0};
|
off_t offset {0};
|
||||||
|
|
||||||
/// Request priority. Higher value request will take priority over lower
|
/// Request priority. Lower value request will take priority over higher.
|
||||||
/// value. Lowest value is zero. Negative value will receive a contextual
|
int8_t priority {0};
|
||||||
/// value internally (generally just zero). Default is -1.
|
|
||||||
int8_t priority {-1};
|
|
||||||
|
|
||||||
/// for allocate()
|
/// for allocate()
|
||||||
bool keep_size {false};
|
bool keep_size {false};
|
||||||
|
|
17
ircd/aio.cc
17
ircd/aio.cc
|
@ -658,14 +658,21 @@ catch(const std::exception &e)
|
||||||
// internal util
|
// 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
|
int
|
||||||
ircd::fs::aio::reqprio(int input)
|
ircd::fs::aio::reqprio(int input)
|
||||||
{
|
{
|
||||||
// no use for negative values yet; make them zero.
|
static const auto median
|
||||||
input = std::max(input, 0);
|
{
|
||||||
|
int(MAX_REQPRIO / 2)
|
||||||
// value is reduced to system maximum.
|
};
|
||||||
input = std::min(input, int(ircd::info::aio_reqprio_max));
|
|
||||||
|
|
||||||
|
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;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue