0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

ircd::fs::aio: Add debug mechanism to warn read will block io_submit(2).

This commit is contained in:
Jason Volk 2019-04-29 15:03:33 -07:00
parent 0c7dcf6cc7
commit 04020da7e4
2 changed files with 41 additions and 2 deletions

View file

@ -197,12 +197,46 @@ ircd::fs::aio::read(const fd &fd,
const scope_count cur_reads{stats.cur_reads};
stats.max_reads = std::max(stats.max_reads, stats.cur_reads);
// Make request; blocks ircd::ctx until completed or throw.
const size_t bytes
#if defined(RB_DEBUG_FS_AIO_READ_BLOCKING)
request.aio_rw_flags |= support_nowait? RWF_NOWAIT : 0;
#endif
size_t bytes
{
request()
};
#if defined(RB_DEBUG_FS_AIO_READ_BLOCKING)
const bool would_block
{
opts.blocking &&
request.aio_rw_flags & RWF_NOWAIT &&
request.retval == -1 &&
request.errcode == EAGAIN
};
if(would_block)
{
log::dwarning
{
log, "read blocks io_submit(): fd:%d size:%zu off:%zd op:%u pri:%u in_flight:%zu qcount:%zu",
request.aio_fildes,
request.aio_nbytes,
request.aio_offset,
request.aio_lio_opcode,
request.aio_reqprio,
system->in_flight,
system->qcount,
};
assert(bytes == 0);
request.aio_rw_flags &= ~RWF_NOWAIT;
request.retval = -2;
request.errcode = 0;
bytes = request();
}
#endif
stats.bytes_read += bytes;
stats.reads++;
return bytes;

View file

@ -12,6 +12,11 @@
#define HAVE_FS_AIO_H
#include <linux/aio_abi.h>
/// Define this to try all read requests with RWF_NOWAIT first and indicate
/// EAGAIN failure with a log dwarning. On EAGAIN the request is resubmitted
/// without RWF_NOWAIT if the user expected blocking behavior.
//#define RB_DEBUG_FS_AIO_READ_BLOCKING
namespace ircd::fs::aio
{
struct system;