0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 10:08:56 +02:00

ircd::fs: Move the reqprio() normalizer from fs::aio:: to fs::.

This commit is contained in:
Jason Volk 2019-03-13 18:50:57 -07:00
parent 02435c3672
commit 56092db18c
3 changed files with 33 additions and 32 deletions

View file

@ -14,6 +14,8 @@
namespace ircd::fs
{
struct opts extern const opts_default;
int reqprio(int);
}
/// Options common to all operations

View file

@ -910,14 +910,17 @@ decltype(ircd::fs::aio::support_nowait)
extern __attribute__((weak))
ircd::fs::aio::support_nowait;
decltype(ircd::fs::aio::MAX_REQPRIO)
extern __attribute__((weak))
ircd::fs::aio::MAX_REQPRIO;
decltype(ircd::fs::aio::MAX_EVENTS)
extern __attribute__((weak))
ircd::fs::aio::MAX_EVENTS;
decltype(ircd::fs::aio::MAX_REQPRIO)
extern __attribute__((weak))
ircd::fs::aio::MAX_REQPRIO
{
20
};
/// Conf item to control whether AIO is enabled or bypassed.
decltype(ircd::fs::aio::enable)
ircd::fs::aio::enable
@ -1740,3 +1743,27 @@ ircd::fs::posix_flags(const std::ios::openmode &mode)
ret |= ret & O_RDWR && ret & (O_TRUNC | O_APPEND)? O_CREAT : 0;
return ret;
}
/// 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::reqprio(int input)
{
const auto &max_reqprio
{
aio::MAX_REQPRIO
};
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;
}

View file

@ -13,11 +13,6 @@
#include <ircd/asio.h>
#include "fs_aio.h"
namespace ircd::fs::aio
{
static int reqprio(int);
}
///////////////////////////////////////////////////////////////////////////////
//
// ircd/fs/aio.h
@ -884,26 +879,3 @@ const
{
return event.size();
}
//
// 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)
{
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;
}