Whamcloud - gitweb
LU-12036 ofd: add "no_precreate" mount option
[fs/lustre-release.git] / lnet / lnet / acceptor.c
index 9eea92c..232018b 100644 (file)
@@ -44,6 +44,7 @@ static struct {
        int                     pta_shutdown;
        struct socket           *pta_sock;
        struct completion       pta_signal;
+       struct net              *pta_ns;
 } lnet_acceptor_state = {
        .pta_shutdown = 1
 };
@@ -150,7 +151,7 @@ EXPORT_SYMBOL(lnet_connect_console_error);
 
 int
 lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
-           __u32 local_ip, __u32 peer_ip, int peer_port)
+           __u32 local_ip, __u32 peer_ip, int peer_port, struct net *ns)
 {
        struct lnet_acceptor_connreq cr;
        struct socket           *sock;
@@ -158,7 +159,7 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
        int                     port;
        int                     fatal;
 
-       CLASSERT(sizeof(cr) <= 16);             /* not too big to be on the stack */
+       BUILD_BUG_ON(sizeof(cr) > 16); /* not too big to be on the stack */
 
        for (port = LNET_ACCEPTOR_MAX_RESERVED_PORT;
             port >= LNET_ACCEPTOR_MIN_RESERVED_PORT;
@@ -167,14 +168,14 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
 
                rc = lnet_sock_connect(&sock, &fatal,
                                         local_ip, port,
-                                        peer_ip, peer_port);
+                                        peer_ip, peer_port, ns);
                if (rc != 0) {
                        if (fatal)
                                goto failed;
                        continue;
                }
 
-               CLASSERT(LNET_PROTO_ACCEPTOR_VERSION == 1);
+               BUILD_BUG_ON(LNET_PROTO_ACCEPTOR_VERSION != 1);
 
                cr.acr_magic   = LNET_PROTO_ACCEPTOR_MAGIC;
                cr.acr_version = LNET_PROTO_ACCEPTOR_VERSION;
@@ -354,7 +355,8 @@ lnet_acceptor(void *arg)
        cfs_block_allsigs();
 
        rc = lnet_sock_listen(&lnet_acceptor_state.pta_sock,
-                               0, accept_port, accept_backlog);
+                             0, accept_port, accept_backlog,
+                             lnet_acceptor_state.pta_ns);
        if (rc != 0) {
                if (rc == -EADDRINUSE)
                        LCONSOLE_ERROR_MSG(0x122, "Can't start acceptor on port"
@@ -478,13 +480,15 @@ lnet_acceptor_start(void)
 
        if (lnet_count_acceptor_nets() == 0)  /* not required */
                return 0;
-
+       if (current->nsproxy && current->nsproxy->net_ns)
+               lnet_acceptor_state.pta_ns = current->nsproxy->net_ns;
+       else
+               lnet_acceptor_state.pta_ns = &init_net;
        task = kthread_run(lnet_acceptor, (void *)(uintptr_t)secure,
                           "acceptor_%03ld", secure);
        if (IS_ERR(task)) {
                rc2 = PTR_ERR(task);
                CERROR("Can't start acceptor thread: %ld\n", rc2);
-
                return -ESRCH;
        }