]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/wscript: only check for F_SETLEASE being available at compile time
authorStefan Metzmacher <metze@samba.org>
Mon, 7 Dec 2020 10:38:59 +0000 (11:38 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 7 Dec 2020 19:02:33 +0000 (19:02 +0000)
F_GETLEASE/F_SETLEASE are available (at least) since Linux 2.4.0 from
2002.

We also should not have the configure check depend on the filesystem
we find at build time. It's very common that the build-environment is
much more restricted than the runtime-environment will be.

As a history we had this check on Samba 3.6:

 AC_CACHE_CHECK([for Linux kernel oplocks],samba_cv_HAVE_KERNEL_OPLOCKS_LINUX,[
 AC_TRY_RUN([
 #include <sys/types.h>
 #include <fcntl.h>
 #ifndef F_GETLEASE
 #define F_GETLEASE 1025
 #endif
 main() {
        int fd = open("/dev/null", O_RDONLY);
        return fcntl(fd, F_GETLEASE, 0) == -1;
 }
 ],
 samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=no,samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=cross)])
 if test x"$samba_cv_HAVE_KERNEL_OPLOCKS_LINUX" = x"yes"; then
    AC_DEFINE(HAVE_KERNEL_OPLOCKS_LINUX,1,[Whether to use linux kernel oplocks])
 fi

which didn't depend on the filesystem.

Then we got a broken check introduced in Samba 4.0 (a copy of the
F_NOTIFY check):

 # Check for Linux kernel oplocks
 conf.CHECK_CODE('''
 #include <sys/types.h>
 #include <fcntl.h>
 #include <signal.h>
 #ifndef F_NOTIFY
 #define F_NOTIFY 1026
 #endif
 main() {
         exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
        msg="Checking for Linux kernel oplocks")

this got "fixed" in Samba 4.7 (and backports to 4.6, 4.5 and 4.4) into

 # Check for Linux kernel oplocks
 conf.CHECK_CODE('''
 #include <sys/types.h>
 #include <fcntl.h>
 #include <signal.h>
 #ifndef F_GETLEASE
 #define F_GETLEASE 1025
 #endif
 main() {
         exit(fcntl(open("/tmp", O_RDONLY), F_GETLEASE, 0) == -1 ?  1 : 0);
 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
        msg="Checking for Linux kernel oplocks")

Lately it became dependend on the filesystem in the build-environment:

 # Check for Linux kernel oplocks
 conf.CHECK_CODE('''
 #include <sys/types.h>
 #include <fcntl.h>
 #include <signal.h>
 #ifndef F_GETLEASE
 #define F_GETLEASE 1025
 #endif
 main() {
       const char *fname="/tmp/oplock-test.txt";
       int fd = open(fname, O_RDWR|O_CREAT, 0644);
       int ret = fcntl(fd, F_SETLEASE, F_WRLCK);
       unlink(fname);
       return (ret == -1) ? 1 : 0;
 }''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
        msg="Checking for Linux kernel oplocks")

Now we just check for F_SETLEASE being available in linux/fcntl.h.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/wscript
source4/ntvfs/sysdep/wscript_configure

index cb51511353fdc4afdc3a581422ba3f8e5b723455..ba02a3586b9e34d515bb5e381ef601618a96dbd4 100644 (file)
@@ -166,21 +166,8 @@ long ret = splice(0,0,1,0,400,SPLICE_F_MOVE);
            conf.DEFINE('HAVE_INOTIFY', 1)
 
     # Check for Linux kernel oplocks
-    conf.CHECK_CODE('''
-#include <sys/types.h>
-#include <fcntl.h>
-#include <signal.h>
-#ifndef F_GETLEASE
-#define F_GETLEASE 1025
-#endif
-int main() {
-       const char *fname="/tmp/oplock-test.txt";
-       int fd = open(fname, O_RDWR|O_CREAT, 0644);
-       int ret = fcntl(fd, F_SETLEASE, F_WRLCK);
-       unlink(fname);
-       return (ret == -1) ? 1 : 0;
-}''', 'HAVE_KERNEL_OPLOCKS_LINUX', addmain=False, execute=True,
-        msg="Checking for Linux kernel oplocks")
+    if conf.CHECK_DECLS('F_SETLEASE', headers='linux/fcntl.h', reverse=True):
+        conf.DEFINE('HAVE_KERNEL_OPLOCKS_LINUX', 1)
 
     # Check for kernel share modes
     conf.CHECK_CODE('''
index 274fc08b58154003f8414f9d5b5e9b3c180a9ec0..20358848cd33572d2a12fd2b8a435665ec3d35da 100644 (file)
@@ -10,5 +10,4 @@ if host_os.rfind('sunos') == -1:
     if (conf.CONFIG_SET('HAVE_SYS_INOTIFY_H')):
         conf.DEFINE('HAVE_LINUX_INOTIFY', 1)
 
-conf.CHECK_DECLS('F_SETLEASE', headers='linux/fcntl.h', reverse=True)
 conf.CHECK_DECLS('SA_SIGINFO', headers='signal.h', reverse=True)