mirror of
https://github.com/matrix-construct/construct
synced 2024-09-28 19:58:53 +02:00
ircd::fs: Add an evict() front to cache interface; add preconditions.
This commit is contained in:
parent
e75c9fe54c
commit
d9812f3e86
2 changed files with 31 additions and 1 deletions
|
@ -32,6 +32,9 @@ namespace ircd::fs
|
||||||
|
|
||||||
// Prefetch data for subsequent read(); offset given in opts (WILLNEED).
|
// Prefetch data for subsequent read(); offset given in opts (WILLNEED).
|
||||||
size_t prefetch(const fd &, const size_t &, const read_opts & = read_opts_default);
|
size_t prefetch(const fd &, const size_t &, const read_opts & = read_opts_default);
|
||||||
|
|
||||||
|
// Evict data which won't be read anymore (DONTNEED).
|
||||||
|
size_t evict(const fd &, const size_t &, const read_opts & = read_opts_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Options for a read operation
|
/// Options for a read operation
|
||||||
|
|
29
ircd/fs.cc
29
ircd/fs.cc
|
@ -486,14 +486,31 @@ ircd::fs::read_opts
|
||||||
const ircd::fs::read_opts_default
|
const ircd::fs::read_opts_default
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
size_t
|
||||||
|
ircd::fs::evict(const fd &fd,
|
||||||
|
const size_t &count,
|
||||||
|
const read_opts &opts)
|
||||||
|
{
|
||||||
|
#if defined(POSIX_FADV_DONTNEED)
|
||||||
|
return advise(fd, count, opts, POSIX_FADV_DONTNEED);
|
||||||
|
#else
|
||||||
|
return 0UL;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
ircd::fs::prefetch(const fd &fd,
|
ircd::fs::prefetch(const fd &fd,
|
||||||
const size_t &count,
|
const size_t &count,
|
||||||
const read_opts &opts)
|
const read_opts &opts)
|
||||||
{
|
{
|
||||||
return advise(fd, count, opts, POSIX_FADV_WILLNEED);
|
#if defined(POSIX_FADV_WILLNEED)
|
||||||
|
return advise(fd, count, opts, POSIX_FADV_WILLNEED);
|
||||||
|
#else
|
||||||
|
return 0UL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_POSIX_FADVISE)
|
||||||
size_t
|
size_t
|
||||||
ircd::fs::advise(const fd &fd,
|
ircd::fs::advise(const fd &fd,
|
||||||
const size_t &count,
|
const size_t &count,
|
||||||
|
@ -518,6 +535,16 @@ ircd::fs::advise(const fd &fd,
|
||||||
while(off + cnt < opts.offset + count);
|
while(off + cnt < opts.offset + count);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
size_t
|
||||||
|
ircd::fs::advise(const fd &fd,
|
||||||
|
const size_t &count,
|
||||||
|
const read_opts &opts,
|
||||||
|
const int &advice)
|
||||||
|
{
|
||||||
|
return 0UL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ircd::fs::fincore(const fd &fd,
|
ircd::fs::fincore(const fd &fd,
|
||||||
|
|
Loading…
Reference in a new issue