posix_fadvice advice parameter change
authorSami Kerola <kerolasa@iki.fi>
Sat, 22 Jan 2011 21:05:53 +0000 (22:05 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 22 Jan 2011 21:05:53 +0000 (22:05 +0100)
With a bit of manual rereading and thinking I came to conclusion
that users will most likely fetch same data over and over again.
Advicing to kernel to keep pages into cache seems to be correct
thing to do.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>

src/getdata.c

index b1e79b9..1a7cba8 100644 (file)
@@ -76,16 +76,16 @@ int parse_leases(void)
                err(EXIT_FAILURE, "parse_leases: %s",
                    config.dhcpdlease_file);
        }
                err(EXIT_FAILURE, "parse_leases: %s",
                    config.dhcpdlease_file);
        }
-#ifdef POSIX_FADV_NOREUSE
-       posix_fadvise((long) dhcpd_leases, 0, 0, POSIX_FADV_NOREUSE);
+#ifdef POSIX_FADV_WILLNEED
+       posix_fadvise((long) dhcpd_leases, 0, 0, POSIX_FADV_WILLNEED);
        if (errno) {
        if (errno) {
-               err(EXIT_FAILURE, "parse_leases: fadvise noreuse");
+               err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file);
        }
        }
-#endif                         /* POSIX_FADV_NOREUSE */
+#endif                         /* POSIX_FADV_WILLNEED */
 #ifdef POSIX_FADV_SEQUENTIAL
        posix_fadvise((long) dhcpd_leases, 0, 0, POSIX_FADV_SEQUENTIAL);
        if (errno) {
 #ifdef POSIX_FADV_SEQUENTIAL
        posix_fadvise((long) dhcpd_leases, 0, 0, POSIX_FADV_SEQUENTIAL);
        if (errno) {
-               err(EXIT_FAILURE, "parse_leases: fadvise sequential");
+               err(EXIT_FAILURE, "parse_leases: fadvise %s", config.dhcpdlease_file);
        }
 #endif                         /* POSIX_FADV_SEQUENTIAL */
 
        }
 #endif                         /* POSIX_FADV_SEQUENTIAL */
 
@@ -228,16 +228,16 @@ char *parse_config(int is_include, char *config_file,
        if (dhcpd_config == NULL) {
                err(EXIT_FAILURE, "parse_config: %s", config_file);
        }
        if (dhcpd_config == NULL) {
                err(EXIT_FAILURE, "parse_config: %s", config_file);
        }
-#ifdef POSIX_FADV_NOREUSE
-       posix_fadvise((long) dhcpd_config, 0, 0, POSIX_FADV_NOREUSE);
+#ifdef POSIX_FADV_WILLNEED
+       posix_fadvise((long) dhcpd_config, 0, 0, POSIX_FADV_WILLNEED);
        if (errno) {
        if (errno) {
-               err(EXIT_FAILURE, "parse_config: fadvise noreuse");
+               err(EXIT_FAILURE, "parse_config: fadvise %s", config_file);
        }
        }
-#endif                         /* POSIX_FADV_NOREUSE */
+#endif                         /* POSIX_FADV_WILLNEED */
 #ifdef POSIX_FADV_SEQUENTIAL
        posix_fadvise((long) dhcpd_config, 0, 0, POSIX_FADV_SEQUENTIAL);
        if (errno) {
 #ifdef POSIX_FADV_SEQUENTIAL
        posix_fadvise((long) dhcpd_config, 0, 0, POSIX_FADV_SEQUENTIAL);
        if (errno) {
-               err(EXIT_FAILURE, "parse_config: fadvise sequential");
+               err(EXIT_FAILURE, "parse_config: fadvise %s", config_file);
        }
 #endif                         /* POSIX_FADV_SEQUENTIAL */
 
        }
 #endif                         /* POSIX_FADV_SEQUENTIAL */