From e95599085add67f2449324fb6530a1a10186aa55 Mon Sep 17 00:00:00 2001 From: leitner Date: Mon, 27 Sep 2004 19:46:42 +0000 Subject: [PATCH] use madvise MADV_PREFETCH to implement iob_prefetch --- CHANGES | 1 + io/iob_prefetch.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGES b/CHANGES index 648b914..6e26401 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ 0.21: errno cleanup and man page updates (Rolf Eike Beer) + implement iob_prefetch with madvise MADV_WILLNEED if it's defined 0.20: add errmsg API diff --git a/io/iob_prefetch.c b/io/iob_prefetch.c index 53ac735..8285363 100644 --- a/io/iob_prefetch.c +++ b/io/iob_prefetch.c @@ -12,6 +12,12 @@ void iob_prefetch(io_batch* b,uint64 bytes) { if (!e) return; for (; etype==FROMFILE || e->type==FROMFILE_CLOSE) { +#ifdef MADV_WILLNEED + char* c; + c=mmap(0,bytes,PROT_READ,MAP_SHARED,e->fd,(e->offset|4095)+1); + madvise(c,bytes,MADV_WILLNEED); + munmap(c,bytes); +#else char* c,* d; uint64 before=bytes; if (e->nn; @@ -28,6 +34,7 @@ void iob_prefetch(io_batch* b,uint64 bytes) { } munmap(c,before); } +#endif return; } }