#endif
/* enable posix_fadvise on linux */
-#ifdef HAVE_POSIX_FADVISE
+#if defined(HAVE_POSIX_FADVISE) && defined(HAVE_FCNTL_H)
+#include <fcntl.h>
#define __USE_XOPEN2K 1
#endif
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
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);
}
}
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);
}
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).
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
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