cmogstored.git  about / heads / tags
alternative mogstored implementation for MogileFS
blob f1d0772a043f894d6f87ad94518af9cfb49f85f7 865 bytes (raw)
$ git show gl-env: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-2016 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

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