0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

ircd::fs: Improve request priority value related; get sysconf info.

This commit is contained in:
Jason Volk 2018-11-01 20:15:12 -07:00
parent 3385d25c97
commit 13e6e02901
6 changed files with 41 additions and 12 deletions

View file

@ -24,6 +24,8 @@ struct ircd::fs::fsync_opts
{
fsync_opts() = default;
/// Request priority (this option may be improved, avoid for now)
int16_t priority {0};
/// 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};
};

View file

@ -36,8 +36,10 @@ struct ircd::fs::read_opts
/// Offset in the file to start the read from.
off_t offset {0};
/// Request priority (this option may be improved, avoid for now)
int16_t priority {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};
};
inline

View file

@ -47,8 +47,10 @@ struct ircd::fs::write_opts
/// Alignment requirement.
size_t alignment {0};
/// Request priority (this option may be improved, avoid for now)
int16_t priority {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};
/// for allocate()
bool keep_size {false};

View file

@ -51,6 +51,7 @@ namespace ircd::info
extern const int glibc_version[3];
extern const string_view glibc_version_str;
extern const int aio_reqprio_max;
#ifdef HAVE_SYS_UTSNAME_H
extern const ::utsname utsname;
#endif

View file

@ -17,6 +17,7 @@ namespace ircd::fs
{
extern char _zero_pads_[4096];
static size_t _zero_pads_required(const size_t &buf_size, const size_t &alignment);
static int reqprio(int);
}
//
@ -27,7 +28,7 @@ ircd::fs::aio::request::fsync::fsync(const int &fd,
const fsync_opts &opts)
:request{fd}
{
aio_reqprio = opts.priority;
aio_reqprio = reqprio(opts.priority);
aio_lio_opcode = IOCB_CMD_FSYNC;
aio_buf = 0;
@ -55,7 +56,7 @@ ircd::fs::aio::request::fdsync::fdsync(const int &fd,
const fsync_opts &opts)
:request{fd}
{
aio_reqprio = opts.priority;
aio_reqprio = reqprio(opts.priority);
aio_lio_opcode = IOCB_CMD_FDSYNC;
aio_buf = 0;
@ -92,7 +93,7 @@ ircd::fs::aio::request::read::read(const int &fd,
},
}
{
aio_reqprio = opts.priority;
aio_reqprio = reqprio(opts.priority);
aio_lio_opcode = IOCB_CMD_PREADV;
aio_buf = uintptr_t(iov.data());
@ -144,7 +145,7 @@ ircd::fs::aio::request::write::write(const int &fd,
},
}}
{
aio_reqprio = opts.priority;
aio_reqprio = reqprio(opts.priority);
aio_lio_opcode = IOCB_CMD_PWRITEV;
aio_buf = uintptr_t(iov.data());
@ -217,6 +218,18 @@ ircd::fs::_zero_pads_required(const size_t &buf_size,
return alignment - (buf_size % alignment);
}
int
ircd::fs::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, ircd::info::aio_reqprio_max);
return input;
}
//
// aio
//

View file

@ -77,11 +77,12 @@ ircd::info::dump()
// This message flashes posix information about the resource limits
log::debug
{
"AS=%lu DATA=%lu RSS=%lu NOFILE=%zu",
"AS=%lu DATA=%lu RSS=%lu NOFILE=%zu; aio_reqprio_max=%d",
rlimit_as,
rlimit_data,
rlimit_rss,
rlimit_nofile
rlimit_nofile,
aio_reqprio_max
};
}
@ -197,6 +198,14 @@ ircd::info::glibc_version_str
glibc_version[2])
);
decltype(ircd::info::aio_reqprio_max)
ircd::info::aio_reqprio_max
{
#ifdef _SC_AIO_PRIO_DELTA_MAX
int(syscall(::sysconf, _SC_AIO_PRIO_DELTA_MAX))
#endif
};
#ifdef HAVE_SYS_UTSNAME_H
decltype(ircd::info::utsname)
ircd::info::utsname{[]