Whamcloud - gitweb
LU-9558 lnet: kernel socket accept takes new bool agrument 63/28463/2
authorJames Simmons <uja.ornl@yahoo.com>
Wed, 14 Jun 2017 16:42:52 +0000 (12:42 -0400)
committerJohn L. Hammond <john.hammond@intel.com>
Wed, 16 Aug 2017 20:44:05 +0000 (20:44 +0000)
During the development of the linux 4.11 kernel it was discovered
that the kernel socket layer could get into lockdep situation. To
handle this a new bool argument was added to the accept member
of struct socket. For LNet we can always pass false.

Lustre-commit: 15045c9067fd021baa0ec925bcc245949945d01e
Lustre-change: https://review.whamcloud.com/27642

Change-Id: I420cda95b70cf927b1a6e3493b631bc5a3585d74
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/27642
Reviewed-by: Doug Oucharek <doug@cadentcomputing.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-on: https://review.whamcloud.com/28463
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lnet/autoconf/lustre-lnet.m4
lnet/lnet/lib-socket.c

index c360244..2ae3144 100644 (file)
@@ -735,6 +735,27 @@ LB_CHECK_EXPORT([kmap_to_page], [mm/highmem.c],
 ]) # LN_EXPORT_KMAP_TO_PAG
 
 #
+# LN_CONFIG_SOCK_ACCEPT
+#
+# 4.11 commit cdfbabfb2f0ce983fdaa42f20e5f7842178fc01e added a flag
+# to handle a possible lockdep condition kernel socket accept.
+#
+AC_DEFUN([LN_CONFIG_SOCK_ACCEPT], [
+tmp_flags="$EXTRA_KCFLAGS"
+EXTRA_KCFLAGS="-Werror"
+LB_CHECK_COMPILE([if 'struct sock' accept function requires a bool argument],
+kern_sock_flag, [
+       #include <linux/net.h>
+],[
+       ((struct socket *)0)->ops->accept(NULL, NULL, O_NONBLOCK, false);
+],[
+       AC_DEFINE(HAVE_KERN_SOCK_ACCEPT_FLAG_ARG, 1,
+               ['struct sock' accept function requires bool argument])
+])
+EXTRA_KCFLAGS="$tmp_flags"
+]) # LN_CONFIG_SOCK_ACCEPT
+
+#
 # LN_PROG_LINUX
 #
 # LNet linux kernel checks
@@ -753,10 +774,12 @@ LN_CONFIG_SK_SLEEP
 LN_CONFIG_TCP_SENDPAGE
 # 3.10
 LN_EXPORT_KMAP_TO_PAGE
-# 4.x
-LN_CONFIG_SOCK_CREATE_KERN
 # 3.15
 LN_CONFIG_SK_DATA_READY
+# 4.x
+LN_CONFIG_SOCK_CREATE_KERN
+# 4.11
+LN_CONFIG_SOCK_ACCEPT
 ]) # LN_PROG_LINUX
 
 #
index 4eaaf6c..57678b3 100644 (file)
@@ -582,7 +582,11 @@ lnet_sock_accept(struct socket **newsockp, struct socket *sock)
 
        newsock->ops = sock->ops;
 
+#ifdef HAVE_KERN_SOCK_ACCEPT_FLAG_ARG
+       rc = sock->ops->accept(sock, newsock, O_NONBLOCK, false);
+#else
        rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
+#endif
        if (rc == -EAGAIN) {
                /* Nothing ready, so wait for activity */
                init_waitqueue_entry(&wait, current);
@@ -590,7 +594,11 @@ lnet_sock_accept(struct socket **newsockp, struct socket *sock)
                set_current_state(TASK_INTERRUPTIBLE);
                schedule();
                remove_wait_queue(sk_sleep(sock->sk), &wait);
+#ifdef HAVE_KERN_SOCK_ACCEPT_FLAG_ARG
+               rc = sock->ops->accept(sock, newsock, O_NONBLOCK, false);
+#else
                rc = sock->ops->accept(sock, newsock, O_NONBLOCK);
+#endif
        }
 
        if (rc != 0)