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

ircd::fs: Add write_life hint fcntl front.

This commit is contained in:
Jason Volk 2019-05-03 19:53:05 -07:00
parent abae2c02f5
commit 82200a9abd
3 changed files with 36 additions and 1 deletions

View file

@ -19,6 +19,8 @@ namespace ircd::fs
size_t block_size(const fd &);
ulong fstype(const fd &);
ulong device(const fd &);
uint64_t write_life(const fd &);
void write_life(const fd &, const uint64_t &);
}
/// File Desc++ptor. This is simply a native fd (i.e. integer) with c++ object

View file

@ -2067,7 +2067,7 @@ noexcept
#endif
this->hint = hint;
//TODO: fcntl F_SET_FILE_RW_HINT
fs::write_life(fd, this->hint);
}
rocksdb::Env::WriteLifeTimeHint

View file

@ -1503,6 +1503,39 @@ ircd::fs::fd::opts::direct_io_enable
{ "persist", false },
};
#if defined(HAVE_FCNTL_H) && defined(F_SET_FILE_RW_HINT)
void
ircd::fs::write_life(const fd &fd,
const uint64_t &hint)
{
syscall(::fcntl, int(fd), F_SET_FILE_RW_HINT, &hint);
}
#else
#warning "F_SET_FILE_RW_HINT not supported on platform."
void
ircd::fs::write_life(const fd &fd,
const uint64_t &hint)
{
}
#endif
#if defined(HAVE_FCNTL_H) && defined(F_GET_FILE_RW_HINT)
uint64_t
ircd::fs::write_life(const fd &fd)
{
uint64_t ret;
syscall(::fcntl, int(fd), F_GET_FILE_RW_HINT, &ret);
return ret;
}
#else
#warning "F_GET_FILE_RW_HINT not supported on platform."
uint64_t
ircd::fs::write_life(const fd &fd)
{
return 0UL;
}
#endif
#ifdef HAVE_SYS_STAT_H
ulong
ircd::fs::device(const fd &fd)