1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| | /*
* Copyright (C) 2012-2015 all contributors <cmogstored-public@bogomips.org>
* License: GPLv3 or later (see COPYING for details)
*/
#if defined(HAVE_POSIX_FADVISE)
static inline void mog_fadv_sequential(int fd, off_t offset, off_t len)
{
int rc = posix_fadvise(fd, offset, len, POSIX_FADV_SEQUENTIAL);
if (rc == 0) return;
assert(errno != EBADF && errno != ESPIPE &&
"BUG: posix_fadvise(POSIX_FADV_SEQUENTIAL) failed");
}
static inline void mog_fadv_noreuse(int fd, off_t offset, off_t len)
{
int rc = posix_fadvise(fd, offset, len, POSIX_FADV_NOREUSE);
if (rc == 0) return;
assert(errno != EBADF && errno != ESPIPE &&
"BUG: posix_fadvise(POSIX_FADV_NOREUSE) failed");
}
#else
static inline void mog_fadv_sequential(int fd, off_t offset, off_t len)
{
}
static inline void mog_fadv_noreuse(int fd, off_t offset, off_t len)
{
}
#endif
|