Merge pull request #396 from trapexit/fadvise

fadvise cleanup
This commit is contained in:
Antonio SJ Musumeci 2017-04-11 09:03:12 -04:00 committed by GitHub
commit 1499ccf3fb
4 changed files with 46 additions and 4 deletions

View File

@ -21,3 +21,30 @@
#else #else
# include "fs_base_fadvise_unsupported.icpp" # include "fs_base_fadvise_unsupported.icpp"
#endif #endif
namespace fs
{
int
fadvise_dontneed(const int fd,
const off_t offset,
const off_t len)
{
return fs::fadvise(fd,offset,len,POSIX_FADV_DONTNEED);
}
int
fadvise_willneed(const int fd,
const off_t offset,
const off_t len)
{
return fs::fadvise(fd,offset,len,POSIX_FADV_WILLNEED);
}
int
fadvise_sequential(const int fd,
const off_t offset,
const off_t len)
{
return fs::fadvise(fd,offset,len,POSIX_FADV_SEQUENTIAL);
}
}

View File

@ -48,6 +48,21 @@ namespace fs
const off_t offset, const off_t offset,
const off_t len, const off_t len,
const int advice); const int advice);
int
fadvise_dontneed(const int fd,
const off_t offset = 0,
const off_t len = 0);
int
fadvise_willneed(const int fd,
const off_t offset = 0,
const off_t len = 0);
int
fadvise_sequential(const int fd,
const off_t offset = 0,
const off_t len = 0);
} }
#endif // __FS_FADVISE_HPP__ #endif // __FS_FADVISE_HPP__

View File

@ -122,8 +122,8 @@ copydata(const int fdin,
{ {
int rv; int rv;
fs::fadvise(fdin,0,count,POSIX_FADV_WILLNEED); fs::fadvise_willneed(fdin,0,count);
fs::fadvise(fdin,0,count,POSIX_FADV_SEQUENTIAL); fs::fadvise_sequential(fdin,0,count);
fs::fallocate(fdout,0,0,count); fs::fallocate(fdout,0,0,count);

View File

@ -33,8 +33,8 @@ _release(FileInfo *fi,
// https://github.com/Feh/nocache // https://github.com/Feh/nocache
if(dropcacheonclose) if(dropcacheonclose)
{ {
fs::fadvise(fi->fd,0,0,POSIX_FADV_DONTNEED); fs::fadvise_dontneed(fi->fd);
fs::fadvise(fi->fd,0,0,POSIX_FADV_DONTNEED); fs::fadvise_dontneed(fi->fd);
} }
fs::close(fi->fd); fs::close(fi->fd);