mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::fs: Add prefetch().
This commit is contained in:
parent
7f93f3ea2c
commit
79b2bdfb42
2 changed files with 28 additions and 0 deletions
|
@ -22,6 +22,9 @@ namespace ircd::fs
|
|||
// Yields ircd::ctx for read into allocated string; returns that string
|
||||
std::string read(const fd &, const read_opts & = read_opts_default);
|
||||
std::string read(const string_view &path, const read_opts & = read_opts_default);
|
||||
|
||||
// Prefetch bytes for subsequent read(); offset is given in opts.
|
||||
void prefetch(const fd &, const size_t &, const read_opts & = read_opts_default);
|
||||
}
|
||||
|
||||
/// Options for a read operation
|
||||
|
|
25
ircd/fs.cc
25
ircd/fs.cc
|
@ -122,6 +122,31 @@ const ircd::fs::read_opts_default
|
|||
// ircd::fs interface linkage
|
||||
//
|
||||
|
||||
#ifdef __linux__
|
||||
void
|
||||
ircd::fs::prefetch(const fd &fd,
|
||||
const size_t &count,
|
||||
const read_opts &opts)
|
||||
{
|
||||
const auto flags
|
||||
{
|
||||
syscall(::fcntl, fd, F_GETFL)
|
||||
};
|
||||
|
||||
if(flags & O_DIRECT)
|
||||
return; //TODO: AIO prefetch scheme
|
||||
|
||||
syscall(::readahead, fd, opts.offset, count);
|
||||
}
|
||||
#else
|
||||
void
|
||||
ircd::fs::prefetch(const fd &fd,
|
||||
const size_t &count,
|
||||
const read_opts &opts)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string
|
||||
ircd::fs::read(const string_view &path,
|
||||
const read_opts &opts)
|
||||
|
|
Loading…
Reference in a new issue