Browse Source

fadvise cleanup

pull/396/head
Antonio SJ Musumeci 8 years ago
parent
commit
1a1fa06aa3
  1. 27
      src/fs_base_fadvise.cpp
  2. 15
      src/fs_base_fadvise.hpp
  3. 4
      src/fs_clonefile.cpp
  4. 4
      src/release.cpp

27
src/fs_base_fadvise.cpp

@ -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);
}
}

15
src/fs_base_fadvise.hpp

@ -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__

4
src/fs_clonefile.cpp

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

4
src/release.cpp

@ -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(fi->fd,0,0,POSIX_FADV_DONTNEED);
fs::fadvise_dontneed(fi->fd);
fs::fadvise_dontneed(fi->fd);
} }
fs::close(fi->fd); fs::close(fi->fd);

Loading…
Cancel
Save