From: oetiker Date: Thu, 17 May 2007 11:38:54 +0000 (+0000) Subject: now the fadvise code actually compiles ... let the testing begin. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0fee05c8267c79dfebe2d4c0d1271cf166ee5115;p=rrdtool-all.git now the fadvise code actually compiles ... let the testing begin. git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@1064 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/configure.ac b/program/configure.ac index 8e64c11a..f878dccd 100644 --- a/program/configure.ac +++ b/program/configure.ac @@ -71,7 +71,8 @@ char *strchr (), *strrchr (); #endif /* enable posix_fadvise on linux */ -#ifdef HAVE_POSIX_FADVISE +#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FCNTL_H) +#include #define __USE_XOPEN2K 1 #endif diff --git a/program/src/rrd_create.c b/program/src/rrd_create.c index 521c7261..6f4c8043 100644 --- a/program/src/rrd_create.c +++ b/program/src/rrd_create.c @@ -690,7 +690,7 @@ rrd_create_fn(const char *file_name, rrd_t *rrd) return(-1); } -#ifdef POSIX_FADVISE +#ifdef HAVE_POSIX_FADVISE /* this file is not going to be read again any time soon, so we drop everything except the header portion from the buffer cache. for this to work, we have to fdsync the file diff --git a/program/src/rrd_fetch.c b/program/src/rrd_fetch.c index 7e92c2ca..0676b4ac 100644 --- a/program/src/rrd_fetch.c +++ b/program/src/rrd_fetch.c @@ -456,11 +456,11 @@ fprintf(stderr,"partial match, not best\n"); fclose(in_file); return(-1); } -#ifdef POSIX_FADVISE +#ifdef HAVE_POSIX_FADVISE /* don't pollute the buffer cache with data read from the file. We do this while reading to keep damage minimal */ if (0 != posix_fadvise(fileno(in_file), rrd_head_size, ftell(in_file), POSIX_FADV_DONTNEED)) { - rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno)); + rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",filename, rrd_strerror(errno)); fclose(in_file); return(-1); } @@ -480,10 +480,10 @@ fprintf(stderr,"partial match, not best\n"); } rrd_free(&rrd); -#ifdef POSIX_FADVISE +#ifdef HAVE_POSIX_FADVISE /* and just to be sure we drop everything except the header at the end */ if (0 != posix_fadvise(fileno(in_file), rrd_head_size, 0, POSIX_FADV_DONTNEED)) { - rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno)); + rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",filename, rrd_strerror(errno)); fclose(in_file); return(-1); } diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index 8f081764..3740750f 100644 --- a/program/src/rrd_open.c +++ b/program/src/rrd_open.c @@ -88,7 +88,7 @@ rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) return (-1); } -#ifdef POSIX_FADVISE +#ifdef HAVE_POSIX_FADVISE /* In general we need no read-ahead when dealing with rrd_files. When we stop reading, it is highly unlikely that we start up again. In this manner we actually save time and diskaccess (and buffer cache). diff --git a/program/src/rrd_update.c b/program/src/rrd_update.c index dc1a492b..91a1d1bf 100644 --- a/program/src/rrd_update.c +++ b/program/src/rrd_update.c @@ -1398,16 +1398,16 @@ _rrd_update(const char *filename, const char *tmplt, int argc, const char **argv fclose(rrd_file); return(-1); } -#ifdef POSIX_FADVISE +#ifdef HAVE_POSIX_FADVISE /* with update we have write ops, so they will probably not be done by now, this means the buffers will not get freed. But calling this for the whole file - header will let the data off the hook as soon as it is written when if it is from a previous update cycle. Calling fdsync to force things is much too hard here. */ - if (0 != posix_fadvise(fileno(in_file), rra_begin, 0, POSIX_FADV_DONTNEED)) { - rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno)); - fclose(in_file); + if (0 != posix_fadvise(fileno(rrd_file), rra_begin, 0, POSIX_FADV_DONTNEED)) { + rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",filename, rrd_strerror(errno)); + fclose(rrd_file); return(-1); } #endif @@ -1449,11 +1449,11 @@ _rrd_update(const char *filename, const char *tmplt, int argc, const char **argv rra_start += rrd.rra_def[i].row_cnt *rrd.stat_head->ds_cnt*sizeof(rrd_value_t); } -#ifdef POSIX_FADVISE +#ifdef HAVE_POSIX_FADVISE /* same procedure as above ... */ - if (0 != posix_fadvise(fileno(in_file), rrd_head_size, 0, POSIX_FADV_DONTNEED)) { - rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",file_name, rrd_strerror(errno)); - fclose(in_file); + if (0 != posix_fadvise(fileno(rrd_file), rra_begin, 0, POSIX_FADV_DONTNEED)) { + rrd_set_error("setting POSIX_FADV_DONTNEED on '%s': %s",filename, rrd_strerror(errno)); + fclose(rrd_file); return(-1); } #endif