Commit afedd144 authored by Julius Plenz's avatar Julius Plenz

Add DOUBLEFADVISE compile time option

parent 241eade9
default: all
all: cachestats cachedel nocache.so
GCC = gcc $(CFLAGS)
%.c: Makefile
cachestats: cachestats.c
gcc -Wall -o cachestats cachestats.c
$(GCC) -Wall -o cachestats cachestats.c
cachedel: cachedel.c
gcc -Wall -o cachedel cachedel.c
$(GCC) -Wall -o cachedel cachedel.c
nocache.o: nocache.c
gcc -Wall -fPIC -c -o nocache.o nocache.c
$(GCC) -Wall -fPIC -c -o nocache.o nocache.c
fcntl_helpers.o: fcntl_helpers.c
gcc -Wall -fPIC -c -o fcntl_helpers.o fcntl_helpers.c
$(GCC) -Wall -fPIC -c -o fcntl_helpers.o fcntl_helpers.c
nocache.so: nocache.o fcntl_helpers.o
gcc -Wall -pthread -shared -Wl,-soname,nocache.so -o nocache.so nocache.o fcntl_helpers.o -ldl
$(GCC) -Wall -pthread -shared -Wl,-soname,nocache.so -o nocache.so nocache.o fcntl_helpers.o -ldl
install: all
install -m 0644 nocache.so /usr/local/lib
......
......@@ -90,6 +90,13 @@ the file descriptor is closed, this may not happen if they are left
open when the application exits, although the destructor tries to do
that.
There are timing issues to consider, as well. If you consider `nocache
cat <file>`, in most (all?) cases the cache will not be restored. For
discussion and possible solutions see <http://lwn.net/Articles/480930/>.
My experience showed that in many cases you could "fix" this by doing
the `posix_fadvise` call *twice*. If you want this behaviour, compile
the library using `make CFLAGS=-DDOUBLEFADVISE`.
Acknowledgements
----------------
......
......@@ -7,6 +7,9 @@
int fadv_dontneed(int fd, off_t offset, off_t len)
{
#ifdef DOUBLEFADVISE
posix_fadvise(fd, offset, len, POSIX_FADV_DONTNEED);
#endif
return posix_fadvise(fd, offset, len, POSIX_FADV_DONTNEED);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment