mirror of
https://github.com/trapexit/mergerfs.git
synced 2024-11-26 18:31:12 +08:00
commit
1499ccf3fb
|
@ -21,3 +21,30 @@
|
|||
#else
|
||||
# include "fs_base_fadvise_unsupported.icpp"
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,21 @@ namespace fs
|
|||
const off_t offset,
|
||||
const off_t len,
|
||||
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__
|
||||
|
|
|
@ -122,8 +122,8 @@ copydata(const int fdin,
|
|||
{
|
||||
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);
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ _release(FileInfo *fi,
|
|||
// https://github.com/Feh/nocache
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user