cmogstored.git  about / heads / tags
alternative mogstored implementation for MogileFS
blob e7a9ff99dc0096fa36a1861cba20a7e7b1982082 872 bytes (raw)
$ git show HEAD:fadvise.h	# shows this blob on the CLI

 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-2020 all contributors <cmogstored-public@yhbt.net>
 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
 */
#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

git clone https://yhbt.net/cmogstored.git