]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Replace check for _POSIX_MEMLOCK w/ HAVE_MLOCKALL
authorChris Dunlap <cdunlap@llnl.gov>
Tue, 1 Apr 2014 21:21:56 +0000 (14:21 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 2 Apr 2014 20:10:08 +0000 (13:10 -0700)
zed supports a '-M' cmdline opt to lock all pages in memory via
mlockall().  The _POSIX_MEMLOCK define is checked to determine whether
this function is supported.  The current test assumes mlockall()
is supported if _POSIX_MEMLOCK is non-zero.  However, this test is
insufficient according to mlock(2) and sysconf(3).  If _POSIX_MEMLOCK
is -1, mlockall() is not supported; but if _POSIX_MEMLOCK is 0,
availability must be checked at runtime.

This commit adds an autoconf check for mlockall() to user.m4.  The zed
code block for mlockall() is now guarded with a test for HAVE_MLOCKALL.
If defined, mlockall() will be called and its runtime availability
checked via its return value.

Signed-off-by: Chris Dunlap <cdunlap@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #2

cmd/zed/zed.c
config/user.m4

index d2fc0e89971775c4b00d2b4ba3a777dea143d16d..c54a59b0a7b74dc1d0c2bdb6a132561886ed01f9 100644 (file)
@@ -97,10 +97,7 @@ _setup_sig_handlers(void)
 static void
 _lock_memory(void)
 {
-#if ! _POSIX_MEMLOCK
-       zed_log_die("Failed to lock memory pages: mlockall() not supported");
-
-#else /* _POSIX_MEMLOCK */
+#if HAVE_MLOCKALL
        int i = 0;
        const int max_tries = 10;
 
@@ -114,7 +111,9 @@ _lock_memory(void)
        }
        zed_log_die("Failed to lock memory pages: %s", strerror(errno));
 
-#endif /* _POSIX_MEMLOCK */
+#else /* HAVE_MLOCKALL */
+       zed_log_die("Failed to lock memory pages: mlockall() not supported");
+#endif /* HAVE_MLOCKALL */
 }
 
 /*
index 6c127820c94d31f0dfdc34cdeff710b524193d62..38024370bbb469379941f328860a9ec8d7c5b9ee 100644 (file)
@@ -13,4 +13,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
        ZFS_AC_CONFIG_USER_LIBBLKID
        ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN
        ZFS_AC_CONFIG_USER_RUNSTATEDIR
+dnl #
+dnl #  Checks for library functions
+       AC_CHECK_FUNCS([mlockall])
 ])